開始使用免費開始

以模擬為基礎的 t 檢定

在第 2 章中,你曾手動依序執行 t 檢定的步驟,來檢驗下列假設:

$H_{0}$:未延遲出貨的平均重量與延遲出貨的平均重量相同。

$H_{A}$:未延遲出貨的平均重量小於延遲出貨的平均重量。

你也可以用 infer 的 t_test() 更精簡地執行檢定。

late_shipments %>% 
  t_test(
    weight_kilograms ~ late,
    order = c("No", "Yes"),
    alternative = "less"
  )

t_test() 假設虛無分佈為常態。我們可以使用以模擬為基礎的非參數檢定來避免這些假設。

已提供 late_shipments;且已載入 dplyrinfer

本練習屬於課程

R 中的假設檢定

檢視課程

動手互動練習

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

# Fill out the null distribution pipeline
null_distn <- late_shipments %>% 
  # Specify weight_kilograms vs. late
  ___ %>% 
  # Declare a null hypothesis of independence
  ___ %>% 
  # Generate 1000 permutation replicates
  ___ %>% 
  # Calculate the difference in means ("No" minus "Yes")
  ___

# See the results
null_distn
編輯並執行程式碼