Aan de slagGa gratis aan de slag

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.

Deze oefening maakt deel uit van de cursus

Hypothesis Testing in R

Cursus bekijken

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# 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
Code bewerken en uitvoeren