最も基礎的な検定として、分割表で独立性の検定をおこなう。関数chisq.test()を使用する。
まず、分割表を行列として読み込む。
> ct<- matrix(c(25,35,67,33),ncol=2,byrow=T)
> ct
[,1] [,2]
[1,] 25 35
[2,] 67 33
> chisq.test(ct)
Pearson's Chi-squared test with Yates' continuity correction
data: ct
X-squared = 8.8389, df = 1, p-value = 0.002949
連続性の修正をおこなわないならば、
> chisq.test(ct,correct=F)
まず、分割表を行列として読み込む。
> ct<- matrix(c(25,35,67,33),ncol=2,byrow=T)
> ct
[,1] [,2]
[1,] 25 35
[2,] 67 33
> chisq.test(ct)
Pearson's Chi-squared test with Yates' continuity correction
data: ct
X-squared = 8.8389, df = 1, p-value = 0.002949
連続性の修正をおこなわないならば、
> chisq.test(ct,correct=F)