Learn R Programming

GeoModels (version 2.2.1)

getInvC: Utility function for kriging computation

Description

Utility function that computes (\(\Sigma^{-1} \mathbf{CC}\)) where \(\Sigma\) is a covariance matrix and \(\mathbf{CC}\) is the matrix of of covariances between the observed location and the locations to predict. Optionally, the quadratic form \(\mathbf{cc}^\top \Sigma^{-1} \mathbf{cc}\) can be computed. Both dense and sparse matrix representations are supported.

Usage

getInvC(covmatrix, CC, mse = TRUE)

Value

A list with components

a

Numeric vector: the product \(\Sigma^{-1} \mathbf{cc}\).

b

Numeric scalar: the quadratic form \(\mathbf{cc}^\top \Sigma^{-1} \mathbf{cc}\) (only if mse = TRUE).

Arguments

covmatrix

A covariance matrix:

covmatrix

A covariance matrix (dense or sparse).

sparse

Logical scalar indicating whether the matrix is stored in sparse format.

CC

Numeric matrix to be multiplied by the inverse of the covariance matrix (length must match the dimension of covmatrix).

mse

Logical. If TRUE (default) the quadratic form \(\mathbf{cc}^\top \Sigma^{-1} \mathbf{cc}\) is also returned.

Author

Moreno Bevilacqua, moreno.bevilacqua@uai.cl

Details

For dense matrices the function uses the Cholesky decomposition provided by FastGP::rcppeigen_get_chol. For sparse matrices (class spam) the factorisation is performed with spam::chol.spam. If the covariance matrix is not positive definite an error is thrown.