RFfit {RandomFields}R Documentation

Fitting model parameters to spatial data (regionalised variables) and to linear (mixed) models

Description

The function estimates arbitrary parameters of a random field specification with various methods. Currenty, the model to be fitted can be

The fitting of max-stable random fields and others has not been implemented yet.

Usage

RFfit(model, x, y = NULL, z = NULL, T = NULL, grid=NULL, data,
 lower = NULL, upper = NULL, bc_lambda, methods,
 sub.methods, optim.control = NULL, users.guess = NULL,
 distances = NULL, dim, transform = NULL, ...)

Arguments

model

covariance model, see RMmodel or type RFgetModelNames(type="variogram") to get all options.

All parameters that are set to NA will be estimated; see the examples below.

x

vector of x coordinates, or object of class GridTopology or raster; For more options see RFsimulateAdvanced.

y

vector of y coordinates

z

vector of z coordinates

T

vector of T coordinates; these coordinates are given in triple notation, see RFsimulate.

data

vector or matrix of values measured at coord; If a matrix is given then the columns are interpreted as independent realisations.
If also a time component is given, then in the data the indices for the spatial components run the fastest.

If an m-variate model is used, then each realisation is given as m consecutive columns of data.

lower

list or vector. Lower bounds for the parameters. If param is a vector, lower has to be a vector as well and its length must equal the number of parameters to be estimated. The order of param has to be maintained. A component being NA means that no manual lower bound for the corresponding parameter is set.

If param is a list, lower has to be of (exactly) the same structure.

upper

list or vector. Upper bounds for the parameters. See also lower.

grid

boolean. Whether coordinates build a grid. In nearly all cases the value of grid is self-detected, so that grid need not be given, in general

bc_lambda

a vector of at most two numerical components (just one component corresponds to two identical ones) which are the parameters of the box-cox-transformation: (x^λ_1-1)/λ_1+λ_2 If the model is univariate, the first parameter can be estimated by using NA.

methods

Main methods to be used for estimating. If several methods, estimation will be performed with each method and the results reported.

sub.methods

variants of the least squares fit of the variogram. See Details. variants of the maximum likelihood fit of the covariance function. See Details.

users.guess

User's guess of the parameters. All the parameters must be given using the same rules as for either param (except that no NA's should be contained) or model.

distances,dim

Instead of x-coordinates, distances might be given. The the dimension of the space dim must be given explicitely.

optim.control

control list for optim, which uses ‘L-BFGS-B’. However parscale may not be given.

transform

this is an attempt to allow binding between parameters, e.g. one parameter value is supposed to equal another one, See examples below.

transform=list() is not valid for estimating, but returns structural information to set up the correct function. See examples below.

...

further options and control arguments for the simulation that are passed to and processed by RFoptions.

Details

For details on the simulation methods see

If x-coordinates are not given, the function will check data for NAs and will perform imputing.

The function has many more options to tune the optimizer, see RFoptions for details.

If the model defines a Gaussian random field, the options for methods and submethods are currently "ml" and c("self", "plain", "sqrt.nr", "sd.inv", "internal"), respectively.

Value

The result depends on the logical value of spConform. If TRUE, an S4 object is greated. In case the model indicates a Gaussian random field, an RFfit object is created.

If spConform=FALSE, a list is returned. In case the model indicates a Gaussian random field, the details are given in fitgauss.

Note

This function does not depend on the value of RFoptions()$PracticalRange. The function RFfit always uses the standard specification of the covariance model as given in RMmodel.

Author(s)

Martin Schlather, schlather@math.uni-mannheim.de http://ms.math.uni-mannheim.de/de/publications/software

References

See Also

RFratiotest RMmodel, RandomFields, weather.

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")


n <- if (interactive()) 100 else 3

#########################################################
## simulate some data first                            ## 
points <- if (interactive()) 100 else 40
x <- runif(points, 0, 3)
y <- runif(points, 0, 3) ## random points in square [0, 3]^2
model <- RMgencauchy(alpha=1, beta=2)
d <- RFsimulate(model, x=x, y=y, grid=FALSE, n=n) #1000


#########################################################
## estimation; 'NA' means: "to be estimated"           ##
estmodel <- RMgencauchy(var=NA, scale=NA, alpha=NA, beta=2) +
            RMtrend(mean=NA)
RFfit(estmodel, data=d)








[Package RandomFields version 3.0.62 Index]