Package 'howManyImputations'

Title: Calculate How many Imputations are Needed for Multiple Imputation
Description: When performing multiple imputations, while 5-10 imputations are sufficient for obtaining point estimates, a larger number of imputations are needed for proper standard error estimates. This package allows you to calculate how many imputations are needed, following the work of von Hippel (2020) <doi:10.1177/0049124117747303>.
Authors: Josh Errickson [aut, cre]
Maintainer: Josh Errickson <[email protected]>
License: MIT + file LICENSE
Version: 0.2.6.9001
Built: 2024-11-01 11:16:14 UTC
Source: https://github.com/josherrickson/howmanyimputations

Help Index


Implements two-stage "how_many_imputations" from von Hippel (2020)

Description

The old advice of 5-10 imputations is sufficient for a point estimate (e.g. an estimated coefficient), but not for estimates of standard errors (and consequently, hypothesis tests or confidence intervals).

Usage

how_many_imputations(model, cv = 0.05, alpha = 0.05)

howManyImputations(model, cv = 0.05, alpha = 0.05)

Arguments

model

Either a mira object (created by running a model on a data set which was imputed using mice::mice()) or a mipo object (creating by running pool() on a mira object), or any object which can be converted to mira via as.mira().

cv

Desired precision of standard errors. Default to .05. If the data were re-imputed, the estimated standard errors would differ by no more than this amount.

alpha

Significance level for choice of "conservative" FMI.

Details

von Hippel (2020) provides a way to calculate the number of imputations needed to have consistent estimates of the standard error. To do so requires an estimate of the Fraction of Missing Information (FMI) which can only be obtained after running some number of imputations. Therefore, von Hippel (2020) recommends the following procedure:

  1. Carry out a limited number of imputations to enable estimation of the FMI. von Hippel (2020) recommends 20 imputations.

  2. Use this function, how_many_imputations(), to calculate how many total imputations you will need.

  3. If the number of total imputations you will need is larger than your initial batch of 20, run additional imputations.

Value

The number of required imputations to obtain the cv level of precision.

References

von Hippel, Paul T. "How Many Imputations Do You Need? A Two-stage Calculation Using a Quadratic Rule." Sociological Methods & Research 49.3 (2020): 699-718.

Examples

data(airquality)
# Add some missingness
airquality[4:10, 3] <- rep(NA, 7)
airquality[1:5, 4] <- NA
airquality <- airquality[-c(5, 6)]
impdata1 <- mice::mice(airquality, m = 5, maxit = 10,
                       method = 'pmm', seed = 500)
modelFit1 <- with(impdata1, lm(Temp ~ Ozone + Solar.R + Wind))
how_many_imputations(modelFit1)
how_many_imputations(modelFit1, cv = .01)

# Using a non-`mice` libraries.
library(jomo)
library(mitools) # for the `imputationList` function
jomodata <- jomo::jomo1(airquality, nburn = 100, nbetween = 100, nimp = 5)
impdata2 <- mitools::imputationList(split(jomodata, jomodata$Imputation))
modelfit2 <- with(impdata2, lm(Temp ~ Ozone + Solar.R + Wind))
how_many_imputations(modelfit2)

library(Amelia)
data(freetrade)
a.out <- amelia(freetrade, m = 20, ts = "year", cs = "country")
modelFit3 <- with(imputationList(a.out$imputations),
                  lm(tariff ~ polity + pop + gdp.pc + year + country))
how_many_imputations(modelFit3)