[R-sig-Geo] Unconditional simulation

Tomislav Hengl hengl at spatial-analyst.net
Tue Nov 17 11:46:15 CET 2009


Hi Nick,

Very interesting problem. At first thought, I imagined that you just want to simulate noise  ;)

In the geoR package (http://leg.ufpr.br/geoR/) there is a function to simulate Gaussian Random
Fields (uses actually RandomFields package) using various models e.g.:

> library(geoR)
-------------------------------------------------------------
Analysis of geostatistical data
For an Introduction to geoR go to http://www.leg.ufpr.br/geoR
geoR version 1.6-27 (built on 2009-10-15) is now loaded
-------------------------------------------------------------
> s <- grf(100, grid="reg", cov.pars=c(2, 0.2), cov.model="mat", kappa=1.5)
grf: generating grid  10  *  10  with  100  points
grf: process with  1  covariance structure(s)
grf: nugget effect is: tausq= 0 
grf: covariance model 1 is: matern(sigmasq=2, phi=0.2, kappa = 1.5)
grf: decomposition algorithm used is:  cholesky 
grf: End of simulation procedure. Number of realizations: 1 
> image(s, col=gray(seq(1, 0.2, l=21)))
> hist(s$data)  # normal distribution

You can also simulate a regular point sample with the same spatial structure on top of that using
either Poisson, Bernoulli or binomial models. For example, to simulate a Poisson model, you could
use:

# define your own model, e.g. poisson:
> lambda <- exp(0.5 +s$data)
> y <- rpois(length(s$data), lambda=lambda)
> points(y)
> text(s$coords, label=y, pos=3, offset=0.3)
> hist(y)

For a uniform model, I would then use the Empirical Cumulative Distribution Function (ECDF):

# uniform distribution:
> y.cdf <- ecdf(s$data)
> y <- y.cdf(s$data)
> image(s, col=gray(seq(1, 0.2, l=21)))
> points(y)
> text(s$coords, label=y, pos=3, offset=0.3)
> hist(y)

This would then have the same spatial auto-correlation structure and 'perfectly' uniform
distribution (I might also be wrong - I do not like that a simulated variable has a perfect
histogram).

I am sure that other mathematicians have maybe better ideas.


HTH

T. Hengl
http://home.medewerker.uva.nl/t.hengl/ 





> -----Original Message-----
> From: r-sig-geo-bounces at stat.math.ethz.ch [mailto:r-sig-geo-bounces at stat.math.ethz.ch] On Behalf
> Of Nick Hamm
> Sent: Tuesday, November 17, 2009 10:06 AM
> To: r-sig-geo at stat.math.ethz.ch; ai-geostats at jrc.it
> Subject: [R-sig-Geo] Unconditional simulation
> 
> Dear all
> 
> I want to simulate a spatially-correlated random field which follows a
> uniform rather than than Gaussian distribution.  Does anybody know a
> straight-forward way to do this?
> 
> Nick
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo



More information about the R-sig-Geo mailing list