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

Description Usage Arguments Value Author(s) See Also Examples

View source: R/lmer_vcov.R

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
## 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)

alexanderrobitzsch/miceadds documentation built on Dec. 12, 2018, 2:41 a.m.