首页 > 解决方案 > 使用 FactominR 如何使用 plot() 在 FAMD 中显示补充变量

问题描述

我正在使用 FactominR 进行分析。对于我的数据,我需要运行 FAMD,因为我混合了连续变量和分类变量。我有活跃的连续和分类变量,以及补充分类变量。我可以运行 FAMD 并绘制结果。但我没有找到如何在图形上绘制补充变量。总结显示补充变量包含在分析中。我在这个包上做了一个 mooc 并且玩了很多不同的功能,并且知道如何为 PCA、MFA 等其他人做到这一点……但我没有找到如何为 FAMD 显示它们我期望一个图表与不同模式的 MFA 类似。

我已经阅读了 plot.FAMD 函数,似乎不存在显示或不存在补充变量的可能性。我觉得这很奇怪,因为对于 MFA ,情节包括补充变量,并且可以显示或不显示它们。

包中包含的示例没有补充变量。它运行良好,但我无法比较。

# This works except the supplementary variable are invisible on all graphs
res <- FAMD(luc, ncp = Inf, sup.var = c(1,7,8,10,11,13,14))
summary(res, nbelements=Inf)

# Here are the option to display the different graphs from FAMD
plot(res, choix="var")
plot(res, choix="quanti")
plot(res, choix="quali")
plot(res, choix = "ind")

Error in match.arg(choix, c("ind", "var", "quanti", "quali")) : 
  'arg' should be one of “ind”, “var”, “quanti”, “quali”

#what I would do/did with an MFA to remove the suppl variables on the ind factor map
plot(res, invisible=c("var","quali.sup"))

#Same on the Variable graph for an MFA
plot(res, choix="var",invisible=c("quali.sup","quanti.sup"))

标签: r

解决方案


我发现了问题。我正在使用旧版本的 FactomineR 1.41 更新到 1.42 解决了它。

如果您有同样的问题,并且想要测试,您可以使用开发人员之一 François Husson 给我的以下代码。

data(wine)
res <- FAMD(wine[,c(1,2,30,31)],sup.var=1)
plot(res)                  ## graphe avec individus + modalités actves + modalités supplémentaires
plot(res,invisible=c("ind","quali")) ## graphe avec modalités supplémentaires (on rend invisible les individus et modalités actives)
plot(res,choix="var")     # graphe avec toutes les variables (sumbole différent pour les variables supplémentaires)

推荐阅读