Learn R Programming

SpatialTools (version 1.0.5)

krige.ok: Performs Ordinary Kriging

Description

Performs Ordinary Kriging using y, the \(n \times 1\) matrix of observed responses, V, the (positive definite) covariance matrix of the observed responses, Vp, the \(np \times np\) covariance matrix of the responses to be predicted, and Vop, the \(n \times np\) matrix of covariances between the observed responses and the responses to be predicted.

Usage

krige.ok(y, V, Vp, Vop, nsim = 0, Ve.diag = NULL, method = "eigen")

Value

The function returns a list containing the following objects:

pred

A vector of length \(np\) containing the predicted responses.

mspe

A vector of length \(np\) containing the mean-square prediction error of the predicted responses.

coeff

A vector of length \(k\) containing the estimated regression coefficients.

vcov.coeff

A \(k \times k\) matrix containing the (estimated) covariance matrix of estimated the regression coefficients.

simulations

An \(n \times nsim\) matrix containing the nsim realizations of the conditional realizations. Each column of the matrix represents a realization of the conditional normal distribution.

If nsim > 0, this list has class "krigeConditionalSample".

Arguments

y

The vector of observed responses. Should be a matrix of size \(n \times 1\) or a vector of length \(n\).

V

The covariance matrix of the observed responses. The size is \(n \times n\).

Vp

The covariance matrix of the responses to be predicted. The size is \(np \times np\).

Vop

The cross-covariance between the observed responses and the responses to be predicted. The size is \(n \times np\)

nsim

The number of simulated data sets to sample from the conditional predictive distribution.

Ve.diag

A vector of length \(n\) specifying the measure error variances of the observed data. Only needed if nsim > 0.

method

The method for decomposing V in conditional simulation. Default is "eigen", for the Eigen decomposition. Alternatives are "chol" (Cholesky) and "svd" (Singular Value Decomposition).

Author

Joshua French

Details

It is assumed that there are \(n\) observed data values and that we wish to make predictions at \(np\) locations.

If doing conditional simulation, the Cholesky decomposition should not work when there are coincident locations between the observed data locations and the predicted data locations. Both the Eigen and Singular Value Decompositions should work.

If user specifies nsim to be a positive integer, then nsim conditional realizations of the predictive distribution will be generated. If this is less than 1, then no conditional simulation is done. If nsim is a positive integer, then Ve.diag must also be supplied. Ve.diag is should be a vector of length \(n\) specifying the measurement error variances of the observed data. This information is only used for conditional simulation, so this argument is only needed when nsim > 0. When conditional simulation is desired, then the argument method can be to specify the method used to decompose V. Options are "eigen", "chol", or "svd" (Eigen decomposition, Cholesky decomposition, or Singular value decomposition, respectively). This information is only used for conditional simulation, so this argument is only applicable when nsim > 0.

References

Statistical Methods for Spatial Data Analysis, Schabenberger and Gotway (2003). See p. 226-228.

Examples

Run this code
# create observed and predicted coordinates
ocoords <- matrix(runif(100), ncol = 2)
pcoords <- matrix(runif(200), ncol = 2)

# include some observed locations in the predicted coordinates
acoords <- rbind(ocoords, pcoords)

# create covariance matrix
C3 <- cov.sp(coords = ocoords, sp.type = "matern", sp.par = c(2, 1), smoothness = 1, 
	finescale = 0, error = 0.5, pcoords = acoords)

# generate data with error
y <- rmvnorm(nsim = 1, mu = rep(2, 50), V = C3$V) + rnorm(50, sd = sqrt(.5))

# use universal kriging to make predictions.  Do not do conditional simulation
krige.obj <- krige.ok(as.vector(y), V = C3$V, Vp = C3$Vp, Vop = C3$Vop, 
	nsim = 0)

#Do conditional simulation
krige.obj2 <- krige.ok(as.vector(y), V = C3$V, Vp = C3$Vp, Vop = C3$Vop, 
	nsim = 100, Ve.diag = rep(.5, 50), method = "eigen")

Run the code above in your browser using DataLab