# mi.anova: Analysis of Variance for Multiply Imputed Data Sets (Using... In miceadds: Some Additional Multiple Imputation Functions, Especially for 'mice'

## Description

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

## Usage

 `1` ```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 `car::Anova` function from the car package is used.

## Value

A list with the following entries:

 `r.squared` Explained variance R^2 `anova.table` ANOVA table

## Author(s)

Alexander Robitzsch

## References

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

This function uses `micombine.F` and `micombine.chisquare`.

See `mice::pool.compare` and `mitml::testModels` for model comparisons based on the D_1 statistic. The D_2 statistic is also included in `mitml::testConstraints`.

## 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``` ```############################################################################# # 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 <- miceadds::mice.1chain( nhanes2 , burnin=4 , iter=20 , Nimp=8 ) # 2-way analysis of variance (type 2) an2a <- miceadds::mi.anova(mi.res=mi.res, formula="bmi ~ age * chl" ) # 2-way analysis of variance (type 3) an2b <- miceadds::mi.anova(mi.res=mi.res, formula="bmi ~ age * chl" , type=3) #****** analysis based on first imputed dataset # extract first dataset dat1 <- mice::complete( mi.res\$mids ) # type 2 ANOVA lm1 <- stats::lm( bmi ~ age * chl , data = dat1 ) summary( stats::aov( lm1 ) ) # type 3 ANOVA lm2 <- stats::lm( bmi ~ age * chl , data= dat1, contrasts=list(age=contr.sum)) car::Anova( lm2 , type=3) ```

### Example output

```Loading required package: mice
************ BURNIN PHASE | Iterations 1 - 4 ******************

iter imp variable
1   1  bmi  hyp  chl
2   1  bmi  hyp  chl
3   1  bmi  hyp  chl
4   1  bmi  hyp  chl

************ IMPUTATION PHASE | Iterations 5 - 20 ******************

--- Imputation 1 | Iterations 4 - 6

iter imp variable
1   1  bmi  hyp  chl
2   1  bmi  hyp  chl

--- Imputation 2 | Iterations 6 - 8

iter imp variable
1   1  bmi  hyp  chl
2   1  bmi  hyp  chl

--- Imputation 3 | Iterations 8 - 10

iter imp variable
1   1  bmi  hyp  chl
2   1  bmi  hyp  chl

--- Imputation 4 | Iterations 10 - 12

iter imp variable
1   1  bmi  hyp  chl
2   1  bmi  hyp  chl

--- Imputation 5 | Iterations 12 - 14

iter imp variable
1   1  bmi  hyp  chl
2   1  bmi  hyp  chl

--- Imputation 6 | Iterations 14 - 16

iter imp variable
1   1  bmi  hyp  chl
2   1  bmi  hyp  chl

--- Imputation 7 | Iterations 16 - 18

iter imp variable
1   1  bmi  hyp  chl
2   1  bmi  hyp  chl

--- Imputation 8 | Iterations 18 - 20

iter imp variable
1   1  bmi  hyp  chl
2   1  bmi  hyp  chl
Univariate ANOVA for Multiply Imputed Data (Type 2)

lm Formula:  bmi ~ age * chl
R^2=0.5755
..........................................................................
ANOVA Table
SSQ df1      df2 F value  Pr(>F)    eta2 partial.eta2
age         105.2599   2 14.98955  1.5163 0.25136 0.22985      0.35127
chl         112.3693   1 23.72348  5.1846 0.03210 0.24538      0.36630
age:chl      45.9228   2 39.30677  1.1884 0.31543 0.10028      0.19109
Residual    194.3981  NA       NA      NA      NA      NA           NA
Univariate ANOVA for Multiply Imputed Data (Type 3)

lm Formula:  bmi ~ age * chl
R^2=0.3364
..........................................................................
ANOVA Table
SSQ df1       df2 F value  Pr(>F)    eta2 partial.eta2
age       24.99739   2 129.96671  0.8575 0.42661 0.08534      0.11394
chl       27.60494   1  21.01782  0.6750 0.42052 0.09424      0.12434
age:chl   45.92280   2  39.30677  1.1884 0.31543 0.15677      0.19109
Residual 194.39813  NA        NA      NA      NA      NA           NA
Df Sum Sq Mean Sq F value Pr(>F)
age          2  35.80   17.90   1.164 0.3335
chl          1  79.76   79.76   5.188 0.0345 *
age:chl      2  55.19   27.60   1.795 0.1932
Residuals   19 292.14   15.38
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova Table (Type III tests)

Response: bmi
Sum Sq Df F value    Pr(>F)
(Intercept) 326.20  1 21.2155 0.0001928 ***
age          31.63  2  1.0285 0.3765944
chl          25.82  1  1.6790 0.2105836
age:chl      55.19  2  1.7948 0.1932151
Residuals   292.14 19
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Warning message:
system call failed: Cannot allocate memory
```

miceadds documentation built on Dec. 18, 2017, 5:03 p.m.