简体   繁体   中英

How to do the prediction after multiple imputation with MICE package

As part of my analysis, I have to do the prediction but mice doesn't have the tool to do so! Meaning that using "with" and then "pool" doesn't work!

X1<-c(1,1,1,0,0,NA)
X2<c(0,NA,1,NA,NA,0)
X3<-c(1,0,1,1,NA,0)
X4<- c(1,0,1,0,1,1)
data<-data.frame(X1,X2,X3,X4)

p<- glm(X3~X1+X2, family= "binomial", data=subset(data, X4==1))
pre<- predict(p, newdata=data, type="response")

Does anyone have any solution? In my case, I have 20 imputed datasets, I tried to do the analysis on each of them separately and then take the mean of the estimates I want but that just does not seem right.

PS: Question got edited after Steffens answer to make it a bit clear.

Your example seems incomplete at the moment ... where do you use mice and where are the missing data?

I am assuming you planned something like this:

library("mice")
X1 <- c(1,NA,1,0,1,0)
X2 <- c(0,1,1,NA,0,0)
data1 <-data.frame(X1,X2)

imp <- mice(data1)

fit <- with(imp, glm(X1~X2, family = binomial))
summary(pool(fit))

This gives you the parameter estimates of the pooled model. If you are interested in them...

Creating predictions is the net step, but there are actually different ways how to approach this (from a scientific perspective). Probably also depends a little on what you are trying to archive (which you did not mention yet)

Here is an interesting paper "Obtaining Predictions from Models Fit to Multiply Imputed Data" on this issue.

Stef van Buuren (the mice author) also has some suggestions with implementation code here: https://github.com/amices/mice/issues/82

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM