[R] How to generate a random field with truncated marginal distributions?

Ben Bolker bbolker at gmail.com
Mon Nov 12 20:49:10 CET 2012


On 12-11-12 02:05 PM, Mark Leeds wrote:
> Hi: Not sure if totally relevant because I didn't read it but it might
> help or atleast
> be of interest.
> 
> http://journal.r-project.org/archive/2010-1/RJournal_2010-1_Wilhelm+Manjunath.pdf

  This definitely looks relevant. The critical question will be how
large a sample the original questioner needs to generate.  If it's not
too big, then they can just construct their own correlation matrix, and
go from there.

  Ben
> 
> 
> On Mon, Nov 12, 2012 at 12:15 PM, Ben Bolker <bbolker at gmail.com
> <mailto:bbolker at gmail.com>> wrote:
> 
>     Zhenglei Gao <zhenglei.gao <at> bayer.com <http://bayer.com>> writes:
> 
>     >  I have asked the same question on stackoverflow but did not get a
>     > satisfying answer.
> 
>     > I am trying to simulate a lognormal spatial random field but I need
>     > the simulated value in a certain range. So I need some easy to use
>     > functions to generate a truncated Gaussian field to start with. To
>     > be specific, I need a function like GaussRF from the RandomFields
>     > package or grf from the geoR package to generate a random field, but
>     > I need the generated field to have a truncated marginal
>     > distributions and a correlation structure with a prescribed
>     > range. Is there an R package or functions which can do this? If
>     > there is no availabe read-to-use functions or packages,is it
>     > possible that I write my own very easily?
> 
>       As I suggested on Stack Overflow, I don't think this is a simple
>     question: you can pick values according to a normal distribution and
>     then squash them into a truncated normal distribution: something like
> 
>     olddata <- GaussRF(...)
>     library(truncnorm)
>     newdata <- qtruncnorm(pnorm(olddata))
> 
>       However, this may very well modify the range; I don't know.
>     If I were you, I would try it and see if you can live with the
>     results.  If not, ask on http://stats.stackexchange.com
> 
>     ______________________________________________
>     R-help at r-project.org <mailto:R-help at r-project.org> mailing list
>     https://stat.ethz.ch/mailman/listinfo/r-help
>     PLEASE do read the posting guide
>     http://www.R-project.org/posting-guide.html
>     and provide commented, minimal, self-contained, reproducible code.
> 
>




More information about the R-help mailing list