Applies an analysis function to each imputed dataset and pools results using Rubin's rules.
Details
The analysis_fun must return a list with at least:
estimate: The point estimate from the analysis
variance: The variance of the estimate
For regression models, this typically means extracting the coefficient and its squared standard error.
Examples
if (FALSE) { # \dontrun{
data <- data.frame(
outcome = c(10, NA, 30, 40, 50),
predictor = c(1, 2, NA, 4, 5)
)
imp <- perform_multiple_imputation(data, m = 5)
# Analyze with linear regression
result <- analyze_with_imputation(imp, function(d) {
fit <- lm(outcome ~ predictor, data = d)
coefs <- summary(fit)$coefficients
list(
estimate = coefs["predictor", "Estimate"],
variance = coefs["predictor", "Std. Error"]^2
)
})
result$pooled_estimate
result$ci
} # }
