# NOT RUN {
#########################################################
## Multiple Imputation for visualization on the PCA map
#########################################################
data(orange)
## First the number of components has to be chosen
## (for the reconstruction step)
nb <- estim_ncpPCA(orange,ncp.max=4)
## Multiple Imputation
resMI <- MIPCA(orange,ncp=2)
## Visualization on the PCA map
plot(resMI)
#########################################################
## Multiple Imputation for applying statistical methods
(Bayesian method)
#########################################################
data(ozone)
## First the number of components has to be chosen
nb <- estim_ncpPCA(ozone[,1:11])
## Multiple Imputation with Bayesian method
res.BayesMIPCA<-MIPCA(ozone[,1:11],ncp=2,method.mi="Bayes",verbose=TRUE)
## Regression on the multiply imputed data set and pooling with mice
require(mice)
imp<-prelim(res.mi=res.BayesMIPCA,X=ozone[,1:11])#creating a mids object
fit <- with(data=imp,exp=lm(maxO3~T9+T12+T15+Ne9+Ne12+Ne15+Vx9+Vx12+Vx15+maxO3v))#analysis
res.pool<-pool(fit);summary(res.pool)#pooling
## Diagnostics
res.over<-Overimpute(res.BayesMIPCA)
# }
Run the code above in your browser using DataLab