RFsimulateAdvanced: Simulation of Random Fields - Advanced

Description Arguments Details Value Note References See Also Examples

Description

This function simulates unconditional random fields:

It also simulates conditional random fields for

For basic simulation of Gaussian random fields, see RFsimulate. See RFsimulate.more.examples and RFsimulate.sophisticated.examples for further examples.

Arguments

model

object of class RMmodel, RFformula or formula; specifies the model to be simulated

  • if of class RMmodel, model specifies

    • the type of random field by using RPfunctions, e.g.,

      • RPgauss: Gaussian random field (default if none of the functions in the list is given)

      • RPsmith: Smith model See RP for an overview.

    • the covariance or variogram model in case of a Gaussian random field (RPgauss) and for fields based on Gaussian fields (e.g. RPbernoulli); type RFgetModelNames(type="variogram") for a list of available models; see also RMmodel.

    • the shape function in case of a shot noise process; type RFgetModelNames(type='shape') for a list of available models.

  • if of class RFformula or formula, submodel specifies a linear mixed model where random effects can be modelled by Gaussian random fields; see RFformula for details on model specification.

x

matrix of coordinates, or vector of x coordinates, or object of class GridTopology or raster; if matrix, ncol(x) is the dimension of the index space; matrix notation is required in case of more than 3 space dimensions; in this case, if grid=FALSE, x_ij is the i-th coordinate in the j-th dimension; otherwise, if grid=TRUE, the columns of x are interpreted as gridtriples (see grid); if of class GridTopology, x is interpreted as grid definition and grid is automatically set to TRUE.

y

optional vector of y coordinates, ignored if x is a matrix

z

optional vector of z coordinates, ignored if x is a matrix

T

optional vector of time coordinates, T must always be an equidistant vector or given in a gridtriple format (see argument grid); for each component of T, the random field is simulated at all location points.

grid

logical; determines whether the vectors x, y, and z or the columns of x should be interpreted as a grid definition (see Details). If grid=TRUE, either x, y, and z must be equidistant vectors in ascending order or the columns of x must be given in the gridtriple format: c(from, stepsize, len).

Note: If grid is not given, RFsimulate tries to guess what is meant.

c(from, stepsize, len) (see Details)

data

matrix, data.frame or object of class RFsp; coordinates and response values of measurements in case that conditional simulation is to be performed; if a matrix or a data.frame, the first columns are interpreted as coordinate vectors, and the last column(s) as (multiple) measurement(s) of the field; if x is missing, data may contain NAs, which are then replaced by conditionally simulated values; if data is missing, unconditional simulation is performed; for details on matching of variable names see Details; if of class RFsp

err.model

same as model; gives the model of the measurement errors for the measured data (which must be given in this case!), see Details. err.model=NULL (default) corresponds to error-free measurements, the most common alternative is err.model=RMnugget(); ignored if data is missing.

distances

object of class dist representing the upper triangular part of the matrix of Euclidean distances between the points at which the field is to be simulated; only applicable for stationary and isotropic models; if not NULL, dim must be given and x, y, z and T must be missing or NULL.

If distances are given, the current value of spConform, see RFoptions, is ignored and instead spConform=FALSE is used. (This fact may change in future.)

dim

integer; space or space-time dimension of the field

n

number of realizations to generate

...

further options and control arguments for the simulation that are passed to and processed by RFoptions

Details

RFsimulate simulates different classes of random fields, controlled by the wrapping model.

If the wrapping function of the model argument is a covariance or variogram model, i.e., one of the list obtained by RFgetModelNames(type="variogram", group.by="type"), by default, a Gaussian field with the corresponding covariance structure is simulated. By default, the simulation method is chosen automatically through internal algorithms. The simulation method can be set explicitly by enclosing the covariance function with a method specification.

If other than Gaussian fields are to be simulated, the model argument must be enclosed by a function specifying the type of the random field.

There are different possibilities of passing the locations at which the field is to be simulated. If grid=FALSE, all coordinate vectors (except for the time component T) must have the same length and the field is only simulated at the locations given by the rows of x or of cbind(x, y, z). If T is not missing, the field is simulated for all combinations (x[i, ], T[k]) or (x[i], y[i], z[i], T[k]), i=1, ..., nrow(x), k=1, ..., length(T), even if model is not explicitly a space-time model.
If grid=TRUE, the vectors x, y, z and T or the columns of x and T are interpreted as a grid definition, i.e. the field is simulated at all locations (x_i, y_j, z_k, T_l), as given by expand.grid(x, y, z, T). Here, “grid” means “equidistant in each direction”, i.e. all vectors must be equidistant and in ascending order. In case of more than 3 space dimensions, the coordinates must be given in matrix notation. To enable different grid lengths for each direction in combination with the matrix notation, the “gridtriple” notation c(from, stepsize, len) is used: If x, y, z, T or the columns of x are of length 3, they are internally replaced by seq(from=from, to=from+(len-1)*stepsize, by=stepsize) , i.e. the field is simulated at all locations
expand.grid(seq(x$from, length.out=x$len, by=x$stepsize), seq(y$from, length.out=y$len, by=y$stepsize), seq(z$from, length.out=z$len, by=z$stepsize), seq(T$from, length.out=T$len, by=T$stepsize))

If data is passed, conditional simulation is performed.

Specification of err.model: In geostatistics we have two different interpretations of a nugget effect: small scale variability and measurement error. The result of conditional simulation usually does not include the measurement error. Hence the measurement error err.model must be given separately. For sake of generality, any model (and not only the nugget effect) is allowed. Consequently, err.model is ignored when unconditional simulation is performed.

Value

By default, an object of the virtual class RFsp; result is of class RFspatialGridDataFrame if [space-time-dimension > 1] and the coordinates are on a grid, result is of class RFgridDataFrame if [space-time-dimension = 1] and the coordinates are on a grid, result is of class RFspatialPointsDataFrame if [space-time-dimension > 1] and the coordinates are not on a grid, result is of class RFpointsDataFrame if [space-time-dimension = 1] and the coordinates are not on a grid.

The output format can be switched to the "old" array format using RFoptions, either by globally setting RFoptions(spConform=FALSE) or by passing spConform=FALSE in the call of RFsimulate. Then the object returned by RFsimulate depends on the arguments n and grid in the following way:

If vdim > 1 the vdim-variate vector makes the first dimension.

If grid=TRUE an array of the dimension of the random field makes the next dimensions. Here, the dimensions are ordered in the sequence x, y, z, T (if given).

Else if no time component is given, then the values are passed as a single vector. Else if the time component is given the next 2 dimensions give the space and the time, respectively.

If n > 1 the repetitions make the last dimension.

Note: Conversion between the sp format and the conventional format can be done using the method RFspDataFrame2conventional and the function conventional2RFspDataFrame.

InitRFsimulate returns 0 if no error has occurred and a positive value if failed.

Note

Advanced options are

See RFoptions for further options.

References

General

Original work:

See Also

RFoptions, RMmodel, RFgui, methods for simulating Gaussian random fields, RFfit, RFvariogram, RFsimulate.more.examples, RFsimulate.sophisticated.examples, RPgauss.

Examples

1
2
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set
##                   RFoptions(seed=NA) to make them all random again

RandomFields documentation built on Jan. 19, 2022, 1:06 a.m.