效果量

Python 推論基礎

Paul Savala

Assistant Professor of Mathematics

什麼是效果量?

一位醫生拿著被折斷的香菸。

  • 效果量:兩個變數關係強度的度量

各式各樣的垃圾食物。

Python 推論基礎

為何要衡量效果量

  • 衡量關聯強度
  • 抽菸:效果量大
  • 飲食不佳:效果量小
Python 推論基礎

P-Values

 

  • 是否存在關係?
  • 來自假設檢定

Effect size

 

  • 關係有多強?
  • 獨立於假設檢定
Python 推論基礎

平均數的效果量-Cohen 的 d

$n_1 = \text{Sample size of group one}$

$n_2 = \text{Sample size of group two}$

$s_1 = \text{Standard deviation of group one}$

$s_2 = \text{Standard deviation of group two}$

$\overline{x}_1 = \text{Mean of group one}$

$\overline{x}_2 = \text{Mean of group two}$

$s = \displaystyle\sqrt{\frac{\frac{(n_1-1)s_1^2 + (n_2-1)s_2^2}{}}{n_1 + n_2 - 2}}$

Cohen's $d = \displaystyle\frac{\overline{x}_1 - \overline{x}_2}{s}$

Python 推論基礎

解讀 Cohen 的 d

  • 0.01-極小
  • 0.20-小
  • 0.50-中等
  • 0.80-大
  • 1.20-極大

Cohen 的 $d = 0.6$

介於中等至大型效果量

1 https://books.google.com/books?id=2v9zDAsLvA0C&pg=PP1 https://doi.org/10.22237%2Fjmasm%2F1257035100
Python 推論基礎

相關的效果量

r, p_value = stats.pearsonr(
    btc_sp_df['Close_BTC'], 
    btc_sp_df['Close_SP500']
    )

print(r**2)
0.82

$R^2:$ 由一個變數可解釋另一個變數變異的百分比

散佈圖:x 軸為 S&P 500 收盤價,y 軸為比特幣收盤價。圖形大致線性且正斜率。

Python 推論基礎

類別變數的效果量

  • $\chi^2$ = 列聯表的卡方統計量
  • $n$ = 資料點總數
  • $d$ = 自由度 = $min(\text{rows}-1, \text{cols}-1)$

Cramer 的 $V = \displaystyle\sqrt{\frac{\chi^2/n}{d}}$

Python 推論基礎

計算 Cramer 的 V

chi2, p, d, e = stats.chi2_contingency(
    contingency_table)

dof = min(6-1, 2-1) = 1 n = 3394
v = np.sqrt((chi2 / n) / dof)
v = 0.52

一個表格,列出男女與職稱,顯示每個職稱的男性與女性人數。

1 https://en.wikipedia.org/wiki/Degrees_of_freedom_(statistics)
Python 推論基礎

解讀 Cramer 的 V

Cramer's V = 0.52, Degrees of Freedom = 1

一個表格,列出自由度 1 到 5,以及對應小型、中型、大型效果量所需的 Cramer 的 V 值。小型為 0.1、0.07、0.06、0.05、0.04;中型為 0.3、0.21、0.17、0.15、0.13;大型為 0.5、0.35、0.29、0.25、0.22。

1 https://www.statology.org/interpret-cramers-v
Python 推論基礎

一起來練習吧!

Python 推論基礎

Preparing Video For Download...