Simulation-based t-test
In Chapter 2 you manually performed the steps for a t-test to explore these hypotheses.
\(H_{0}\): The mean weight of shipments that weren't late is the same as the mean weight of shipments that were late.
\(H_{A}\): The mean weight of shipments that weren't late is less than the mean weight of shipments that were late.
You can run the test more concisely using infer's t_test()
.
late_shipments %>%
t_test(
weight_kilograms ~ late,
order = c("No", "Yes"),
alternative = "less"
)
t_test()
assumes that the null distribution is normal. We can avoid assumptions by using a simulation-based non-parametric equivalent.
late_shipments
is available; dplyr
and infer
are loaded.
This exercise is part of the course
Hypothesis Testing in R
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# 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