如何用二元(二分)预测变量绘制多重对应分析的置信椭圆?

时间:2015-12-17 21:39:47

标签: r

当我试图用MCA中的95%置信度预测时,我遇到了一些麻烦。以下是我的数据和代码中的示例。

CONSTRUCTION<-c("in plaats van", "ten opzichte van", "met behulp van", "ten koste van", "op grond van", "onder leiding van", "in tegenstelling tot", "op basis van")
IDIOSYNC<-c("no", "yes", "yes", "yes", "no", "no", "no", "no")
ARTICLE<-c("yes", "no", "no", "no", "no", "no", "no", "no")
PLURAL<-c("no", "no", "no", "no", "no", "no", "no", "no")
MODIF<-c("no", "no", "no", "no", "no", "yes", "yes", "no")
EXTRAPOS<-c("yes", "no", "no", "yes", "no", "yes", "yes", "no")
COMPLEM<-c("no", "no", "no", "no", "no", "yes", "no", "no")
P2OPTION<-c("no", "no", "no", "no", "no", "yes", "no", "no")
P1CHBL<-c("no", "no", "no", "no", "no", "no", "no", "no")
P2CHBL<-c("no", "no", "no", "no", "no", "no", "yes", "no")

data.comp.prep<-cbind(CONSTRUCTION, IDIOSYNC, ARTICLE, PLURAL, MODIF, EXTRAPOS, COMPLEM, P2OPTION, P1CHBL, P2CHBL)

ca.comp.prep<-MCA(data.comp.prep[, -c(1, 4, 9)], graph=FALSE)
plot(ca.comp.prep, cex=0.7, col.var="black", col.ind="grey")
ca.comp.prep1<-MCA(data.comp.prep[, -c(4, 9)], quali.sup=1, graph=FALSE)
plot(ca.comp.prep1, invis="ind", col.var="darkgrey", col.quali.sup="black")

当我运行用于绘制省略号的代码时,会出现问题:

plotellipses(ca.comp.prep1[, -c(4, 9)], keepvar=1, label="quali")
Error in ca.comp.prep1[, -c(4, 9)] : incorrect number of dimensions

我没有看到问题的来源,我是(M)CA的新人。

1 个答案:

答案 0 :(得分:0)

ca.comp.prep1是包含MCA结果的列表。您试图将其编入索引,就像它是具有两个维度的data.frame一样。 [,c(4,9)]在这里是非感性的。

然后,您尝试为ca.comp.prep1的第一个变量绘制省略号,这基本上是一个行ID(每个人的值都不同)。没有椭圆是可能的,因为每个类别只有一个点。

我的建议是你不应该在MCA中添加第一个变量;继续学习ca.comp.prep并忘记ca.comp.prep1。然后绘制省略号:

plotellipses(ca.comp.prep, keepvar=1, label="quali")

如果你仍想在ca.comp.prep1上完成,请尝试另一个变量:

plotellipses(ca.comp.prep1, keepvar=2, label="quali")