| extract.lme.cov {mgcv} | R Documentation |
This is a service routine for gamm. 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 forms the full matrix explicitly:
extract.lme.cov2 tries to be more economical than this.
extract.lme.cov(b,data,start.level=1) extract.lme.cov2(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. These routines 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 extract.lme.cov calculation is not optimally efficient, since it forms the full matrix,
which may in fact be sparse. extract.lme.cov2 is more efficient. If the
covariance matrix is diagonal, then only the leading diagonal is returned; if
it can be written as a block diagonal matrix (under some permutation of the
original data) then a list of matrices defining the non-zero blocks is
returned along with an index indicating which row of the original data each
row/column of the block diagonal matrix relates to. The block sizes are defined by
the coarsest level of grouping in the random effect structure.
gamm uses extract.lme.cov2.
extract.lme.cov does not currently deal with the situation in which the
grouping factors for a correlation structure are finer than those for the
random effects. extract.lme.cov2 does deal with this situation.
For extract.lme.cov an estimated covariance matrix.
For extract.lme.cov2 a list containing the estimated covariance matrix
and an indexing array. The covariance matrix is stored as the elements on the
leading diagonalled via the wrapper function PredictMat.
Predict.matrix(object,data)
object |
is a smooth object produced by a smooth.construct method function. The object
contains all the information required to specify the basis for a term of its class, and this information is
used by the appropriate Predict.matrix function to produce a prediction matrix for new covariate values.
Further details are given in smooth.construct. |
data |
A data frame containing the values of the (named) covariates at which the smooth term is to be evaluated. |
Smooth terms in a GAM formula are turned into smooth specification objects of
class xx.smooth.spec during processing of the formula. Each of these objects is
converted to a smooth object using an appropriate smooth.construct fu