RFsimulate {RandomFields}R Documentation

Simulation of Random Fields

Description

This function simulates unconditional random fields:

It also simulates conditional random fields for

Here, only the simulation of Gaussian random fields is described. For other kinds of random fields (binary, max-stable, etc.) or more sophisticated approaches see RFsimulateAdvanced.

Usage

RFsimulate(model, x, y=NULL, z=NULL, T=NULL, grid=NULL,
           distances, dim, data, given=NULL, err.model, params,
           err.params, n=1, ...)

Arguments

model,params

object of class RMmodel, RFformula or formula; best is to consider the examples below, first.
The argument params is a list that specifies free parameters in a formula description, see RMformula.

x

vector of x coordinates, or object of class GridTopology or raster; for more options see RFsimulateAdvanced.

y,z

optional vectors of y (z) coordinates, which should not be given if x is a matrix.

T

optional vector of time coordinates, T must always be an equidistant vector. Instead of T=seq(from=From, by=By, len=Len), one may also write T=c(From, By, Len).

grid

logical; the function finds itself the correct value in nearly all cases, so that usually grid need not be given. See also RFsimulateAdvanced.

distances,dim

another alternative for the argument x to pass the (relative) coordinates, see RFsimulateAdvanced.

data

For conditional simulation and random imputing only. If data is missing, unconditional simulation is performed.

matrix, data.frame or object of class RFsp;
If a matrix is given the ordering of the colums is the following: space, time, multivariate, repetitions, i.e. the index for the space runs the fastest and that for repetitions the slowest. If given is not given and data is a matrix or data is a data.frame, RandomFields tries to identify where the data and the coordinates are, e.g. by names in formulae or by fixed names, see Coordinate systems. See also RFsimulateAdvanced. If all fails, the first columns are interpreted as coordinate vectors, and the last column(s) as (multiple) measurement(s) of the field. Notes that also lists of data can be passed.

If the argument x is missing, data may contain NAs, which are then replaced by conditionally simulated values (random imputing);

given

optional, matrix or list. If given matrix then the coordinates can be given separately, namely by given where, in each row, a single location is given.
If given is a list, it may consist of x, y, z, T, grid.
If given is provided, data must be a matrix or an array containing the data only.

err.model,err.params

For conditional simulation and random imputing only.
In case of (assumed) error-free measurements (which is mostly the case in geostatistics) the argument err.model is not given. In case of measurement errors we have err.model=RMnugget(var=var).
err.param plays the same role as params for model..

n

number of realizations to generate. For a very advanced feature, see the notes in RFsimulateAdvanced.

...

for advanced use: further options and control arguments for the simulation that are passed to and processed by RFoptions. If params is given, then ... may include also the variables used in params.

Details

By default, all Gaussian random fields have zero mean. Simulating with trend can be done by including RMtrend in the model, see the examples below.

If data is passed, conditional simulation based on simple kriging 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 RMmodel.

In case of a multivariate

If n > 1 the repetitions make the last dimension.

See RFsimulateAdvanced for additional options.

Note

Several advanced options can be found in sections ‘General options’ and ‘coords’ of RFoptions. In particular, option spConform=FALSE leads to a simpler (and faster!) output, see RFoptions for details.

Author(s)

Martin Schlather, schlather@math.uni-mannheim.de, http://ms.math.uni-mannheim.de

References

Lantuejoul, Ch. (2002) Geostatistical simulation. New York: Springer.

Schlather, M. (1999) An introduction to positive definite functions and to unconditional simulation of random fields. Technical report ST 99-10, Dept. of Maths and Statistics, Lancaster University.

See RFsimulateAdvanced for more specific literature.

See Also

RFvariogram, RFfit, RFgetModelInfo, RFgui, RMmodel, RFoptions, RFsimulateAdvanced, RFsimulate.more.examples

Examples

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

#############################################################
## ##
## ONLY TWO VERY BASIC EXAMPLES ARE GIVEN HERE ##
## see ##
## ?RMsimulate.more.examples ##
## and ##
## ?RFsimulateAdvanced ##
## for more examples ##
## ##
#############################################################

#############################################################
## ##
## Unconditional simulation ## 
## ##
#############################################################

## first let us look at the list of implemented models
RFgetModelNames(type="positive definite", domain="single variable",
                iso="isotropic") 

## our choice is the exponential model;
## the model includes nugget effect and the mean:
model <- RMexp(var=5, scale=10) + # with variance 4 and scale 10
 RMnugget(var=1) + # nugget
 RMtrend(mean=0.5) # and mean
 
## define the locations:
from <- 0
to <- 20
x.seq <- seq(from, to, length=200) 
y.seq <- seq(from, to, length=200)

simu <- RFsimulate(model, x=x.seq, y=y.seq)
plot(simu)



#############################################################
## ##
## Conditional simulation ## 
## ##
#############################################################

# first we simulate some random values at 
# 100 random locations:
n <- 100
x <- runif(n=n, min=-1, max=1)
y <- runif(n=n, min=-1, max=1)
dta <- RFsimulate(model = RMexp(), x=x, y=y, grid=FALSE)
plot(dta)

# let simulate a field conditional on the above data
L <- if (interactive()) 100 else 5
x.seq.cond <- y.seq.cond <- seq(-1.5, 1.5, length=L)
model <- RMexp()
cond <- RFsimulate(model, x=x.seq.cond, y=y.seq.cond, data=dta)
plot(cond, dta)

[Package RandomFields version 3.3.6 Index]