Exercise

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.

Instructions 1/3

undefined XP
    1
    2
    3
  • Specify weight in kilograms versus whether or not the shipment was late.
  • Declare a null hypothesis of independence.
  • Generate 1000 permutation replicates.
  • Calculate the difference in means, setting the order as "No" minus "Yes".