Zhenglei Gao <zhenglei.gao <at> 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@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.