適合度檢定 (goodness of fit test)

套路31: 適合度檢定
(Cressie-Read power divergence statistic and 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.power_divergence(f_obs, f_exp, lambda_= "log-likelihood")
結果:
Power_divergenceResult(statistic=11.20041316315793, pvalue=0.010690089463184418)
# p = 0.0107 < 0.05H0: 黃色圓皮黃色皺皮綠色圓皮及綠色皺皮碗豆比例為9:3:3:1不成立。
# 反之如果p > 0.05H0: 黃色圓皮黃色皺皮綠色圓皮及綠色皺皮碗豆比例為9:3:3:1成立。

# lambda_ 有下列選項:
# String              Value   Description
# "pearson"             1     Pearson's chi-squared statistic.
#                             In this case, the function is equivalent to `stats.chisquare`.
# "log-likelihood"      0     Log-likelihood ratio. Also known as the G-test.
# "freeman-tukey"      -1/2   Freeman-Tukey statistic.
# "mod-log-likelihood" -1     Modified log-likelihood ratio.
# "neyman"             -2     Neyman's statistic.
# "cressie-read"        2/3   The power recommended.

留言

這個網誌中的熱門文章

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

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

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