視覺化 p-hat 的變異性
為了比較前面練習中抽樣得到的 \(\hat{p}\) 與 \(\hat{p}^*\) 的變異性,把它們的分配視覺化會很有幫助。回顧一下,這些練習帶你走過兩個用來研究 \(\hat{p}\) 與 \(\hat{p}^*\) 變異性的實驗:
- 實驗 1:從極大母體中反覆抽樣($n = 30$)(理論上的黃金標準,但不切實際)
- 實驗 2:從單一樣本(樣本大小 30)以放回方式反覆重抽($n = 30$)
本練習屬於課程
R 統計推論基礎
練習說明
- 使用
bind_rows()合併兩個實驗的資料,傳入ex1_props與ex2_props。將結果命名為both_ex_props。會建立名為experiment的資料集 ID 欄。 - 以
both_ex_props為資料,繪製以experiment著色的stat圖。 - 使用
geom_density()加上機率密度曲線,並將頻寬參數bw設為0.1。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Combine data from both experiments
both_ex_props <- ___(___, ___, .id = "experiment")
# Using both_ex_props, plot stat colored by experiment
ggplot(___, aes(___, color = ___)) +
# Add a density layer with bandwidth 0.1
___(bw = ___)