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.R
in 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.
addMarginsGridList This is a supporting function that adds
extra grid points for a gridList so that every irregular point has a
complete number of nearest neighbors.
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.