Simulate a Random Field Process

DESCRIPTION:

Simulate an isotropic random field at locations x and y with user supplied covariance function.

USAGE:

rfsim(x, y, covfun, z=rnorm(length(x)), nc=1000, ...) 

REQUIRED ARGUMENTS:

x
a vector of x locations. Alternatively, x can be a matrix with at least two columns or a list with at least two components. The first column or component contains the x location and the second contains the y locations.
y
a vector of y locations, must be the same length as x.
covfun
an S-PLUS function that computes the covariance for the random field as a function of distance. The first argument should be distance. covfun(0, ...) should give the variance of the random field.

OPTIONAL ARGUMENTS:

z
a vector of independent, unit variance random values. This must be the same length as x and y. These will be transformed to have covariance covfun.
nc
the number of distance values used in the interpolation of the covariance function. Increasing this value may give a more accurate result at the cost of increased computation time.
...
additional named arguments that will be passed to covfun, typically the parameters for the covariance function.

VALUE:

a vector of random values with covariance function covfun.

SIDE EFFECTS:

If z is not supplied, the value of the data set .Random.seed is updated if it already exists, otherwise .Random.seed is created.

DETAILS:

The covariance matrix as a function of distance is formed. The z vector is then multipled by the Cholesky decomposition of this matrix to obtain the result. Linear interpolation over the fixed nh values of distance and cov.fun is used in computing the covariance matrix.

Although the covariance matrix is formed in C code and only the upper triangular is actually formed, it can require large amounts of memory. A 100 x 100 grid of locations will require ((100 * 100) * (100 * 100) + 1) / 2 * 8 bytes / value = 400040000 bytes or about 400 Mb of memory.

SEE ALSO:

.

EXAMPLES:

# Simulate a Gaussian random field on a 12 x 12 grid with exponential 
# covariance function 
x12 <- expand.grid(x=1:12,y=1:12) 
z <- rfsim(x12,covfun=exp.cov,range=3)