Learn R Programming

RandomFields (version 3.0.35)

RFinterpolate: Interpolation methods

Description

The function allows for different methods of interpolation. Currently only various kinds of kriging are installed.

Usage

RFinterpolate(model, x, y = NULL, z = NULL, T = NULL, grid, data,
              distances, dim, err.model, method = "ml", ...)

Arguments

model
string; covariance model, see RMmodel, or type RFgetModelNames() to get all options.
x
$(n \times d)$ matrix or vector of x coordinates, or object of class GridTopology or raster; coordinates of $n$ points t
y
optional vector of y coordinates
z
optional vector of z coordinates
T
optional vector of time coordinates, T must always be an equidistant vector. Instead of T=seq(from=From, by=By, len=Len) one may also write T=c(From, By, Len).
grid
logical; determines whether the vectors x, y, and z should be interpreted as a grid definition; RandomFields can find itself the correct value in nearly all cases. See also
data
Matrix, data.frame or object of class RFsp; coordinates and response values of measurements; If a matrix or a data.frame, the first columns are interpreted as coordinate vectors, and the la
distances
another alternative to pass the (relative) coordinates, see RFsimulateAdvanced.
dim
Only used if distances are given.
err.model
For conditional simulation and random imputing only. Usually err.model=RMnugget(var=var), or not given at all (error-free measurements).
method
character. A single method out of methods or sub.methods, see RFfit.
...
Two intrinsic arguements can be given: [object Object],[object Object] For further optional arguments, see RFoptions.

Value

  • The value depends on the additional argument variance.return, see RFoptions. If variance.return=FALSE (default), Kriging returns a vector or matrix of kriged values corresponding to the specification of x, y, z, and grid, and data. data: a vector or matrix with one column * grid=FALSE. A vector of simulated values is returned (independent of the dimension of the random field) * grid=TRUE. An array of the dimension of the random field is returned (according to the specification of x, y, and z). data: a matrix with at least two columns * grid=FALSE. A matrix with the ncol(data) columns is returned. * grid=TRUE. An array of dimension $d+1$, where $d$ is the dimension of the random field, is returned (according to the specification of x, y, and z). The last dimension contains the realisations.

    If variance.return=TRUE, a list of two elements, estim and var, i.e. the kriged field and the kriging variances, is returned. The format of estim is the same as described above. The format of var is accordingly.

Details

In case of intrinsic cokriging (intrinsic kriging for a multivariate random fields) the pseudo-cross-variogram is used (cf. Ver Hoef and Cressie, 1991).

References

Chiles, J.-P. and Delfiner, P. (1999) Geostatistics. Modeling Spatial Uncertainty. New York: Wiley.

Cressie, N.A.C. (1993) Statistics for Spatial Data. New York: Wiley. Goovaerts, P. (1997) Geostatistics for Natural Resources Evaluation. New York: Oxford University Press. Ver Hoef, J.M. and Cressie, N.A.C. (1993) Multivariate Spatial Prediction. Mathematical Geology 25(2), 219-240. Wackernagel, H. (1998) Multivariate Geostatistics. Berlin: Springer, 2nd edition.

See Also

RMmodel, RFempiricalvariogram, RandomFields,

Examples

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

## Preparation of graphics
if (interactive()) dev.new(height=7, width=16)
RFoptions(always_close_screen=FALSE)

## creating random variables first
## here, a grid is chosen, but does not matter
p <- 3:8
points <- as.matrix(expand.grid(p,p))
model <- RMexp() + RMtrend(mean=1)
data <- RFsimulate(model, x=points)
plot(data)
x <- seq(0, 9, 0.25)

## Simple kriging with the exponential covariance model
model <- RMexp()
z <- RFinterpolate(model, x=x, y=x, data=data)
plot(z, data)

## Simple kriging with mean=4 and scaled covariance
model <- RMexp(scale=2) + RMtrend(mean=4)
z <- RFinterpolate(model, x=x, y=x, data=data)
plot(z, data)


## Ordinary kriging
model <- RMexp() + RMtrend(mean=NA)
z <- RFinterpolate(model, x=x, y=x, data=data)
plot(z, data)


\dontrun{

## alternatively 

## Intrinsic kriging
model <- RMfbm(a=1)
z <- RFinterpolate(krige.meth="U", model, x, x, data=data)
screen(scr <- scr+1); plot(z, data)


## Interpolation nicht korrekt
## Intrinsic kriging with Polynomial Trend
model <- RMfbm(a=1) + RMtrend(polydeg=2)
z <- RFinterpolate(model, x, x, data=data)
screen(scr <- scr+1); plot(z, data)
}

\dontrun{
## Universal kriging with trend as formula
model <- RMexp() + RMtrend(arbit=function(X1,X2) sin(X1+X2)) +
 RMtrend(mean=1)
z <- RFinterpolate(model, x=x, y=x, data=data)
screen(scr <- scr+1); plot(z, data)

## Universal kriging with several arbitrary functions
model <- RMexp() + RMtrend(arbit=function(x,y) x^2 + y^2) +
 RMtrend(arbit=function(x,y) (x^2 + y^2)^0.5) + RMtrend(mean=1)
z <- RFinterpolate(model, x=x, y=x, data=data)
screen(scr <- scr+1); plot(z, data)
}close.screen(all = TRUE)

RFoptions(always_close_screen=TRUE);
          close.screen(all.screens=TRUE);
          while (length(dev.list()) >= 2) dev.off()
FinalizeExample()

Run the code above in your browser using DataLab