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"))`
This exercise is part of the course
Inference for Categorical Data in R
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Create the bootstrap distribution
___ <- gss2016 %>%
# Specify the variables and success
___ %>%
# Generate 500 bootstrap reps
___ %>%
# Calculate statistics
___