vcov_vc | R Documentation |
Return the asymptotic covariance matrix of random effect standard deviations (or variances) for a fitted model object, using the Hessian evaluated at the (restricted) maximum likelihood estimates.
vcov_vc(x, sd_cor = TRUE, print_names = TRUE)
x |
A fitted merMod object from |
sd_cor |
Logical indicating whether to return asymptotic covariance
matrix on SD scale (if |
print_names |
Logical, whether to print the names for the covariance matrix. |
Although it's easy to obtain the Hessian for \theta
, the relative
Cholesky factor, in lme4, there is no easy way to obtain the Hessian
for the variance components. This function uses devfun_mer()
to
obtain the Hessian (H
) of variance components (or standard deviations,
SD), and then obtain the asymptotic covariance matrix as -2 H^{-1}
.
A (q + 1) * (q + 1) symmetric matrix of the covariance
matrix of (\tau, \sigma
) (if sd_cor = TRUE
) or
(\tau^2, \sigma^2
) (if sd_cor = FALSE
), where q is the
the number of estimated random-effects components (excluding \sigma
).
For example, for a model with random slope, \tau
=
(intercept SD, intercept-slope correlation, slope SD).
vcov.merMod
for covariance matrix of fixed
effects, confint.merMod
for confidence intervals of all
parameter estimates, and devfun_mer
for the underlying
function to produce the deviance function.
library(lme4)
data(Orthodont, package = "nlme")
fm1 <- lmer(distance ~ age + (age | Subject), data = Orthodont)
vc <- VarCorr(fm1)
# Standard deviation only
print(vc, comp = c("Std.Dev"))
# Asymptotic variance-covariance matrix of (tau, sigma):
vcov_vc(fm1, sd_cor = TRUE)
## Not run:
#' # Compare with (parametric) bootstrap results :
get_sdcor <- function(x) {
as.data.frame(lme4::VarCorr(x), order = "lower.tri")[ , "sdcor"]
}
boo <- bootstrap_mer(fm1, get_sdcor, type = "parametric", nsim = 200L)
# There might be failures in some resamples
cov(boo$t, use = "complete.obs")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.