library("FactoMineR") library("homals") gmo <- read.csv2("gmo.csv", dec = ".") ## the levels are reorganized by variable in order to be ordered gmo[, 1] <- relevel(gmo[, 1], "A lot ") gmo[, 1] <- relevel(gmo[, 1], "Certain extent") gmo[, 1] <- relevel(gmo[, 1], "A little") gmo[, 1] <- relevel(gmo[, 1], "Not at all") for (i in 2:4) gmo[, i] <- relevel(gmo[, i], "Somewhat Against") for (i in 2:4) gmo[, i] <- relevel(gmo[, i], "Totally opposed") ## Multiple Correpondence Analysis (MCA) res <- MCA(gmo, ncp = 5, quali.sup = 17:21, graph = FALSE) res$var$coord[, 1] <- -res$var$coord[, 1] ### just to manage the symmetry res$quali.sup$coord[, 1] <- -res$quali.sup$coord[, 1] ### just to manage the symmetry ## Figure 1 plot(res, invisible = c("ind", "quali.sup"), cex = 0.7, title = "MCA factor map - Active categories", col.var=c(rep(1,4),rep(2,4),rep(3,4),rep(4,4),5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15,16,16)) ## Figure 2 plot(res, invisible = c("ind", "var"), new.plot = TRUE, title = "MCA factor map - Supplementary categories") ## homals res.homals <- homals(gmo[, 1:16], level = c(rep("nominal", 16)), active = c(rep(TRUE, 16)), ndim = 5) ## Figure not shown but similar to Figure 1 ## palette(c("transparent",palette()[-1])) ## x11(14,8) ## plot(res.homals, plot.typ = "jointplot", leg.pos = "bottomleft", main = "join plot - homals") ## homals rank 1 homalsRank1 <- homals(gmo[, 1:16], level = c(rep("nominal", 16)), active = c(rep(TRUE, 16)), ndim = 5, rank = 1) ## Figure 3 palette(c("transparent", palette()[-1])) ## x11(14, 8) plot(homalsRank1, plot.typ = "jointplot", leg.pos = "bottomleft", main = "join plot - homals rank 1") ## homals ordered ## A trick is used to avoid that homals re-ordered the categories: ## gmo2 is the same data set with names of categories that are in an alphabetical order gmo2 <- gmo for (i in 1:ncol(gmo2)) levels(gmo2[, i]) <- paste(letters[i], 1:nlevels(gmo2[, i]), sep = "") homalsOrdered <- homals(gmo2[, 1:16], level = c(rep("ordinal", 16)), active = c(rep(TRUE, 16)), ndim = 5, rank = 1) for (i in 1:16) rownames(homalsOrdered$catscores[[i]]) <- levels(gmo[, i]) ## the categories are relabelled by their name ## x11(14, 8) plot(homalsOrdered, plot.typ = "jointplot", leg.pos = "bottomleft", main = "join plot - homals ordered")