開始使用免費開始

兩樣本平均數檢定統計量

要檢驗兩個母體平均數是否不同,所用的檢定統計量和你在第 1 章看到的 z 分數不同。我們使用「t」,可由每個樣本的三個數值透過下列式子計算:

$$ t = \dfrac{(\bar{x}_{\text{child}} - \bar{x}_{\text{adult}})}{\sqrt{\dfrac{s_{\text{child}}^2}{n_{\text{child}}} + \dfrac{s_{\text{adult}}^2}{n_{\text{adult}}}}} $$

在分析為什麼有些出貨會延遲時,你可能會想知道,延遲出貨的重量是否與準時出貨的重量不同。late_shipments 資料集已經依 late == "Yes" 分成「yes」組,和依 late == "No" 分成「no」組。出貨重量記錄在 weight_kilograms 變數中。

為了方便起見,兩組的樣本平均數已提供為 xbar_noxbar_yes;樣本標準差為 s_nos_yes;樣本大小為 n_non_yes

本練習屬於課程

R 中的假設檢定

檢視課程

練習說明

  • 計算檢定統計量的分子。
  • 計算檢定統計量的分母。
  • 使用上述兩個數值計算檢定統計量。

動手互動練習

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

# Calculate the numerator of the test statistic
numerator <- ___

# Calculate the denominator of the test statistic
denominator <- ___

# Calculate the test statistic
t_stat <- ___

# See the result
t_stat
編輯並執行程式碼