Learn R Programming

miceadds (version 1.5-0)

mi.anova: Analysis of Variance for Multiply Imputed Data Sets (Using the $D_2$ Statistic)

Description

This function combines $F$ values from analysis of variance using the $D_2$ statistic which is based on combining $\chi^2$ statistics (see Allison, 2001; micombine.F, micombine.chisquare).

Usage

mi.anova(mi.res, formula, type=2)

Arguments

mi.res
Object of class mids or mids.1chain
formula
Formula for lm function. Note that this can be also a string.
type
Type for ANOVA calculations. For type=3, the Anova function form the car package is used.

Value

  • A list with the following entries:
  • r.squaredExplained variance $R^2$
  • anova.tableANOVA table

References

Allison, P. D. (2002). Missing data. Newbury Park, CA: Sage.

See Also

micombine.F, micombine.chisquare

Examples

Run this code
#############################################################################
# EXAMPLE 1: nhanes2 data | two-way ANOVA
#############################################################################

library(mice)
library(car)
data(nhanes2, package="mice")
set.seed(9090)

# nhanes data in one chain and 8 imputed datasets
mi.res <- mice.1chain( nhanes2 , burnin=4 , iter=20 , Nimp=8 )
# 2-way analysis of variance (type 2)
an2a <- mi.anova(mi.res=mi.res, formula="bmi ~ age * chl" )
# 2-way analysis of variance (type 3)
an2b <- mi.anova(mi.res=mi.res, formula="bmi ~ age * chl" , type=3)

#****** analysis based on first imputed dataset

# extract first dataset
dat1 <- complete( mi.res$mids )

# type 2 ANOVA
lm1 <- lm( bmi ~ age * chl , data = dat1 )
summary( aov( lm1 ) )
# type 3 ANOVA
lm2 <- lm( bmi ~ age * chl , data= dat1,    contrasts=list(age=contr.sum))
car::Anova( lm2 , type=3)

Run the code above in your browser using DataLab