# NOT RUN {
### data preparation:
minhanes1 <- getdata(data = minhanes)
##################
###
### Example 1:
###
### Multiple imputation clustering process with backward variable selection
###
##################
### using only the imputations 1 to 10 for the clustering process and exploring
### 2 vs. 3 clusters:
minhanes1clust <- miclust(data = minhanes1, search = "backward", ks = 2:3,
usedimp = 1:10, seed = 4321)
minhanes1clust
minhanes1clust$kfin ### optimal number of clusters
### graphical summary:
plot(minhanes1clust)
### selection frequency of the variables for the optimal number of clusters:
y <- getvariablesfrequency(minhanes1clust)
y
plot(y$percfreq, type = "h", main = "", xlab = "Variable",
ylab = "Percentage of times selected", xlim = 0.5 + c(0, length(y$varnames)),
lwd = 15, col = "blue", xaxt = "n")
axis(1, at = 1:length(y$varnames), labels = y$varnames)
### default summary for the optimal number of clusters:
summary(minhanes1clust)
## summary forcing 3 clusters:
summary(minhanes1clust, k = 3)
##################
###
### Example 2:
###
### Same analysis but without variable selection
###
##################
# }
# NOT RUN {
minhanes2clust <- miclust(data = minhanes1, ks = 2:3, usedimp = 1:10, seed = 4321)
minhanes2clust
plot(minhanes2clust)
summary(minhanes2clust)
# }
# NOT RUN {
##################
###
### Example 3:
###
### Complete case clustering process with backward variable selection
###
##################
nhanes0 <- getdata(data = minhanes[[1]])
nhanes2clust <- miclust(data = nhanes0, search = "backward", ks = 2:3, seed = 4321)
nhanes2clust
summary(nhanes2clust)
### nothing to plot for a single data set analysis
# plot(nhanes2clust)
##################
###
### Example 4:
###
### Complete case clustering process without variable selection
###
##################
# }
# NOT RUN {
nhanes3clust <- miclust(data = nhanes0, ks = 2:3, seed = 4321)
nhanes3clust
summary(nhanes3clust)
# }
Run the code above in your browser using DataLab