Learn R Programming

geoR (version 1.0-0)

grf: Simulation of Gaussian Random Fields

Description

Generates simulations of Gaussian random fields for given covariance parameters.

Usage

grf(n, grid = "irreg", nx = round(sqrt(n)), ny = round(sqrt(n)), 
    xlims = c(0, 1), ylims = c(0, 1), nsim = 1, 
    cov.model = c("exponential", "matern", "gaussian",
                  "spherical", "circular", "cubic", "wave",
                  "powered.exponential", "cauchy", "gneiting",
                  "gneiting.matern", "pure.nugget"),
    cov.pars = stop("cov. parameters (sigmasq and phi) needed"), 
    kappa = 0.5, nugget = 0, lambda = 1, aniso.pars,
    method = c("cholesky", "svd", "eigen", "circular.embedding"),
    messages.screen = TRUE)

Arguments

n
number of points (spatial locations) in each simulations.
grid
optional. An $n \times 2$ matrix with coordinates of the simulated data.
nx
optional. Number of points in the X direction.
ny
optional. Number of points in the X direction.
xlims
optional. Limits of the area in the X direction. Defaults to $[0,1]$.
ylims
optional. Limits of the area in the Y direction. Defaults to $[0,1]$.
nsim
Number of simulations. Defaults to 1.
cov.model
correlation function. See cov.spatial for further details. Defaults to "exponential".
cov.pars
a vector with 2 elements or an $n \times 2$ matrix with values of the covariance parameters $\sigma^2$ (partial sill) and $\phi$ (range parameter). If a vector, the elements are the values of $\sigma^2$ and $\phi$, respectively. If a
kappa
additional smoothness parameter required only for the following correlation functions: "matern", "powered.exponential", "gneiting" and "gneiting.matern". More details on the documentation
nugget
the value of the nugget effect parameter $\tau^2$.
lambda
value of the Box-Cox transformation parameter. The value $\lambda = 1$ corresponds to no transformation, the default. For any other value of $\lambda$ Gaussian data is simulated and then transformed.
aniso.pars
geometric anisotropy parameters. By default an isotropic field is assumed and this argument is ignored. If a vector with 2 values is provided, with values for the anisotropy angle $\psi_A$ (in radians) and anisotropy ratio $\psi_A$, t
method
simulation method. Defaults to the Cholesky decomposition. See section DETAILS below.
messages.screen
logical, indicating whether or not status messages are printed on the screen (or output device) while the function is running. Defaults to TRUE.

Value

  • A list with the components:
  • coordsan $n \times 2$ matrix with the coordinates of the simulated data.
  • dataa vector (if nsim = 1) or a matrix with the simulated values. For the latter each column corresponds to one simulation.
  • cov.modela string with the name of the correlation.
  • nuggetthe value of the nugget parameter.
  • cov.parsa vector with the values of $\sigma^2$ and $\phi$, respectively.
  • kappavalue of the parameter $\kappa$.
  • lambdavalue of the Box-Cox transformation parameter $\lambda$.
  • aniso.parsa vector with values of the anisotropy parameters, if provided in the function call.
  • methoda string with the name of the simulation method used.
  • .Random.seedthe random seed at the time the function was called.
  • messagesmessages produced by the function describing the simulation.
  • callthe function call.

Details

For the methods "cholesky", "svd" and "eigen" the simulation consists of multiplying a vector of standardized normal deviates by a square root of the covariance matrix. The square root of a matrix is not uniquely defined. The three available methods differs in the way they compute the square root of the (positive definite) covariance matrix.

For method = "circular.embedding" the algorithm implements the method described by Wood & Chan (1994) which is based on Fourier transforms. Only regular and equally spaced grids can be generated using this method. The code for the "circular.embedding" method was provided by Martin Schlather, University of Bayreuth (http://btgyn8.geo.uni-bayreuth.de/~martin/). WARNING: The code for the "circular.embedding" method is no longer being maintained. Martin will soon release a package for unconditional simulation of random fields. This will be announced on the R(contributed packages) and geoR home page. When this new package is released the current implementation of the "circular.embedding" method might become obsolete.

References

Wood, A.T.A. and Chan, G. (1994) Simulation of stationary Gaussian process in $[0,1]^d$. Journal of Computatinal and Graphical Statistics, 3, 409--432. Schlather, M. (1999) Introduction to positive definite functions and to unconditional simulation of random fields. Tech. Report ST--99--10, Dept Maths and Stats, Lancaster University. Further information about geoR can be found at: http://www.maths.lancs.ac.uk/~ribeiro/geoR.html.

See Also

plot.grf and image.grf for graphical output, coords.aniso for anisotropy coordinates transformation and, chol, svd and eigen for methods of matrix decomposition.

Examples

Run this code
# initial value for the random numbers generator (if needed)
if(is.R()) .Random.seed <- 1:3
#
sim1 <- grf(100, cov.pars=c(1, .25))
# a display of simulated locations and values
points.geodata(sim1)   
# empirical and theoretical variograms
plot(sim1)
#
# a "smallish" simulation
sim2 <- grf(441, grid="reg", cov.pars=c(1, .25)) 
image.grf(sim2)
#
# a "bigger" one
sim3 <- grf(40401, grid="reg", cov.pars=c(10, .2), met="circ") 
image.grf(sim3)

Run the code above in your browser using DataLab