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 |
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).
how_many_imputations(model, cv = 0.05, alpha = 0.05) howManyImputations(model, cv = 0.05, alpha = 0.05)
how_many_imputations(model, cv = 0.05, alpha = 0.05) howManyImputations(model, cv = 0.05, alpha = 0.05)
model |
Either a |
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. |
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:
Carry out a limited number of imputations to enable estimation of the FMI. von Hippel (2020) recommends 20 imputations.
Use this function, how_many_imputations()
, to calculate how
many total imputations you will need.
If the number of total imputations you will need is larger than your initial batch of 20, run additional imputations.
The number of required imputations to obtain the cv
level of
precision.
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.
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)
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)