2017年10月30日 星期一

計數資料的檢驗 (Testing of categorical data)

    承接上一個內容, 以前我在讀研的時候老師只是說: 當分組資料和變量都是計數資料(categorical data)時, 如2x2表或RxC表, 就是用卡方檢驗, 直至讀博時都是這樣~ 但最近了解到, 這樣的情況還可用G test來解決, 而且據知它的理論與算法比卡方檢驗還更好!?(因為G test的算法比較簡單, 所以校正就較方便快捷; 理論上就較具優勢!~) 當然, 算G.test, 以我知暫時仍是R統計軟件才有.

    如上次的例子,
                有效    無效
靜脈注射   25       7
肌肉注射   22       10
口  服  藥   15        17

    在R進行卡方檢驗, 結果是


        Pearson's Chi-squared test
data:  dat
X-squared = 7.1954, df = 2, p-value = 0.02739

    而在R進行G test, 須先下載它的程式 (幸好已有人寫好, 並放在網上!), 只要把程式貼到R軟件並運行即可... 其結果是:
G-Test for Contingency Tables
Data:
         有效 無效
靜脈注射   25    7
肌肉注射   22   10
口服藥     15   17
The test statistic is  7.19124 .
There are  2  degrees of freedom.
The p-value is  0.02744362 .


參考內容:
1. http://www.stat.wisc.edu/~st571-1/gtest.R
2. http://www.biostathandbook.com/gtestind.html

1 則留言:

  1. Hard Rock Hotel & Casino Reno - MapyRO
    Welcome to Hard Rock 김포 출장안마 Hotel 속초 출장마사지 & 양주 출장마사지 Casino Reno! Experience award wining gaming, luxury accommodations, a world-class gaming 의왕 출장샵 venue with new events 서울특별 출장마사지 and

    回覆刪除