RFformula: RFformula - syntax to design random field models with trend...

Description Details IMPORTANT Note References See Also Examples

View source: R/getNset.R

Description

It is described how to create a formula, which, for example, can be used as an argument of RFsimulate and RFfit to simulate and to fit data according to the model described by the formula.

In general, the created formula serves two purposes:

Thereby, fixed effects and trend surfaces can be adressed via the expression RMfixed and the function RMtrend. In simple cases, the trend can also be given in a very simple, see the examples below. The covariance structures of the zero-mean multivariate normally distributed random field components are adressed by objects of class RMmodel, which allow for a very flexible covariance specification.

See RFformulaAdvanced for rather complicated model definitions.

Details

The formula should be of the type

response ~ fixed effects %+ random effects + error term

or

response ~ trend + zero-mean random field + nugget effect,

respectively.

Thereby:

IMPORTANT

Note that in formula constants are interpreted as part of a linear model, i.e. the corresponding parameter has to be estimated (e.g. ~ 1 + ...) whereas in models not given as formula the parameters to be estimated must be given explicitly.

Note

(additional) argument names should always start with a capital letter. Small initial letters are reserved for RFoptions.

References

See Also

RMmodel, RFsimulate, RFfit, RandomFields.

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
RFoptions(seed=0) ## *ANY* simulation will have the random seed 0; set
##                   RFoptions(seed=NA) to make them all random again

RFoptions(modus_operandi="sloppy")

##############################################################
#
# Example  : Simulation and fitting of a two-dimensional
# Gaussian random field with exponential covariance function
#
###############################################################

V <- 10
S <- 0.3
M <- 3
model <- RMexp(var=V, scale=S) + M
x <- y <- seq(1, 3, 0.1)

simulated <- RFsimulate(model = model, x=x, y=y)
plot(simulated)


# an alternative code to the above code:
model <- ~ Mean + RMexp(var=Var, scale=Sc)
simulated2 <- RFsimulate(model = model,x=x, y=y, Var=V, Sc=S, Mean=M)
plot(simulated2)


# a third way of specifying the model using the argument 'param'
# the initials of the variables do not be captical letters
model <- ~ M + RMexp(var=var, scale=sc)
simulated3 <- RFsimulate(model = model,x=x, y=y,
                         param=list(var=V, sc=S, M=M))
plot(simulated3)


# Estimate parameters of underlying covariance function via
# maximum likelihood
model.na <- ~ NA + RMexp(var=NA, scale=NA)
fitted <- RFfit(model=model.na, data=simulated)

# compare sample mean of data with ML estimate, which is very similar:
mean(simulated@data[,1]) 
fitted

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