卡方检验
> library(vcd)
> mytable
> chisq.test(mytable)
Pearson's Chi-squared test
data: mytable
X-squared = 13.055, df = 2, p-value = 0.001463
#由上述的内容可以看出:本次检验治疗和改善之后的效果是否与原有的效果显著,由于p=0.001,小于显著性水平,拒绝原假设,接受对立假设,效果是显著的。
> mytable
> chisq.test(mytable)
Pearson's Chi-squared test
data: mytable
X-squared = 4.8407, df = 2, p-value = 0.08889
#这里是在探究改善与性别的和效果与原有效果的显著性,而结果大于显著性水平,因此是不显著的。
Warning message:
In chisq.test(mytable) : Chi-squared近似算法有可能不准
#这里是系统自动的提示,毕竟表格中有一个小于5的值,对结果是有影响的
Fisher精确检验
> mytable
> fisher.test(mytable)
Fisher's Exact Test for Count Data
data: mytable
p-value = 0.001393
alternative hypothesis: two.s