Learn R Programming

kergp (version 0.5.7)

gls-methods: Generalized Least Squares Estimation with a Given Covariance Kernel

Description

Generalized Least Squares (GLS) estimation for a linear model with a covariance given by the covariance kernel object. The method gives auxiliary variables as needed in many algebraic computations.

Usage

# S4 method for covAll
gls(object,
    y, X, F = NULL, varNoise = NULL, 
    beta = NULL, checkNames = TRUE,
    ...)

Value

A list with several elements.

betaHat

Vector \(\widehat{\boldsymbol{\beta}}\) of length \(p\) containing the estimated coefficients if beta = NULL, or the known coefficients \(\boldsymbol{\beta}\) either.

L

The (lower) Cholesky root matrix \(\mathbf{L}\) of the covariance matrix \(\mathbf{C}\). This matrix has \(n\) rows and \(n\) columns and \(\mathbf{C} = \mathbf{L} \mathbf{L}^\top\).

eStar

Vector of length \(n\): \(\mathbf{e}^\star = \mathbf{L}^{-1}(\mathbf{y} - \mathbf{X} \widehat{\boldsymbol{\beta}})\).

Fstar

Matrix \(n \times p\): \(\mathbf{F}^\star := \mathbf{L}^{-1}\mathbf{F}\).

sseStar

Sum of squared errors: \({\mathbf{e}^\star}^\top\mathbf{e}^\star\).

RStar

The 'R' upper triangular \(p \times p\) matrix in the QR decomposition of FStar: \(\mathbf{F}^\star = \mathbf{Q}\mathbf{R}^\star\).

All objects having length \(p\) or having one of their dimension equal to \(p\) will be NULL when F is NULL, meaning that \(p = 0\).

Arguments

object

An object with "covAll" class.

y

The response vector with length \(n\).

X

The input (or spatial design) matrix with \(n\) rows and \(d\) columns. This matrix must be compatible with the given covariance object, see checkX,covAll,matrix-method.

F

A trend design matrix with \(n\) rows and \(p\) columns. When F is NULL no trend is used and the response y is simply a realization of a centered Gaussian Process with covariance kernel given by object.

varNoise

A known noise variance. When provided, must be a positive numeric value.

beta

A known vector of trend parameters. Default is NULL indicating that the trend parameters must be estimated.

checkNames

Logical. If TRUE (default), check the compatibility of X with object, see checkX.

...

not used yet.

Author

Y. Deville, O. Roustant

Details

There are two options: for unknown trend, this is the usual GLS estimation with given covariance kernel; for a known trend, it returns the corresponding auxiliary variables (see value below).

References

Kenneth Lange (2010), Numerical Analysis for Statisticians 2nd ed. pp. 102-103. Springer-Verlag,

Examples

Run this code
## a possible 'covTS'
myCov <- covTS(inputs = c("Temp", "Humid"),
               kernel = "k1Matern5_2",
               dep = c(range = "input"),
               value = c(range = 0.4))
d <- myCov@d; n <- 100;
X <- matrix(runif(n*d), nrow = n, ncol = d)
colnames(X) <- inputNames(myCov)
## generate the 'GP part'  
C <- covMat(myCov, X = X)
L <- t(chol(C))
zeta <- L %*% rnorm(n)
## trend matrix 'F' for Ordinary Kriging
F <- matrix(1, nrow = n, ncol = 1)
varNoise <- 0.5
epsilon <- rnorm(n, sd = sqrt(varNoise))
beta <- 10
y <- F %*% beta + zeta + epsilon
fit <- gls(myCov, X = X, y = y, F = F, varNoise = varNoise)

Run the code above in your browser using DataLab