Learn R Programming

geoR (version 1.7-5.2.1)

ksline: Spatial Prediction -- Conventional Kriging

Description

This function performs spatial prediction for given covariance parameters. Options implement the following kriging types: SK (simple kriging), OK (ordinary kriging), KTE (external trend kriging) and UK (universal kriging).

The function krige.conv should be preferred, unless moving neighborhood is to be used.

Usage

ksline(geodata, coords = geodata$coords, data = geodata$data,
       locations, borders = NULL, 
       cov.model = "matern",
       cov.pars=stop("covariance parameters (sigmasq and phi) needed"),
       kappa = 0.5, nugget = 0, micro.scale = 0,
       lambda = 1, m0 = "ok", nwin = "full",
       n.samples.backtransform = 500, trend = 1, d = 2,
       ktedata = NULL, ktelocations = NULL, aniso.pars = NULL,
       signal = FALSE, dist.epsilon = 1e-10, messages)

Arguments

geodata

a list containing elements coords and data as described next. Typically an object of the class "geodata" - a geoR data-set. If not provided the arguments coords and data must be provided instead.

coords

an \(n \times 2\) matrix where each row has the 2-D coordinates of the \(n\) data locations. By default it takes the component coords of the argument geodata, if provided.

data

a vector with n data values. By default it takes the component data of the argument geodata, if provided.

locations

an \(N \times 2\) matrix or data-frame with the 2-D coordinates of the \(N\) prediction locations, or a list for which the first two components are used. Input is internally checked by the function check.locations.

borders

optional. If a two column matrix defining a polygon is provided the prediction is performed only at locations inside this polygon.

cov.pars

a vector with 2 elements or an \(n \times 2\) matrix with the covariance parameters \(\sigma^2\) (partial sill) and \(\phi\) (range parameter). If a vector, the elements are the values of \(\sigma^2\) and \(\phi\), respectively. If a matrix, corresponding to a model with several structures, the values of \(\sigma^2\) are in the first column and the values of \(\phi\) are in the second.

nugget

the value of the nugget variance parameter \(\tau^2\). Defaults to zero.

micro.scale

micro-scale variance. If different from zero, the nugget variance is divided into 2 terms: micro-scale variance and measurement error. This might affect the precision of the predictions. In practice, these two variance components are usually indistinguishable but the distinction can be made here if justifiable.

cov.model

string indicating the name of the model for the correlation function. Further details in the documentation for cov.spatial. Defaults are equivalent to the exponential model.

kappa

additional smoothness parameter required by the following correlation functions: "matern", "powered.exponential", "cauchy" and "gneiting.matern".

lambda

numeric value of the Box-Cox transformation parameter. The value \(\lambda = 1\) corresponds to no transformation and \(\lambda = 0\) corresponds to the log-transformation. Prediction results are back-transformed and returned is the same scale as for the original data.

m0

The default value "ok" indicates that ordinary kriging will be performed. Other options are "kt" for kriging with a trend model (universal kriging) and "kte" for kriging with external trend (covariates). If a numeric value is provided it is assumed to be the value of a know mean and simple kriging is then performed. If "av" the arithmetic mean of the data is assumed to be the know mean for simple kriging algorithm.

nwin

If "full" global neighborhood is used i.e., all data values are used in the prediction of every prediction location. An integer number defines the moving neighborhood algorithm. The number provided is used as the number closest neighbors to be used for the prediction at each location. Defaults to "full".

n.samples.backtransform

number of samples used in the back-transformation. When transformations are used (specified by an argument lambda), back-transformations are usually performed by sampling from the predictive distribution and then back-transforming the sampled values. The exceptions are for \(\lambda = 0\) (log-transformation) and \(\lambda = 1\) (no transformation).

trend

only required if m0 = "kt" (universal kriging). Possible values are \(1\) or \(2\), corresponding to a first or second degree polynomial trend on the coordinates, respectively.

d

spatial dimension, \(1\) defines a prediction on a line, \(2\) on a plane (the default).

ktedata

only required if m0 = "kte". A vector or matrix with the values of the external trend (covariates) at the data locations.

ktelocations

only required if m0 = "kte". A vector or matrix with the values of the external trend (covariates) at the prediction locations.

aniso.pars

parameters for geometric anisotropy correction. If aniso.pars = FALSE no correction is made, otherwise a two elements vector with values for the anisotropy parameters must be provided. Anisotropy correction consists of a transformation of the data and prediction coordinates performed by the function coords.aniso.

signal

logical. If TRUE the signal is predicted, otherwise the variable is predicted. If no transformation is performed the expectations are the same in both cases and the difference is only for values of the kriging variance, if the value of the nugget is different from zero.

dist.epsilon

a numeric value. Points which are separated by a distance less than this value are considered co-located.

messages

logical. Indicates whether or not status messages are printed on the screen (or other output device) while the function is running.

Value

An object of the class kriging which is a list with the following components:

predict

the predicted values.

krige.var

the kriging variances.

dif

the difference between the predicted value and the global mean. Represents the contribution to the neighboring data to the prediction at each point.

summary

values of the arithmetic and weighted mean of the data and standard deviations. The weighted mean corresponds to the estimated value of the global mean.

ktrend

the matrix with trend if m0 = "kt" (universal kriging).

ktetrend

the matrix with trend if m0 = "kte" (external trend kriging).

beta

the value of the mean which is implicitly estimated for m0 = "ok", "kte" or "kt".

wofmean

weight of mean. The predicted value is an weighted average between the global mean and the values at the neighboring locations. The value returned is the weight of the mean.

locations

the coordinates of the prediction locations.

message

status messages returned by the algorithm.

call

the function call.

References

Further information on the package geoR can be found at: http://www.leg.ufpr.br/geoR.

See Also

krige.conv for a more efficient implementation of conventional kriging methods, krige.bayes for Bayesian prediction.

Examples

Run this code
# NOT RUN {
loci <- expand.grid(seq(0,1,l=31), seq(0,1,l=31))
kc <- ksline(s100, loc=loci, cov.pars=c(1, .25))
par(mfrow=c(1,2))
image(kc, main="kriging estimates")
image(kc, val=sqrt(kc$krige.var), main="kriging std. errors")
# }

Run the code above in your browser using DataLab