基于模拟的 t 检验
在第 2 章中,您手动执行了 t 检验的各个步骤来检验以下假设。
$H_{0}$:未延迟发货的平均重量与延迟发货的平均重量相同。
$H_{A}$:未延迟发货的平均重量小于延迟发货的平均重量。
您可以使用 infer 的 t_test() 更简洁地运行该检验。
late_shipments %>%
t_test(
weight_kilograms ~ late,
order = c("No", "Yes"),
alternative = "less"
)
t_test() 假定原假设分布为正态分布。我们可以使用基于模拟的非参数等价方法来避免这些假设。
late_shipments 已可用;已加载 dplyr 和 infer。
本练习是课程的一部分
R 中的假设检验
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Fill out the null distribution pipeline
null_distn <- late_shipments %>%
# Specify weight_kilograms vs. late
___ %>%
# Declare a null hypothesis of independence
___ %>%
# Generate 1000 permutation replicates
___ %>%
# Calculate the difference in means ("No" minus "Yes")
___
# See the results
null_distn