[R] Help!!

Duncan Murdoch murdoch at stats.uwo.ca
Wed Jan 29 15:39:47 CET 2003


On Tue, 28 Jan 2003 16:01:06 +0000, you wrote in message
<F171eRaNgEpTX5V3Gyk00000356 at hotmail.com>:

>
>Dear R ers, if some can tel me how I can generate a sample from a given 
>density. I have a complex  2D density function en I want to genearte
>a sample from it? Any package?

That's generally a hard problem, and the answer depends a lot on the
particular characteristics of your distribution.  The easiest general
purpose method if you can calculate the density is probably MCMC, in
particular random walk Metropolis; see the book Markov Chain Monte
Carlo in Practice for details.  This will give you a Markov chain that
(hopefully) converges to your target distribution.  If you only want a
small sample, it's quite inefficient, but for a large sample (e.g. for
estimating moments) it can be quite good.

Support in R for MCMC is pretty much non-existent, but it's easy to
write the chains yourself.

Duncan Murdoch




More information about the R-help mailing list