offGridWeights This function creates the interpolation weights taking advantage of some
efficiency in the covariance function being stationary, use
of a fixed configuration of nearest neighbors, and Kriging
predictions from a rectangular grid.
The returned matrix is in spam sparse matrix format. See
example below for the "one-liner" to make the prediction
once the weights are computed. Although created primarily
for (approximate) conditional simulation of a spatial process this
function is also useful for interpolating to off grid
locations from a rectangular field. It is also used for
fast, but approximate prediction for Kriging with a
stationary covariance.
The function offGridWeights is a simple wrapper to
call either the 1D or 2D functions
In most cases one would not use these approximations for a 1D problem.
However,
the 1D algorithm is included as a separate function for testing and also
because this is easier to read and understand the conversion between the
Kriging weights for each point and the sparse matrix encoding of them.
The interpolation errors are also computed based on the nearest neighbor
predictions. This is returned as a sparse matrix in the component SE.
If all observations are in different grid boxes then SE is
diagonal
and agrees with the square root of the component
predctionVariance but
if multiple observations are in the same grid box then SE has blocks of
upper
triangular matrices that can be used to simulate the prediction error
dependence among observations in the same grid box.
Explicitly if obj is the output object and there are nObs
observations then
error <- obj$SE%*% rnorm( nObs)
will simulate a prediction error that includes the dependence. Note that
in
the case that there all observations are in separate grid boxes this code line is the same as
error <- sqrt(obj$predictionVariance)*rnorm( nObs)
It is always true that the prediction variance is given by
diag( obj$SE%*% t( obj$SE)).
The user is also referred to the testing scripts
offGridWeights.test.R and
offGridWeights.testNEW.Rin tests where the
Kriging predictions and standard errors are computed explicitly and
tested against the sparse
matrix computation. This is helpful in defining exactly what
is being computed.
Returned value below pertains to the offGridWeights function.
approximateCovariance2d This is used to approximate a stationary covariance for fast prediction
The weights reuired are the same as those used for the local simulation and so this function is
included here. See predictSurface with the fast option for more details.
augmentPredictionGrid This is a supporting functions that adds
extra grid points to a gridList so that every irregular point has a
complete number of nearest neighbors.Typically the initial grid has as
its limits the ranges of the observations.
This functions adds more grid points at the edges so the there are NNSize
neighbors around every data location.
findGridBoxThis is a handy function that finds the indices of
the lower left grid box that contains the points in s. If the
point is not contained within the range of the grid and NA is returned
fo the index.
This function assumes that the grid points are equally spaced.