看板 R_Language 關於我們 聯絡資訊
[軟體熟悉度]: 入門(寫過其他程式,只是對語法不熟悉) [問題敘述]: 想利用R跑卡方檢定,並算出phi值,使用vcd library中的assocstats()計算 但跑任何卡方,跑出來Phi-Coefficient值都是NA, 但在SPSS可以跑出來是,例如下面這個可以算出是0.206 [程式範例]: #all$newage與all$part2D_6為兩個類別變項 assocstats(table(all$newage,all$part2D_6)) 執行結果: X^2 df P(> X^2) Likelihood Ratio 20.709 4 0.00036158 Pearson 20.667 4 0.00036861 Phi-Coefficient : NA Contingency Coeff.: 0.202 Cramer's V : 0.206 [環境敘述]: R version 3.3.2 (2016-10-31) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows >= 8 x64 (build 9200) [1] vcd_1.4-3 [關鍵字]: 卡方檢定 vcd assocstats() -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.112.25.100 ※ 文章網址: https://www.ptt.cc/bbs/R_Language/M.1496065793.A.F6F.html
celestialgod: 當你的table不是2 x 2就會是NA 05/29 22:02
celestialgod: The absolute value of the phi coefficient (only 05/29 22:03
celestialgod: defined for 2 x 2 tables). 05/29 22:03
celestialgod: 請確定你的table是 2 x 2 05/29 22:03
celestialgod: 看你的自由度應該是 3 x 3 05/29 22:03
celestialgod: 第二個推文是出自assocstats的manual 05/29 22:04
celestialgod: 如果SPSS跑得出來要看一下它的phi是怎麼計算的 05/29 22:05
celestialgod: 我看wiki Phi只有在2 x 2有定義 05/29 22:05
tcssh611503: 阿,原來如此,感謝!!! 真得只能在2X2用 05/29 22:15