Learn R Programming

geoR (version 1.2-5)

varcov.spatial: Computes Covariance Matrix and Related Results

Description

This function builds the covariance matrix for a set of spatial locations, given the covariance parameters. According to the input options other results related to the covariance matrix (such as decompositions, determinants, inverse. etc) can also be returned.

Usage

varcov.spatial(coords = NULL, dists.lowertri = NULL,
               cov.model = "matern", kappa = 0.5, nugget = 0,
               cov.pars = stop("no cov.pars argument"), 
               inv = FALSE, det = FALSE,
               func.inv = c("cholesky", "eigen", "svd", "solve"),
               scaled = FALSE,  only.decomposition = FALSE,
               sqrt.inv = FALSE, try.another.decomposition = TRUE,
               only.inv.lower.diag = FALSE)

Arguments

coords
an $n \times 2$ matrix with the coordinates of the data locations. If not provided the argument dists.lowertri should be provided instead.
dists.lowertri
a vector with the lower triangle of the matrix of distances between pairs of data points. If not provided the argument coords should be provided instead.
cov.model
a string indicating the type of the correlation function. More details in the documentation for cov.spatial. Defaults are equivalent to the exponential model.
kappa
values of the additional smoothness parameter, only required by the following correlation functions: "matern", "powered.exponential", "cauchy" and "gneiting.matern".
nugget
the value of the nugget parameter $\tau^2$.
cov.pars
a vector with 2 elements or an $ns \times 2$ matrix with the covariance parameters. The first element (if a vector) or first column (if a matrix) corresponds to the variance parameter $\sigma^2$. second element or column corresponds to the cor
inv
if TRUE the inverse of covariance matrix is returned. Defaults to FALSE.
det
if TRUE the logarithmic of the square root of the determinant of the covariance matrix is returned. Defaults to FALSE.
func.inv
algorithm used for the decomposition and inversion of the covariance matrix. Options are "chol" for Cholesky decomposition, "svd" for singular value decomposition and "eigen" for eigenvalues/eigenvectors
scaled
logical indicating whether the covariance matrix should be scaled. If TRUE the partial sill parameter $\sigma^2$ is set to 1. Defaults to FALSE.
only.decomposition
logical. If TRUE only the square root of the covariance matrix is returned. Defaults to FALSE.
sqrt.inv
if TRUE the square root of the inverse of covariance matrix is returned. Defaults to FALSE.
try.another.decomposition
logical. If TRUE and the argument func.inv is one of "cholesky", "svd" or "solve", the matrix decomposition or inversion is tested and, if it fails, the argument func.inv
only.inv.lower.diag
logical. If TRUE only the lower triangle and the diagonal of the inverse of the covariance matrix are returned. Defaults to FALSE.

Value

  • The result is always list. The components will vary according to the input options. The possible components are:
  • varcovthe covariance matrix.
  • sqrt.varcova square root of the covariance matrix.
  • lower.inversethe lower triangle of the inverse of covariance matrix.
  • diag.inversethe diagonal of the inverse of covariance matrix.
  • inversethe inverse of covariance matrix.
  • sqrt.inversea square root of the inverse of covariance matrix.
  • log.det.to.halfthe logarithmic of the square root of the determinant of the covariance matrix.

Details

The elements of the covariance matrix are computed by the function cov.spatial. Typically this is an auxiliary function called by other functions in the geoR package.

References

Further information about geoR can be found at: http://www.maths.lancs.ac.uk/~ribeiro/geoR.

See Also

cov.spatial for more information on the correlation functions; chol, solve, svd and eigen for matrix inversion and/or decomposition.