開始使用免費開始

假想母體-x 方向的變異更小

為了理解斜率係數的抽樣分配,將樣本與母體的變動如何影響斜率係數視覺化非常有幫助。這裡,我們讓「解釋變數」沿著直線的變異變小,進而改變與斜率統計量相關的變異程度。

本練習屬於課程

R 中的線性迴歸推論

檢視課程

練習說明

  • 先看看為你繪好的圖。
  • 在抽樣的程式碼中,把 popdata 換成 even_newer_popdata,並重新繪圖。
  • 將 x 軸範圍設為 -17 到 17(與先前相同)。
  • 再看看新圖。有哪裡不同?

動手互動練習

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

# Update the sampling to use even_newer_popdata
many_samples <- popdata %>%
  rep_sample_n(size = 50, reps = 100)

# Update and rerun the plot; how does it change?
ggplot(many_samples, aes(x = explanatory, y = response, group = replicate)) + 
  geom_point() + 
  geom_smooth(method = "lm", se = FALSE) +
  # Set the x-axis limit from -17 to 17
  ___
編輯並執行程式碼