開始使用免費開始

計算 p 值

在影片中,你學到 p 值用來衡量資料與虛無假設之間的分歧程度。這裡你要為原始歧視資料集,以及其小型與大型版本 disc_smalldisc_big 計算 p 值。

工作區中已提供原始比例差:diff_origdiff_orig_smalldiff_orig_big,以及對應的置換後資料集:disc_permdisc_perm_smalldisc_perm_big

請記得這裡只關注單尾檢定。也就是說,你要回答的問題是:「男性被升遷的機率是否高於女性?」

本練習屬於課程

R 統計推論基礎

檢視課程

練習說明

  • 使用內建的 infer 函式 visualize()get_p_value()。記住虛無分佈的統計量位在原始差異之下,因此 p 值(代表虛無值比原始統計更「極端」的頻率)要以「虛無值大於原始差異」的次數來計算。
  • 對小型資料集 disc_perm_small 重複上述步驟,它的觀察差異是 diff_orig_small
  • 對大型資料集 disc_perm_big 重複上述步驟,它的觀察差異是 diff_orig_big
  • 你也可以在送出答案前試試看不同方向設定:direction = "greater"direction = "two_sided"direction = "less"

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Visualize and calculate the p-value for the original dataset
disc_perm %>%
  ___(obs_stat = ___, direction = "___")

disc_perm %>%
  ___(___, ___)

# Visualize and calculate the p-value for the small dataset
___ %>%
  ___(___, ___)

___ %>%
  ___(___, ___)

# Visualize and calculate the p-value for the big dataset
___ %>%
  ___(___, ___)

___ %>%
  ___(___, ___)
編輯並執行程式碼