
fviz_hmfa_ind(X, axes = c(1, 2), geom = c("point", "text"), label = "all", invisible = "none", labelsize = 4, pointsize = 2, habillage = "none", addEllipses = FALSE, ellipse.level = 0.95, ellipse.type = "norm", ellipse.alpha = 0.1, col.ind = "blue", col.ind.sup = "darkblue", alpha.ind = 1, shape.ind = 19, repel = FALSE, axes.linetype = "dashed", select.ind = list(name = NULL, cos2 = NULL, contrib = NULL), title = "Individuals factor map - HMFA", jitter = list(what = "label", width = NULL, height = NULL), ...)
fviz_hmfa_quanti_var(X, axes = c(1, 2), geom = c("arrow", "text"), label = "all", invisible = "none", labelsize = 4, pointsize = 2, col.var = "red", alpha.var = 1, shape.var = 17, col.quanti.sup = "blue", col.quali.sup = "darkgreen", col.circle = "grey70", select.var = list(name = NULL, cos2 = NULL, contrib = NULL), axes.linetype = "dashed", title = "Quantitative Variable categories - MFA", repel = FALSE, jitter = list(what = "label", width = NULL, height = NULL))
fviz_hmfa_quali_var(X, axes = c(1, 2), geom = c("point", "text"), label = "all", invisible = "none", labelsize = 4, pointsize = 2, col.var = "red", alpha.var = 1, shape.var = 17, col.quanti.sup = "blue", col.quali.sup = "darkgreen", repel = FALSE, select.var = list(name = NULL, cos2 = NULL, contrib = NULL), axes.linetype = "dashed", title = "Qualitative Variable categories - MFA", jitter = list(what = "label", width = NULL, height = NULL))
fviz_hmfa_quali_biplot(X, axes = c(1, 2), geom = c("point", "text"), label = "all", invisible = "none", labelsize = 4, pointsize = 2, habillage = "none", addEllipses = FALSE, ellipse.level = 0.95, col.ind = "blue", col.ind.sup = "darkblue", alpha.ind = 1, col.var = "red", alpha.var = 1, col.quanti.sup = "blue", col.quali.sup = "darkgreen", axes.linetype = "dashed", shape.ind = 19, shape.var = 17, select.var = list(name = NULL, cos2 = NULL, contrib = NULL), select.ind = list(name = NULL, cos2 = NULL, contrib = NULL), arrows = c(FALSE, FALSE), repel = FALSE, title = "HMFA factor map - Biplot", jitter = list(what = "label", width = NULL, height = NULL), ...)
fviz_hmfa_ind_starplot(X, axes = c(1, 2), geom = c("point", "text"), group.names = NULL, label = "all", invisible = "none", legend.partial.title = NULL, labelsize = 4, pointsize = 2, linesize = 0.5, repel = FALSE, habillage = "none", addEllipses = FALSE, ellipse.level = 0.95, ellipse.type = "norm", ellipse.alpha = 0.1, col.ind = "black", col.ind.sup = "darkblue", col.partial = "black", alpha.ind = 1, shape.ind = 19, alpha.partial = 1, node.level = 1, select.ind = list(name = NULL, cos2 = NULL, contrib = NULL), select.partial = list(name = NULL, cos2 = NULL, contrib = NULL), axes.linetype = "dashed", title = "Individuals factor map - MFA", jitter = list(what = "label", width = NULL, height = NULL), ...)
fviz_hmfa_group(X, axes = c(1, 2), geom = c("point", "text"), alpha.group = 1, shape.group = 17, label = "all", invisible = "none", labelsize = 4, pointsize = 2, col.group = "blue", col.group.sup = "darkgreen", repel = FALSE, select.group = list(name = NULL, cos2 = NULL, contrib = NULL), title = "MFA - Groups Representations", jitter = list(what = "label", width = NULL, height = NULL), ...)
fviz_hmfa(X, ...)
stat_ellipse
including one of c("t", "norm", "euclid").# Hierarchical Multiple Factor Analysis
# ++++++++++++++++++++++++
# Install and load FactoMineR to compute MFA
# install.packages("FactoMineR")
library("FactoMineR")
data(wine)
hierar <- list(c(2,5,3,10,9,2), c(4,2))
res.hmfa <- HMFA(wine, H = hierar, type=c("n",rep("s",5)), graph = FALSE)
# Graph of individuals
# ++++++++++++++++++++
# Default plot
# Color of individuals: col.ind = "#2E9FDF"
# Use repel = TRUE to avoid overplotting (slow if many points)
fviz_hmfa_ind(res.hmfa, repel = TRUE, col.ind = "#2E9FDF")
## Not run:
# # 1. Control automatically the color of individuals
# # using the "cos2" or the contributions "contrib"
# # cos2 = the quality of the individuals on the factor map
# # 2. To keep only point or text use geom = "point" or geom = "text".
# # 3. Change themes: http://www.sthda.com/english/wiki/ggplot2-themes
#
# fviz_hmfa_ind(res.hmfa, col.ind="cos2")+
# theme_minimal()
# ## End(Not run)
# Color individuals by groups, add concentration ellipses
# Remove labels: label = "none".
grp <- as.factor(wine[,1])
p <- fviz_hmfa_ind(res.hmfa, label="none", habillage=grp,
addEllipses=TRUE, ellipse.level=0.95)+
theme_minimal()
print(p)
## Not run:
# # Change group colors using RColorBrewer color palettes
# # Read more: http://www.sthda.com/english/wiki/ggplot2-colors
# p + scale_color_brewer(palette="Paired") +
# scale_fill_brewer(palette="Paired") +
# theme_minimal()
# ## End(Not run)
# Change group colors manually
# Read more: http://www.sthda.com/english/wiki/ggplot2-colors
p + scale_color_manual(values=c("#999999", "#E69F00", "#56B4E9"))+
scale_fill_manual(values=c("#999999", "#E69F00", "#56B4E9"))+
theme_minimal()
## Not run:
# # Select and visualize some individuals (ind) with select.ind argument.
# # - ind with cos2 >= 0.1: select.ind = list(cos2 = 0.1)
# # - Top 20 ind according to the cos2: select.ind = list(cos2 = 20)
# # - Top 20 contributing individuals: select.ind = list(contrib = 20)
# # - Select ind by names: select.ind = list(name = c("1VAU", "1FON") )
#
# # Example: Select the top 10 according to the cos2
# fviz_hmfa_ind(res.hmfa, select.ind = list(cos2 = 100))
# ## End(Not run)
# Graph of qantitative variable categories
# ++++++++++++++++++++++++++++++++++++++++
data(wine)
hierar <- list(c(2,5,3,10,9,2), c(4,2))
res.hmfa <- HMFA(wine, H = hierar, type=c("n",rep("s",5)), graph = FALSE)
# Plot
# Control variable colors using their contributions
fviz_hmfa_quanti_var(res.hmfa, col.var = "contrib")+
scale_color_gradient2(low = "white", mid = "blue",
high = "red", midpoint = 12) +
theme_minimal()
## Not run:
# # Select variables with select.var argument
# # You can select by contrib, cos2 and name
# # as previously described for ind
# # Select the top 10 contributing variables
# fviz_hmfa_quanti_var(res.hmfa, select.var = list(contrib = 10))
# ## End(Not run)
# Graph of categorical variable categories
# ++++++++++++++++++++++++++++++++++++++++
data(poison)
hierar <- list(c(2,2,5,6), c(1,3))
res.hmfa <- HMFA(poison, H = hierar, type=c("s","n","n","n"), graph = FALSE)
# Default plot
fviz_hmfa_quali_var(res.hmfa, col.var = "contrib")+
theme_minimal()
# Biplot of categorical variable categories and individuals
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
grp <- as.factor(poison[, "Vomiting"])
# Use repel = TRUE to avoid overplotting
fviz_hmfa_quali_biplot(res.hmfa, col.var = "#E7B800", repel = FALSE,
habillage = grp, addEllipses = TRUE)+
theme_minimal()
# Graph of partial individuals (starplot)
# +++++++++++++++++++++++++++++++++++++++
fviz_hmfa_ind_starplot(res.hmfa, col.partial = "group.name")+
scale_color_brewer(palette = "Dark2")
theme_minimal()
## Not run:
# # Select the partial points of the top 5
# # contributing individuals
# fviz_hmfa_ind_starplot(res.hmfa,
# select.partial = list(contrib = 2))+
# theme_minimal()
#
# # Change colours of star segments
# fviz_hmfa_ind_starplot(res.hmfa, select.partial = list(contrib = 5),
# col.partial = "group.name") +
# scale_color_brewer(palette = "Dark2") +
# theme_minimal()
# ## End(Not run)
# Graph of groups (correlation square)
# ++++++++++++++++++++++++++++++++++++
fviz_hmfa_group(res.hmfa)
Run the code above in your browser using DataLab