R: Generalized Least Squares estimation with a given covariance...
gls-methods
R Documentation
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 signature 'covAll'
gls(object,
y, X, F = NULL, varNoise = NULL,
beta = NULL, checkNames = TRUE,
...)
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.
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).
Value
A list with several elements.
betaHat
Vector of length p
containing the estimated coefficients if beta = NULL, or the
known coefficients beta either.
L
The (lower) Cholesky root matrix L of the
covariance matrix C. This
matrix has n rows and n columns and C = L %*% t(L).
eStar
Vector of length n: eStar = inv(L) %*% (y - X betaHat).
Fstar
Matrix (n, p): FStar = inv(L) %*% F.
sseStar
Sum of squared errors:
t(eStar) %*% eStar.
RStar
The 'R' upper triangular (p, p) matrix in the QR
decomposition of FStar: FStar = Q %*% RStar.
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.
Author(s)
Y. Deville, O. Roustant
References
Kenneth Lange (2010), Numerical Analysis for Statisticians 2nd ed.
pp. 102-103. Springer-Verlag,
Examples
## 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)