Get startedGet started for free

Observed statistic and p-value

You now have a null distribution. In order to get a p-value and weigh up the evidence against the null hypothesis, you need to calculate the difference in proportions that is observed in the late_shipments sample.

late_shipments is available; dplyr, infer, and ggplot2 are loaded.

This exercise is part of the course

Hypothesis Testing in R

View Course

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

null_distn <- late_shipments %>% 
  specify(
    late ~ freight_cost_group, 
    success = "Yes"
  ) %>% 
  hypothesize(null = "independence") %>% 
  generate(reps = 2000, type = "permute") %>% 
  calculate(
    stat = "diff in props", 
    order = c("expensive", "reasonable")
  )

# Copy, paste, and modify the pipeline to get the observed statistic
obs_stat <- ___









# See the result
obs_stat
Edit and Run Code