以 t 區間進行估計

R 數值資料推論

Mine Cetinkaya-Rundel

Associate Professor of the Practice, Duke University

量化樣本平均數的變異

假設在隨機抽樣的 100 人中有 13 人是左撇子。若再抽一個 100 人的樣本,只有 12 人是左撇子會意外嗎?15 人呢?或是 30?1 或 90?

量化樣本平均數變異的方法:

  • 以自助法模擬

  • 用中央極限定理近似

R 數值資料推論

中央極限定理

$$ \bar{x} \sim N \left( mean = \mu, SE = \frac{\sigma}{\sqrt{n}} \right) $$

  • SE(標準誤)= 抽樣分配的標準差
  • $\sigma$ 未知:
    • $SE = \frac{s}{\sqrt{n}}$
    • 估計平均數時使用 $t_{df = n - 1}$ 推論
  • 僅在滿足特定條件時成立…
R 數值資料推論

條件

  1. 獨立觀測:不易檢查,但…
    • 隨機抽樣/隨機指派
    • 若為不放回抽樣,n < 總體的 10%
  2. 樣本大小/偏態:母體越偏態,所需樣本越大。
R 數值資料推論

平均數的信賴區間

使用 2010 年 General Social Survey(資料:gss)估計美國人超出平常排班加班的平均天數(變數:moredays)。

R 數值資料推論

平均數的信賴區間

使用 2010 年 General Social Survey(資料:gss)估計美國人超出平常排班加班的平均天數(變數:moredays)。

t.test(gss$moredays, conf.level = 0.95)
    One Sample t-test
data:  gss$moredays
t = 25.628, df = 1146, p-value < 2.2e-16
alternative hypothesis: true mean is not equal to 0
95 percent confidence interval:
 5.273367 6.147732
sample estimates:
mean of x 
 5.710549
R 數值資料推論

一起來練習吧!

R 數值資料推論

Preparing Video For Download...