r - 当我们有很多变量时如何处理测试依赖
问题描述
我想使用 R 中实现的卡方检验来测试许多分类变量的依赖关系。事实上,我有 14 个变量,对所有变量进行 14*14 测试非常长。如您所知,当我需要测试和之间的依赖关系时,卡方检验只关心在正常情况下对两个变量进行TYPE_PEAU
测试SENSIBILITE
。
> 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")
先感谢您
解决方案
推荐阅读
- machine-learning - 面对来自 Pixel Nerf 模型的 AssertionError
- swift - 无法通过 NavigationController 传递数据
- fastapi - 如何在 FastAPI 中启用 CORS?
- fortran - 在 Fortran90 中,是否可以将文件中的模块与主程序一起使用?
- php - 在我用 php 创建的 html 元素中编写 php if 语句
- javascript - 为什么我的纯功能组件呈现不同?
- json - 如何在 Typescript 中通过验证反序列化 JSON?
- python - 更改 Python 中字典的索引顺序
- image - 如何通过图像表达来操作像素值?
- html - 如何将 h1 文本移动到框的底部?