RFsimulate: Simulation of Random Fields

Description Usage Arguments Details Value Note References See Also Examples

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

1
2
3
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 \argModel
x \argX
y,z \argYz
T \argT
grid \argGrid
distances,dim \argDistances
data

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

\argData \argDataGiven

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

given \argGiven
err.model,err.params

For conditional simulation and random imputing only.
\argErrmodel.

n

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

... \argDots

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.

References

\litLantue \litIntro

See RFsimulateAdvanced for more specific literature.

See Also

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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)

Example output

Loading required package: sp
Loading required package: RandomFieldsUtils

Attaching package: 'RandomFields'

The following object is masked from 'package:RandomFieldsUtils':

    RFoptions

$`tail correlation`
$`tail correlation`$`single variable`
 [1] "RMaskey"      "RMbcw"        "RMcircular"   "RMcubic"      "RMdagum"     
 [6] "RMexp"        "RMgencauchy"  "RMnatsc"      "RMpower"      "RMpoweredexp"
[11] "RMspheric"    "RMstable"    


$`positive definite`
$`positive definite`$`single variable`
 [1] "RMaskey"        "RMbcw"          "RMbessel"       "RMbicauchy"    
 [5] "RMbigneiting"   "RMbistable"     "RMbiwm"         "RMcardinalsine"
 [9] "RMcauchy"       "RMcauchytbm"    "RMconstant"     "RMcutoff"      
[13] "RMdagum"        "RMdampedcos"    "RMepscauchy"    "RMexp"         
[17] "RMfractdiff"    "RMfractgauss"   "RMgauss"        "RMgencauchy"   
[21] "RMgengneiting"  "RMgneiting"     "RMgneitingdiff" "RMhyperbolic"  
[25] "RMintrinsic"    "RMlgd"          "RMlsfbm"        "RMnatsc"       
[29] "RMparswm"       "RMparswmX"      "RMpenta"        "RMpower"       
[33] "RMpoweredexp"   "RMqam"          "RMqexp"         "RMspheric"     
[37] "RMstable"       "RMwave"         "RMwendland"    


NOTE: simulation is performed with fixed random seed 0.
Set 'RFoptions(seed=NA)' to make the seed arbitrary.
New output format of RFsimulate: S4 object of class 'RFsp';
for a bare, but faster array format use 'RFoptions(spConform=FALSE)'.
NOTE: simulation is performed with fixed random seed 0.

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