開始使用免費開始

比較比例差異的假設檢定

在上一個練習中,你得知大約有 52% 的女性贊成死刑,而男性約有 63% 贊成,差了約 11 個百分點。這看起來差異不小,但如果這只是隨機造成的,而事實上性別與是否支持死刑之間沒有關係呢?透過檢定虛無假設(性別與是否支持死刑彼此獨立)來找出答案。

你在本練習中要使用的 stat"diff in props",這需要你用參數 order = c("FIRST", "SECOND") 指定計算的「先減後」順序,其中 FIRST 與 SECOND 代表群組名稱。計算式為:FIRST - SECOND。

本練習屬於課程

R 中的類別資料推論

檢視課程

動手互動練習

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

# Create null distribution
___ <- gss2016 %>%
  # Specify the response and explanatory as well as the success
  ___(___ ~ ___, success = "___") %>%
  # Set up null hypothesis
  ___(null = "___") %>%
  # Generate 500 reps by permutation
  ___(___ = ___, ___ = "___") %>%
  # Calculate the statistics
  ___(stat = ___, order = c("___", "___"))
編輯並執行程式碼