Learn R Programming

miceadds (version 3.17-44)

lmer_vcov: Statistical Inference for Fixed and Random Structure for Fitted Models in lme4

Description

The function lmer_vcov conducts statistical inference for fixed coefficients and standard deviations and correlations of random effects structure of models fitted in the lme4 package.

The function lmer_pool applies the Rubin formula for inference for fitted lme4 models for multiply imputed datasets.

Usage

lmer_vcov(object, level=.95, use_reml=FALSE, ...)

# S3 method for lmer_vcov summary(object, digits=4, file=NULL, ...) # S3 method for lmer_vcov coef(object, ...) # S3 method for lmer_vcov vcov(object, ...)

lmer_vcov2(object, level=.95, ...)

lmer_pool( models, level=.95, ...) # S3 method for lmer_pool summary(object, digits=4, file=NULL, ...)

lmer_pool2( models, level=.95, ...)

Value

List with several entries:

par_summary

Parameter summary

coef

Estimated parameters

vcov

Covariance matrix of estimates

...

Further values

Arguments

object

Fitted object in lme4

level

Confidence level

use_reml

Logical indicating whether REML estimates should be used for variance components (if provided)

digits

Number of digits used for rounding in summary

file

Optional file name for sinking output

models

List of models fitted in lme4 for a multiply imputed dataset

...

Further arguments to be passed

Author

Function originally from Ben Bolker, http://rpubs.com/bbolker/varwald

See Also

lme4::lmer, mitml::testEstimates

Examples

Run this code
if (FALSE) {
#############################################################################
# EXAMPLE 1: Single model fitted in lme4
#############################################################################

library(lme4)
data(data.ma01, package="miceadds")
dat <- na.omit(data.ma01)

#* fit multilevel model
formula <- math ~ hisei + miceadds::gm( books, idschool ) + ( 1 + books | idschool )
mod1 <- lme4::lmer( formula, data=dat, REML=FALSE)
summary(mod1)

#* statistical inference
res1 <- miceadds::lmer_vcov( mod1 )
summary(res1)
coef(res1)
vcov(res1)

#############################################################################
# EXAMPLE 2: lme4 model for multiply imputed dataset
#############################################################################

library(lme4)
data(data.ma02, package="miceadds")
datlist <- miceadds::datlist_create(data.ma02)

#** fit lme4 model for all imputed datasets
formula <- math ~ hisei + miceadds::gm( books, idschool ) + ( 1 | idschool )
models <- list()
M <- length(datlist)
for (mm in 1:M){
    models[[mm]] <- lme4::lmer( formula, data=datlist[[mm]], REML=FALSE)
}

#** statistical inference
res1 <- miceadds::lmer_pool(models)
summary(res1)
}

Run the code above in your browser using DataLab