比較兩組獨立次序資料 (Two-Sample Test for Ordinal Data)
套路15: 比較兩組獨立次序資料 (Two-Sample Test for Ordinal Data)
1. 使用時機: 用於比較觀測到的兩組獨立次序資料(ordinal data)有無差異。
2. 分析類型: 無母數分析(non-parametric analysis)。
3. 前提假設: 兩組資料均為可排序(ordinal data)且彼此獨立。
4. 資料範例: 咪路比較前後兩班學生統計成績,資料如下:
2038級
|
A+
|
A
|
A
|
A-
|
B
|
B+
|
C+
|
C+
|
C
|
C
|
C-
|
D
|
D-
|
|
|
2048級
|
A
|
A
|
B+
|
B
|
B-
|
B-
|
C+
|
C
|
C
|
C
|
C-
|
C-
|
D+
|
D
|
D-
|
請問兩班學生統計成績是否有差異? H0: 兩班學生統計成績沒差異,HA: 兩班學生統計成績有差異。
5. 輸入建立資料:
第一步: 將A+ … D- 轉換成排序(rank)
# A+ A
A- B+ B
B- C+ C
C- D+ D D-
# 1 2
3 4 5 6
7 8 9 10 11 12
第二步: 用小c將資料放入名稱為x及y的vector (R最基本資料結構)。
#
x<-c("A","A","A","A-","B","B","C+","C+","C","C","C-")
x<-c(2,2,2,3,5,5,7,7,8,8,9)
#
y<-c("A","A","B+","B+","B","B-","C","C","C-","D","D","D","D","D-")
y<-c(2,2,4,4,5,6,8,8,9,11,11,11,11,12)
6. 使用R計算兩組獨立樣本曼恩-惠尼U檢定:
第一步: 閱讀基本模組(base)中的wilcox.test函數的使用說明。
help(wilcox.test)
第二步: 使用基本模組(base)中的wilcox.test函數代入x及y資料。
wilcox.test(x, y,
alternative = "two.sided", paired = FALSE, conf.level = 0.95)
# paired = FALSE不是成對資料檢定。
# alternative =
"two.sided" 執行雙尾檢定。
第三步: 判讀結果。
Wilcoxon rank sum test with continuity correction
data: x and y
W = 48.5, p-value = 0.1219 #
p-value > 0.05,H0: 兩班學生統計成績沒差異,成立。
alternative hypothesis: true location shift is not equal to 0
# p-value < 0.05,H0: 兩班學生統計成績沒差異,不成立。
# p-value > 0.05,H0: 兩班學生統計成績沒差異,成立。
來勁了嗎? 想知道更多?? 補充資料(連結):
1. Henry Mann (https://en.wikipedia.org/wiki/Henry_Mann)
2. Frank Wilcoxon (https://en.wikipedia.org/wiki/Frank_Wilcoxon)
3. Talk:Mann–Whitney U test (https://en.wikipedia.org/wiki/Talk:Mann%E2%80%93Whitney_U_test)
4. Mann-Whitney U Test,Wilcoxon Rank Sum Test (https://en.wikipedia.org/wiki/Mann%E2%80%93Whitney_U_test)
5. Statistical hypothesis testing (https://en.wikipedia.org/wiki/Statistical_hypothesis_testing)
6. Test statistic (https://en.wikipedia.org/wiki/Test_statistic)
7. 關於R基礎,R繪圖及統計快速入門:
a. R Tutorial: https://www.tutorialspoint.com/r/index.htm
b. Cookbook for R: http://www.cookbook-r.com/
c. Quick-R: https://www.statmethods.net/
d. Statistical tools
for high-throughput data analysis (STHDA): http://www.sthda.com/english/
e. The Handbook of Biological Statistics: http://www.biostathandbook.com/
f. An R Companion for the Handbook of
Biological Statistics: http://rcompanion.org/rcompanion/index.html
8. Zar, JH. 2010. Biostatistical Analysis, Fifth Edition,
Pearson.
留言
張貼留言