計算相對誤差
你抽樣的大小會影響點估計值對應母體參數的準確程度。以計算樣本平均數為例,你會希望它接近母體平均數。然而,如果樣本太小,就可能做不到。
評估準確度最常見的指標是「相對誤差」。它等於母體參數與點估計值的絕對差,再除以母體參數。有時會以百分比表示。
已提供 attrition_pop 與 mean_attrition_pop;已載入 dplyr。
本練習屬於課程
R 的抽樣
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Generate a simple random sample of 10 rows
attrition_srs10 <- ___
# Calculate the proportion of employee attrition in the sample
mean_attrition_srs10 <- ___
# Calculate the relative error percentage
rel_error_pct10 <- ___
# See the result
rel_error_pct10