get_matrix | R Documentation |
get_matrix
is a first attempt at a unified extractor of various matrices from a fit. All augmented matrices follow (Henderson's) block order (upper blocks: X,Z; lower blocks: 0,I).
get_ZALMatrix
returns the design matrix for the random effects v
.
get_matrix(object, which="model.matrix", augmented=TRUE, ...)
get_ZALMatrix(object, force_bind=TRUE)
object |
An object of class |
augmented |
Boolean; whether to return a matrix for all model coefficients (augmented matrix for fixed-effects coefficients and random-effect predictions) or a matrix only for fixed effects. Not operative for all |
which |
Which element to extract. For |
force_bind |
Boolean; with the non-default value |
... |
Other arguments that may be needed in some future versions of |
(Given the pain that it is to write maths in R documentation files, readers are gently asked to be tolerant about any imperfections of the following).
Model coefficients estimates of a (weighted) linear model can be written as (X'WX)^{-1}
X'Wy where X is the design matrix for fixed effects, W a diagonal weight matrix, and y the response vector. In a linear mixed model, the same expression holds in terms of Henderson's augmented design matrix, of an augmented (still diagonal) weight matrix, and of an augmented response vector. For GLMMs and hierarchical GLMs generally, the solution of each step of the iteratively reweighted least squares algorithm again has the same expression in terms of appropriately defined augmented matrices and vectors.
get_matrix
returns, for given values of the which
argument, the following matrices from the model fit:
"AugX"
: X;
"wei_AugX"
: WX;
"wAugX"
: \sqrt{}
(W)X;
"left_ginv"
: (X'WX)^{-1}
X'W (the name stems from the fact that it is generalized inverse, denoted X^-
, since XX^-
X=X, and it is a left one, since X^-
X is an identity matrix when X has full rank);
"hat_matrix"
: XX^-
=X (X'WX)^{-1}
X'W;
"fixef_left_ginv"
: same as "left_ginv"
but for the fixed-effect design matrix only (not to be confused with the corresponding block of "left_ginv"
);
"beta_v_cov"
: joint covariance matrix of estimates/predictions of fixed-effect coefficients and random effects (the v in random-effects
).
"v_condcov"
: covariance matrix of predictions of random effects (the v in random-effects
) given fixed-effect coefficients.
A matrix, possibly in sparseMatrix
format.
vcov
for the variance-covariance matrix of the fixed-effects coefficients, and Corr
for correlation matrices of random effects.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.