Is it possible to use (multiple) imputation when having few variable. I have
been trying to use the MIX library, where I have one categorical and one
continuous covariate but it always crashes. I have attached my problem, I
think I am doing everything the right way but seemingly it does not work.
Furthermore does MI work when for one category in the categorical covariate
all the observations have missing values. Can it be trusted in that case.
Thanks.
Vumani Dlamini
CSO-Swaziland
####
library(mix)
set.seed(124)
xvar<-rnorm(100,0,1)
set.seed(124)
data1<-rbinom(100,size=1,prob=(exp(0.5+0.4*xvar)/(1+exp(0.5+0.4*xvar))))
set.seed(421)
data2<-rbinom(100,size=1,prob=(exp(1-0.3*xvar)/(1+exp(1-0.3*xvar))))
data1a<-na.omit(ifelse(data1==0&data2==0,NA,data1))
data2a<-na.omit(ifelse(data1==0&data2==0,NA,data2))
xvara<-na.omit(ifelse(data1==0&data2==0,NA,xvar))
data<-cbind(ifelse(data1a==1&data2a==0,1,0)+ifelse(data1a==0&data2a==1,2,0)+ifelse(data1a==1&data2a==1,3,0),xvara)
for(i in 1:length(data1a)){
if(data[i,2]>1.5){
data[i,2]<-NA
}
}
data[53:55,1]<-NA
tmp<-format(1:92)
dimnames(data)<-list(tmp,c("PROF","XVAR"))
rm(tmp)
s<-prelim.mix(data,1)
print(s$r)
margins<-1
intercept<-rep(1,length(data1a))
u2i<-ifelse(data1a==0&data2a==1,1,0)
Mi<-ifelse(data1a==1&data2a==1,1,0)
design<-cbind(intercept,u2i,Mi)
rm(intercept,u2i,Mi)
thetahat1<-ecm.mix(s,margins,design)
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.