# RFsimulate

0th

Percentile

##### Simulation of Random Fields

This function simulates unconditional random fields:

It also simulates conditional random fields for

• univariate and multivariat, spatial and spatio-temporal Gaussian random fields
Here, only the simulation of Gaussian random fields is described. For other kind of random fields (binary, max-stable, etc.) or more sophisticated approches see RFsimulateAdvanced.

Keywords
spatial
##### Usage
RFsimulate(model, x, y=NULL, z=NULL, T=NULL, grid,
data, distances, dim, err.model, n=1, ...)
##### Arguments
model
object of class RMmodel, RFformula or formula; specifies the model to be
x
vector of x coordinates, or object of class GridTopology; For more options see RFsimulateAdvanced.
y
optional vector of y coordinates
z
optional vector of z coordinates
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; RandomFields can find itself the correct value in nearly all cases. See also 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; coordinates and res
distances
another alternative to pass the (relative) coordinates, see RFsimulateAdvanced.
dim
Only used if distances are given.
err.model
For conditional simulation and random imputing only. Usually err.model=RMnugget(var=var), or not given at all (error-free measurements).
n
number of realizations to generate. For a very advanced feature, see the notes in RFsimulateAdvanced.
...
for advanced use: further options and control parameters for the simulation that are passed to and processed by RFoptions
##### 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 is performed:

• if of classRFsp,ncol(data@coords)must equal the dimension of the index space. Ifdata@datacontains only a single variable, variable names are optional. Ifdata@datacontains more than one variable, variables must be named andmodelmust be given in the tilde notationresp ~ ...(seeRFformula) and"resp"must be contained innames(data@data).
• % Beschreibung hier stimmt nicht so ganz mit Examples unten ueberein Ifdatais a matrix or a data.frame, eitherncol(data)equals$(dimension of index space + 1)$and the order of the columns is (x, y, z, T, response) or, ifdatacontains more than one response variable (i.e.ncol(data) > (dimension of index space + 1)),colnames(data)must containcolnames(x)or those of"x", "y", "z", "T"that are not missing. The response variable name is matched withmodel, which must be given in the tilde notation. If"x", "y", "z", "T"are missing anddatacontainsNAs,colnames(data)must contain an element which starts withdata; the corresponding column and those behind it are interpreted as the given data and those before the corresponding column are interpreted as the coordinates.
• ifxis missing,RFsimulatesearches forNAs in the data and performs a conditional simulation for them.

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. If n > 1 the repetitions make the last dimension.

##### References

Gneiting, T. and Schlather, M. (2013) Statistical modeling with covariance functions. In preparation.

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.

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

• RFsimulate
##### Examples
set.seed(0)#############################################################
## ##
## ONLY TWO VERY BASIC EXAMPLES ARE GIVEN HERE ##
## see ##
## ?RMsimulate.more.examples ##
## and ##
## 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
len <- if (interactive()) 200 else 2
x.seq <- seq(from, to, length=len)
y.seq <- seq(from, to, length=len)

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

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

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

# let simulate a field conditional on the above data
x.seq.cond <- y.seq.cond <- seq(-1.5, 1.5, length=n)
model <- RMexp()
cond <- RFsimulate(model = model, x=x.seq.cond, y=y.seq.cond,
grid=TRUE, data=data)
plot(cond, data)
Documentation reproduced from package RandomFields, version 3.0.5, License: GPL (>= 3)

### Community examples

Looks like there are no examples yet.