RandomFields: Simulation and Analysis of Random Fields

Description Details Changings Update Contributions Thanks Financial support Note References See Also Examples


The package RandomFields offers various tools for

  1. model estimation (ML) and inference (tests) for regionalized variables and data analysis,

  2. simulation of different kinds of random fields, including

    • multivariate, spatial, spatio-temporal, and non-stationary Gaussian random fields,

    • Poisson fields, binary fields, Chi2 fields, t fields and

    • max-stable fields.

    It can also deal with non-stationarity and anisotropy of these processes and conditional simulation (for Gaussian random fields, currently).

See \mysoftware for intermediate updates.


The following features are provided by the package:

  1. Bayesian Modelling

    • See Bayesian Modelling for an introduction to hierarchical modelling.

  2. Coordinate systems

    • Cartesian, earth and spherical coordinates are recognized, see coordinate systems for details.

    • A list of valid models is given by spherical models.

  3. Data and example studies: Some data sets and published code are provided to illustrate the syntax and structure of the package functions.

    • soil : soil physical data

    • weather : UWME weather data

    • papers : code used in the papers published by the author(s)

  4. Estimation of parameters (for second-order random fields)

    • RFfit : general function for estimating parameters; (for Gaussian random fields)

    • RFhurst : estimation of the Hurst parameter

    • RFfractaldim : estimation of the fractal dimension

    • RFvariogram : calculates the empirical variogram

    • RFcov : calculates the empirical (auto-)covariance function

  5. Graphics

    • Fitting a covariance function manually RFgui

    • the generic function plot

    • global graphical parameters with RFpar

  6. Inference (for Gaussian random fields)

    • RFcrossvalidate : cross validation

    • RFlikelihood : likelihood

    • RFratiotest : likelihood ratio test

    • AIC, AICc, BIC, anova, logLik

  7. Models

    • For an introduction and general properties, see RMmodels.

    • For an overview over classes of covariance and variogram models –e.g. for geostatistical purposes– see RM. More sophisticated models and covariance function operators are included.

    • RFformula reports a new style of passing a model since version 3.3.

    • definite models are evaluated by RFcov, RFvariogram and RFcovmatrix. For a quick impression use plot(model).

    • non-definite models are evaluated by RFfctn and RFcalc

    • RFlinearpart returns the linear part of a model

    • RFboxcox deals explicitly with Box-Cox transformations. In many cases it is performed implicitly.

  8. Prediction (for second-order random fields)

    • RFinterpolate : kriging, including imputing

  9. Simulation

    • RFsimulate: Simulation of random fields, including conditional simulation. For a list of all covariance functions and variogram models see RM. Use plot for visualisation of the result.

  10. S3 and S4 objects

    • The functions return S4 objects based on the package sp, if spConform=TRUE. This is the default.

      If spConform=FALSE, simple objects as in version 2 are returned. These simple objects are frequently provided with an S3 class. This option makes the returning procedure much faster, but currently does not allow for the comfortable use of plot.

    • plot, print, summary, sometimes also str recognise these S3 and S4 objects

    • use sp2RF for an explicit transformation of sp objects to S4 objects of RandomFields.

    • Further generic functions are available for fitted models, see ‘Inference’ above.

  11. Xtended features, especially for package programmers

    • might decide on a large variety of arguments of the simulation and estimation procedures using the function RFoptions

    • may use ‘./configure –with-tcl-config=/usr/lib/tcl8.5/tclConfig.sh –with-tk-config=/usr/lib/tk8.5/tkConfig.sh’ to configure R


A list of major changings from Version 2 to Version 3 can be found in MajorRevisions.

Changings lists some further changings, in particular of argument and argument names.

RandomFields should be rather stable when running it with parallel. However RandomFields might crash severely if an error occurs when running in parallel. When used with parallel, you might set RFoptions(cores = 1). Note that RFoptions(cores = ...) with more than 1 core uses another level of parallelism which will be in competetions with parallel during runtime.


Current updates are available through \mysoftware.



Patrick Brown : comments on Version 3
Paulo Ribeiro : comments on Version 1
Martin Maechler : advice for Version 1

Financial support


The following packages enable further choices for the optimizer (instead of optim) in RandomFields: optimx, soma, GenSA, minqa, pso, DEoptim, nloptr, RColorBrewer, colorspace


See Also

See also RF, RM, RP, RR, RC, R.


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

# simulate some data first (Gaussian random field with exponential
# covariance; 6 realisations)
model <- RMexp()
x <- seq(0, 10, 0.1)
z <- RFsimulate(model, x, x, n=6)

## select some data from the simulated data
xy <- coordinates(z)
pts <- sample(nrow(xy), min(100, nrow(xy) / 2))
dta <- matrix(nrow=nrow(xy), as.vector(z))[pts, ]
dta <- cbind(xy[pts, ], dta)
plot(z, dta)

## re-estimate the parameter (true values are 1)
estmodel <- RMexp(var=NA, scale=NA)
(fit <- RFfit(estmodel, data=dta))

## show a kriged field based on the estimated parameters
kriged <- RFinterpolate(fit, x, x, data=dta)
plot(kriged, dta)

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