Learn R Programming

mgcv (version 1.8-31)

formXtViX: Form component of GAMM covariance matrix

Description

This is a service routine for gamm. Given, \(V\), an estimated covariance matrix obtained using extract.lme.cov2 this routine forms a matrix square root of \( X^TV^{-1}X\) as efficiently as possible, given the structure of \(V\) (usually sparse).

Usage

formXtViX(V,X)

Arguments

V

A data covariance matrix list returned from extract.lme.cov2

X

A model matrix.

Value

A matrix, R such that crossprod(R) gives \( X^TV^{-1}X\).

Details

The covariance matrix returned by extract.lme.cov2 may be in a packed and re-ordered format, since it is usually sparse. Hence a special service routine is required to form the required products involving this matrix.

References

For lme see:

Pinheiro J.C. and Bates, D.M. (2000) Mixed effects Models in S and S-PLUS. Springer

For details of how GAMMs are set up for estimation using lme see:

Wood, S.N. (2006) Low rank scale invariant tensor product smooths for Generalized Additive Mixed Models. Biometrics 62(4):1025-1036

http://www.maths.bris.ac.uk/~sw15190/

See Also

gamm, extract.lme.cov2

Examples

Run this code
# NOT RUN {
require(mgcv)
library(nlme)
data(ergoStool)
b <- lme(effort ~ Type, data=ergoStool, random=~1|Subject)
V1 <- extract.lme.cov(b, ergoStool)
V2 <- extract.lme.cov2(b, ergoStool)
X <- model.matrix(b, data=ergoStool)
crossprod(formXtViX(V2, X))
t(X)
# }
# NOT RUN {
<!-- %*%solve(V1,X) -->
# }

Run the code above in your browser using DataLab