Kruskal-Wallis單因子方差分析
阿新 • • 發佈:2019-01-04
如果你在進行多個群組之間比較時,因為群組不滿足正態分佈而不能使用ANOVA多比較,那麼你可以使用Kruskal-Wallis檢驗。該檢驗類似於前面兩個樣本的Wilcox檢驗。
假設你想看看以下4個數值集合的均值是否統計相似:
Group A: 1, 5, 8, 17, 16
Group B: 2, 16, 5, 7, 4
Group C: 1, 1, 3, 7, 9
Group D: 2, 15, 2, 9, 7
為使用Kruskal-Wallis的檢驗,只要簡單地輸入資料,然後將它們再組織成一個list:
a = c(1, 5, 8, 17, 16) b = c(2, 16, 5, 7, 4) c = c(1, 1, 3, 7, 9) d = c(2, 15, 2, 9, 7) dati = list(g1=a, g2=b, g3=c, g4=d)
現在我們直接使用kruskal.test()函式:
kruskal.test(dati)
Kruskal-Wallis rank sum test
data: dati
Kruskal-Wallis chi-squared = 1.9217, df = 3, p-value = 0.5888
p-value大於0.05;並且檢驗統計的值1.9217也比chi-square的查表值低:
qchisq(0.950, 3)
[1] 7.814728
因此結論就是我們接受null hypothesis H0,即4個群組的均值統計相等。