Computes the GLS estimate using the formula: [REMOVE_ME]μGLS=(X⊤Σ−1X)−1X⊤Σ−1y.[REMOVEME2]
The computation is done depending on the input class of the Cholesky factor R. It relies on the classical solve or on using forwardsolve and backsolve functions of package spam, see solve. This is much faster than computing the inverse of Σ, especially since we have to compute the Cholesky decomposition of Σ either way.
GLS_chol(R, X, y)## S3 method for class 'spam.chol.NgPeyton'GLS_chol(R, X, y)## S3 method for class 'matrix'GLS_chol(R, X, y)
Arguments
R: (spam.chol.NgPeyton or matrix(n, n))
Cholesky factor of the covariance matrix Σ. If covariance tapering and sparse matrices are used, then the input is of class spam.chol.NgPeyton. Otherwise, R is the output of a standard chol, i.e., a simple matrix
X: (matrix(n, p))
Data / design matrix.
y: (numeric(n))
Response vector
Returns
A numeric(p) vector, i.e., the mean effects.
Description
Computes the GLS estimate using the formula:
μGLS=(X⊤Σ−1X)−1X⊤Σ−1y.
The computation is done depending on the input class of the Cholesky factor R. It relies on the classical solve or on using forwardsolve and backsolve functions of package spam, see solve. This is much faster than computing the inverse of Σ, especially since we have to compute the Cholesky decomposition of Σ either way.
Examples
# generate datan <-10X <- cbind(1,20+1:n)y <- rnorm(n)A <- matrix(runif(n^2)*2-1, ncol=n)Sigma <- t(A)%*% A
# two possibilities## using standard Cholesky decompositionR_mat <- chol(Sigma); str(R_mat)mu_mat <- GLS_chol(R_mat, X, y)## using spamR_spam <- chol(spam::as.spam(Sigma)); str(R_spam)mu_spam <- GLS_chol(R_spam, X, y)# should be identical to the followingmu <- solve(crossprod(X, solve(Sigma, X)))%*% crossprod(X, solve(Sigma, y))## checkabs(mu - mu_mat)abs(mu - mu_spam)