lmer_vcov: Statistical Inference for Fixed and Random Structure for...

View source: R/lmer_vcov.R

lmer_vcovR Documentation

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 class 'lmer_vcov'
summary(object, digits=4, file=NULL, ...)
## S3 method for class 'lmer_vcov'
coef(object, ...)
## S3 method for class 'lmer_vcov'
vcov(object, ...)

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

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

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

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

Value

List with several entries:

par_summary

Parameter summary

coef

Estimated parameters

vcov

Covariance matrix of estimates

...

Further values

Author(s)

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

See Also

lme4::lmer, mitml::testEstimates

Examples

## Not run: 
#############################################################################
# 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)

## End(Not run)

miceadds documentation built on May 29, 2024, 11:05 a.m.