以下分析用到package vcd中的Arthritis数据集
library(vcd)
attach(Arthritis)
卡方检验(Chi-squrae test)
mytable <- xtabs(~Treatment+Improved, data = Arthritis)
chisq.test(mytable)
Fisher's exact test
fisher.test(mytable)
Cochran-Mantel-Haenszel test
mantelhaen.test(mytable)
根据生成的报告中的p值判断变量之间是否存在独立。
网友评论