卡方適合度檢定 (Chi-square Goodness of fit test)

套路30: 卡方適合度檢定 (Chi-square Goodness of fit test)

1. 使用時機:卡方適合度檢定用來分析數據之分佈型(distribution)或符合某種比例。
2. 分析類型: 母數分析(parametric analysis)
3. 資料範例:
夢得爾葛格計數黃色圓皮黃色皺皮綠色圓皮及綠色皺皮碗豆資料如下:
性狀
黃色圓皮
黃色皺皮
綠色圓皮
綠色皺皮
總數
觀察值
152
39
53
6
250
期望值
(9/16) x 250
(3/16) x 250
(3/16) x 250
(1/16) x 250


= 140.6
= 46.8
= 46.8
= 15.6

試問黃色圓皮黃色皺皮綠色圓皮及綠色皺皮碗豆比例是否為9:3:3:1?
H0: 黃色圓皮黃色皺皮綠色圓皮及綠色皺皮碗豆比例為9:3:3:1
HA: 黃色圓皮黃色皺皮綠色圓皮及綠色皺皮碗豆比例不是9:3:3:1

4. 使用Python計算卡方適合度檢定:
import scipy.stats
f_obs = [152,39,53,6]
f_exp = [140.6,46.8,46.8,15.6]
scipy.stats.chisquare(f_obs, f_exp)
結果:
Power_divergenceResult(statistic=8.953384153384155, pvalue=0.02991713317223723)
# p = 0.0299 < 0.05H0: 黃色圓皮黃色皺皮綠色圓皮及綠色皺皮碗豆比例為9:3:3:1不成立。
# 反之如果p > 0.05H0: 黃色圓皮黃色皺皮綠色圓皮及綠色皺皮碗豆比例為9:3:3:1成立。

留言

這個網誌中的熱門文章

三因子變異數分析 (Three-Way ANOVA)

兩組獨立樣本變異數相同 t 檢定 (Two-Sample t test with equal variances,parametric)

雙因子變異數分析 (Two-Way ANOVA)