1
$\begingroup$

I am trying to understand the mechanism underline multiple imputation ideas. I am confusing on creating multiple sets of estimates and then average them. For example:

set.seed(123)
df<-data.frame(
x1=rnorm(100,10,2),
x2=rbinom(100,20,0.6))

y=rbinom(100,1,0.5)
#set missing values
ms<-sample(1:100,20)
y[ms]<-NA
df$y<-y

#predict NA

fit<-glm(y~x1+x2,data=df,family="binomial")
pred<-predict(fit,newdata=df[,c("x1","x2")],type="response")
df$yfit1<-with(df,ifelse(pred>=0.4,1,0))
    df$yimp1<-with(df,ifelse(is.na(y),yfit1,y))

         x1 x2  y yfit1 yimp1
1  8.879049 14  1     1     1
2  9.539645  8  0     1     0
3 13.117417 11 NA     1     1
4 10.141017 12  1     1     1
5 10.258575 13  1     1     1
6 13.430130  9  0     1     0

If I want to impute m times to find the average estimates for x1 and x2, in what idea to create multiple df$yimp1...df$yimpm. Why are not these estimates same in different runs? Could someone give an example for m=3?

$\endgroup$
2
  • $\begingroup$ I don't think that you're supposed to average imputed values. $\endgroup$ Mar 27 '14 at 23:27
  • $\begingroup$ Yes, I understand. In the example, the first set of estimates is coef(fit). I wondering how to get the second, third,...set of estimates for m times. $\endgroup$
    – David Z
    Mar 27 '14 at 23:30
0
$\begingroup$

I finally figure it myself from the original Rubin paper, the rest imputations are conducted up the new draw $\beta$s according to the fitted $\hat{\beta}$ and its variance and covariance matrix.

In this case,

newbeta=coef(fit)+chol(vcov(fit))*rnorm(dim(coef(fit))[1])

Then the newbeta are used to predict imp2 etc.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.