开始使用免费开始使用

计算相对误差

您抽取的样本大小会影响点估计对总体参数的刻画是否准确。比如,计算样本均值时,理想情况是它接近总体均值。然而,如果样本太小,往往达不到这个效果。

评估准确度最常用的度量是"相对误差"。它等于总体参数与点估计之差的绝对值,再除以总体参数。有时也会用百分比来表示。

已提供 attrition_popmean_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
编辑并运行代码