重複抽樣
當你計算像是樣本平均數這樣的點估計時,結果會取決於樣本中包含了哪些列。也就是說,答案含有隨機性。為了量化這種隨機性造成的變異,你可以建立許多樣本,並為每個樣本計算樣本平均數(或其他統計量)。
已提供 attrition_pop;dplyr 與 ggplot2 已載入。
本練習屬於課程
R 的抽樣
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Replicate this code 500 times
attrition_pop %>%
slice_sample(n = 20) %>%
summarize(mean_attrition = mean(Attrition == "Yes")) %>%
pull(mean_attrition)
# See the result
head(mean_attritions)