r - R 中的三向卡方检验

标签 r testing statistics

我有如下分类数据:

gender age_group diagnosis
male     young    x
female   child    y
female   adult    x
male     old      z

gender, age_group and diagnosis have 2, 4 and 3 levels respectively. 

我想进行一个卡方检验来查看两个类别之间的关系。我怎么能在 R 中做到这一点

最佳答案

三维列联表的适当测试是 Cochran-Mantel-Haenszel test我相信。为了使用它,您需要将数据转换为三维数组,并确保生成的列联表中每个可能的 stratum 的频率 > 1。

# convert data to contigency table
df <- table(data)

# run test
mantelhaen.test(df)

关于r - R 中的三向卡方检验,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34750987/

相关文章:

java - 在 junit 测试运行时模拟物理 Web 服务器

performance - 性能测量的建模分布

python - 如何在 Python 中确定相关系数?

R:基于行过滤器创建多个数据框

r - 用不平等来约束规范

testing - 自动刷新浏览器以响应文件系统更改?

python - python中的无偏方差估计(n-1)模拟失败

r - 使用 purrr 映射将函数应用于 dplyr 管道中 DataFrame 中列的选择

r - 有效地从矩阵列中减去

unit-testing - 如何测试科学软件?