Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

RFformula

RFformula - syntax to design random field models with trend or linear mixed models


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:

  • to describe models in the “Linear Mixed Models”-framework

  • to define models for random fields including trend surfaces from a geostatistical point of view.

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:

  • response
    optional; name of response variable

  • fixed effects/trend:
    optional, should be a sum (using +) of components either of the form X@RMfixed(beta) or RMtrend(...) with X being a design matrix and β being a vector of coefficients (see RMfixed and RMtrend).
    Note that a fixed effect of the form X is interpreted as X@RMfixed(beta=NA) by default (and β is estimated provided that the formula is used in RFfit).

  • error term/nugget effect
    optional, should be of the form RMnugget(...). RMnugget describes a vector of iid Gaussian random variables.

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.

Author(s)

References

  • Chiles, J.-P. and P. Delfiner (1999) Geostatistics. Modeling Spatial Uncertainty. New York, Chichester: John Wiley & Sons.

  • McCulloch, C. E., Searle, S. R. and Neuhaus, J. M. (2008) Generalized, linear, and mixed models. Hoboken, NJ: John Wiley & Sons.

  • Ruppert, D. and Wand, M. P. and Carroll, R. J. (2003) Semiparametric regression. Cambridge: Cambridge University Press.

See Also

Examples

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

Simulation and Analysis of Random Fields

v3.3.10
GPL (>= 3)
Authors
Martin Schlather [aut, cre], Alexander Malinowski [aut], Marco Oesting [aut], Daphne Boecker [aut], Kirstin Strokorb [aut], Sebastian Engelke [aut], Johannes Martini [aut], Felix Ballani [aut], Olga Moreva [aut], Jonas Auel[ctr], Peter Menck [ctr], Sebastian Gross [ctr], Ulrike Ober [ctb], Paulo Ribeiro [ctb], Brian D. Ripley [ctb], Richard Singleton [ctb], Ben Pfaff [ctb], R Core Team [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.