Session Ready
Exercise

Hypothesis tests and confidence intervals

As was mentioned at the very beginning of this chapter, there is a close link between hypothesis tests and confidence intervals. The former explores whether a particular hypothesis about the world is consistent with your data. The latter has no hypothesis, it simply quantifies your uncertainty in your point estimate by adding and subtracting the margin of error.

In this exercise you will explore the duality by forming a confidence interval around the difference in proportions, d_hat. To get you started, here is the code that you used to form the null distribution:

# Reference code for null distribution
null <- gss2016 %>%
   specify(cappun ~ sex, success = "FAVOR") %>%
   hypothesize(null = "independence") %>%
   generate(reps = 500, type = "permute") %>%
   calculate(stat = "diff in props", order = c("FEMALE", "MALE"))`
Instructions 1/2
undefined XP
  • 1
  • 2

Adapt the code used to form the null distribution for hypothesis test to form the bootstrap distribution for use in a confidence interval.

  • Remove the hypothesis step.
  • Change the generation type to "bootstrap".
  • Save it as boot.