我想使用在R中实现的Chi-Squared测试来测试许多分类变量的依赖性。实际上,我有14个变量,并且对所有变量进行14 * 14测试的时间很长。如你所知,当我需要测试TYPE_PEAU
和SENSIBILITE
之间的依赖关系时,Chi-Squared测试只关注在正常情况下对两个变量进行测试。
> library(MASS)
> tbl = table(DATA_BASE$TYPE_PEAU, DATA_BASE$SENSIBILITE)
> chisq.test(tbl)
Pearson's Chi-squared test
data: tbl
X-squared = 5727.5, df = 12, p-value < 2.2e-16
假设我有14个变量,我该如何处理它们?
这是包含分类变量的关注数据集,希望有助于解决问题
> dput(DATA_BASE[1:50,15:18])
structure(list(TYPE_PEAU = structure(c(3L, 4L, 5L, 1L, 3L, 1L,
1L, 1L, 3L, 1L, 1L, 1L, 4L, 3L, 1L, 3L, 1L, 3L, 3L, 3L, 1L, 1L,
1L, 3L, 1L, 1L, 3L, 1L, 3L, 5L, 1L, 5L, 2L, 1L, 5L, 5L, 3L, 1L,
3L, 1L, 1L, 1L, 1L, 3L, 1L, 1L, 1L, 1L, 3L, 1L), .Label = c("",
"Grasse", "Mixte", "Normale", "Sèche"), class = "factor"), SENSIBILITE = structure(c(4L,
4L, 4L, 1L, 3L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 4L, 4L, 1L, 3L, 1L,
3L, 3L, 4L, 1L, 1L, 1L, 2L, 1L, 1L, 4L, 1L, 2L, 3L, 1L, 4L, 4L,
1L, 3L, 4L, 4L, 1L, 4L, 1L, 1L, 1L, 1L, 4L, 1L, 1L, 1L, 1L, 4L,
1L), .Label = c("", "Aucune", "Fréquente", "Occasionnelle"), class = "factor"),
IMPERFECTIONS = structure(c(3L, 4L, 3L, 1L, 2L, 1L, 1L, 1L,
4L, 1L, 1L, 1L, 3L, 3L, 1L, 2L, 1L, 3L, 2L, 3L, 1L, 1L, 1L,
4L, 1L, 1L, 3L, 1L, 3L, 2L, 1L, 4L, 3L, 1L, 3L, 3L, 3L, 1L,
2L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 3L, 1L), .Label = c("",
"Fréquente", "Occasionnelle", "Rares"), class = "factor"),
BRILLANCE = structure(c(4L, 2L, 2L, 1L, 4L, 1L, 1L, 1L, 4L,
1L, 1L, 1L, 4L, 4L, 1L, 4L, 1L, 4L, 4L, 4L, 1L, 1L, 1L, 4L,
1L, 1L, 4L, 1L, 4L, 4L, 1L, 2L, 3L, 1L, 4L, 4L, 4L, 1L, 4L,
1L, 1L, 1L, 1L, 4L, 1L, 1L, 1L, 1L, 4L, 1L), .Label = c("",
"Aucune", "Partout", "Zone T"), class = "factor")), .Names = c("TYPE_PEAU",
"SENSIBILITE", "IMPERFECTIONS", "BRILLANCE"), row.names = c(15L,
22L, 33L, 40L, 48L, 54L, 59L, 65L, 74L, 78L, 87L, 89L, 104L,
108L, 115L, 121L, 141L, 159L, 161L, 163L, 165L, 175L, 179L, 186L,
196L, 202L, 211L, 222L, 231L, 265L, 272L, 290L, 300L, 318L, 325L,
327L, 349L, 372L, 374L, 380L, 392L, 393L, 394L, 398L, 427L, 440L,
449L, 450L, 456L, 470L), class = "data.frame")
提前谢谢