withinBetween {mlmi} | R Documentation |
Within between variance estimation
Description
This function implements the within-between variance estimation approach. If the imputations were generated using posterior draws, it implements the approach proposed by Barnard & Rubin (1999). If posterior draws were not used, it implements the WB approach described by von Hippel and Bartlett (2021).
Usage
withinBetween(imps, analysisFun, pd = NULL, dfComplete = NULL, ...)
Arguments
imps |
A list of imputed datasets produced by one of the imputation functions
in |
analysisFun |
A function to analyse the imputed datasets that when applied to
a dataset returns a list containing a vector |
pd |
If |
dfComplete |
The complete data degrees of freedom. If |
... |
Other parameters that are to be passed through to |
Value
A list containing the overall parameter estimates, its corresponding covariance matrix, and degrees of freedom for each parameter.
References
Barnard J, Rubin DB. Miscellanea. Small-sample degrees of freedom with multiple imputation. Biometrika 1999; 86(4): 948-955. doi:10.1093/biomet/86.4.948
von Hippel P.T. and Bartlett J.W. Maximum likelihood multiple imputation: faster, more efficient imputation without posterior draws. Statistical Science 2021; 36(3) 400-420 doi:10.1214/20-STS793.
Examples
#simulate a partially observed dataset
set.seed(1234)
n <- 100
x <- rnorm(n)
y <- x+rnorm(n)
y[1:50] <- NA
temp <- data.frame(x,y)
#impute using normImp
imps <- normImp(temp, M=100, pd=TRUE, rseed=4423)
#define a function which analyses a dataset using our desired
#analysis model, returning the estimated parameters and their
#corresponding variance covariance matrix
analysisFun <- function(inputData) {
mod <- lm(y~x, data=inputData)
list(est=coef(mod), var=vcov(mod))
}
withinBetween(imps,analysisFun, dfComplete=c(n-2,n-2))