I have successfully completed a multiple imputation on the missing data of my questionnaire research using the MICE package in R and performed a linear regression on the pooled imputed variables. I can't seem to work out how to extract single pooled variables and plot in a graph. Any ideas?
>imp <- mice(questionnaire)
>fit <- with(imp, lm(APE~TMAS+APB+APA+FOAP))
> imp <-mice(nhanes)
> fit <-with(imp, lm(bmi~chl+hyp))
> mat <-complete(imp, "long")
the underlying with.mids() function lets the regression be carried out on each imputed dataframe. So it is not one regression, but 5 regressions that happened. pool() just averages the estimated coefficients and adjusts the variances for the statistical inference according to the amount of imputation.
So there aren't single pooled variables to plot. What you could do is average the 5 imputed sets and recreate some kind of "regression line" based on the pooled coefficients, eg :
# Averaged imputed data combchl <- tapply(mat$chl,mat$.id,mean) combbmi <- tapply(mat$bmi,mat$.id,mean) combhyp <- tapply(mat$hyp,mat$.id,mean) # coefficients coefs <- pool(fit)$qbar # regression results x <- data.frame( int = rep(1,25), chl = seq(min(combchl),max(combchl),length.out=25), hyp = seq(min(combhyp),max(combhyp),length.out=25) ) y <- as.matrix(x) %*%coefs # a plot plot(combbmi~combchl) lines(x$chl,y,col="red")