Skip to contents

The D2-statistic pools test statistics from the repeated analyses. The method is less powerful than the D1- and D3-statistics.

Usage

D2(fit1, fit0 = NULL, use = "wald", df = 1)

Arguments

fit1

An object of class mira, produced by with().

fit0

An object of class mira, produced by with(). The model in fit0 is a nested within fit1. The default null model fit0 = NULL compares fit1 to the intercept-only model.

use

A character string denoting Wald- or likelihood-based based tests. Can be either "wald" or "likelihood". Only used if method = "D2".

df

The degrees of freedom of the test, used only if fit1 holds htest results that have no chi-squared statistic, such as fisher.test(). See Details.

Details

If fit1 holds the results of a test of class htest, as produced by e.g. with(imp, chisq.test(...)) or with(imp, fisher.test(...)), D2() pools the test results directly with the formulas of Li et al. (1991). There is no null model, so fit0 is ignored.

  • For tests with a chi-squared statistic, such as chisq.test(), mcnemar.test(), mantelhaen.test(), kruskal.test() and friedman.test(), D2() pools the statistics, with their degrees of freedom.

  • For other tests, such as fisher.test(), D2() converts each p-value into a chi-squared statistic with df degrees of freedom, and pools these. The default df = 1 fits a 2 x 2 table. For an r x c table, set df = (r - 1) * (c - 1). The conversion of the p-value of an exact test is an approximation.

Note

Warning: D2() assumes that the order of the variables is the same in different models. See https://github.com/amices/mice/issues/420 for details.

References

Li, K. H., X. L. Meng, T. E. Raghunathan, and D. B. Rubin. 1991. Significance Levels from Repeated p-Values with Multiply-Imputed Data. Statistica Sinica 1 (1): 65–92.

https://stefvanbuuren.name/fimd/sec-multiparameter.html#sec:chi

See also

Examples

# Compare two linear models:
imp <- mice(nhanes2, seed = 51009, print = FALSE)
mi1 <- with(data = imp, expr = lm(bmi ~ age + hyp + chl))
mi0 <- with(data = imp, expr = lm(bmi ~ age + hyp))
if (requireNamespace("mitml", quietly = TRUE)) D2(mi1, mi0)
#>    test statistic df1      df2 dfcom    p.value       riv
#>  1 ~~ 2  6.325693   1 17.03011    NA 0.02222904 0.9403999
if (FALSE) { # \dontrun{
# Compare two logistic regression models
imp <- mice(boys, maxit = 2, print = FALSE)
fit1 <- with(imp, glm(gen > levels(gen)[1] ~ hgt + hc + reg, family = binomial))
fit0 <- with(imp, glm(gen > levels(gen)[1] ~ hgt + hc, family = binomial))
D2(fit1, fit0)
} # }

# Pool chi-squared and Fisher tests of a 2 x 2 table
data <- nhanes2
data$chl <- cut(data$chl, breaks = 2)
imp <- mice(data, seed = 1, print = FALSE)
if (requireNamespace("mitml", quietly = TRUE)) {
  D2(with(imp, chisq.test(xtabs(~ hyp + chl), correct = FALSE)))
  D2(with(imp, fisher.test(xtabs(~ hyp + chl))))
}
#> Warning: Chi-squared approximation may be incorrect
#> Warning: Chi-squared approximation may be incorrect
#> Warning: Chi-squared approximation may be incorrect
#> Warning: Chi-squared approximation may be incorrect
#> Warning: Chi-squared approximation may be incorrect
#>    test statistic df1      df2 dfcom   p.value      riv
#>  1 ~~ 2 0.2976061   1 15.09165    NA 0.5933594 1.061122