extract.lme.cov {mgcv} | R Documentation |
This is a service routine for gamm
. It extracts
the estimated covariance matrix of the data from an lme
object, allowing the
user control about which levels of random effects to include in this
calculation.
extract.lme.cov(b,data,start.level=1)
b |
A fitted model object returned by a call to lme |
data |
The data frame/ model frame that was supplied to
lme . |
start.level |
The level of nesting at which to start including random effects in the calculation. This is used to allow smooth terms to be estimated as random effects, but treated like fixed effects for variance calculations. |
The random effects, correlation structure and variance structure used for a linear mixed model combine to imply a covariance matrix for the response data being modelled. This routine extracts that covariance matrix. The process is slightly complicated, because different components of the fitted model object are stored in different orders (see function code for details!).
The calculation is not optimally efficient, since it forms the full matrix, which may in fact be sparse. In applications in which the main objective is to allow non-independent `errors' in GAMs this is unlikely to cause great computational losses.
An estimated covariance matrix.
Simon N. Wood simon@stats.gla.ac.uk
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 here for estimation using lme
see:
Wood, S.N. (manuscript) Tensor product smooth interaction terms in Generalized Additive Mixed Models.
http://www.stats.gla.ac.uk/~simon/
library(nlme) data(Rail) b <- lme(travel~1,Rail,~1|Rail) extract.lme.cov(b,Rail)