if (FALSE) {
#############################################################################
# EXAMPLE 1: PCA on imputed internet data
#############################################################################
library(mice)
data(data.internet)
dat <- as.matrix( data.internet)
# single imputation in mice
imp <- mice::mice( dat, m=1, maxit=10 )
# apply PCA
pca.imp <- miceadds::pca.covridge( complete(imp) )
## > pca.imp$sdev
## Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 Comp.6 Comp.7
## 3.0370905 2.3950176 2.2106816 2.0661971 1.8252900 1.7009921 1.6379599
# compare results with princomp
pca2.imp <- stats::princomp( complete(imp) )
## > pca2.imp
## Call:
## stats::princomp(x=complete(imp))
##
## Standard deviations:
## Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 Comp.6 Comp.7
## 3.0316816 2.3907523 2.2067445 2.0625173 1.8220392 1.6979627 1.6350428
}
Run the code above in your browser using DataLab