Hypothesis test on the difference in proportions
In the last exercise you learned that about 52% of women favor the death penalty while about 63% of men do, a difference of about 11 percentage points. That seems like a large difference, but what if it's just due to chance and in fact there is no relationship between sex and support for the death penalty? Find out by testing the null hypothesis that sex and support for the death penalty are independent of one another.
The stat
istic that you'll be using in this exercise is a "diff in props"
, which requires that you specify the order of the difference by adding an argument, order = c("FIRST", "SECOND")
, where first and second refer to the group names. This results in the calculation: FIRST - SECOND.
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 null distribution
___ <- gss2016 %>%
# Specify the response and explanatory as well as the success
___(___ ~ ___, success = "___") %>%
# Set up null hypothesis
___(null = "___") %>%
# Generate 500 reps by permutation
___(___ = ___, ___ = "___") %>%
# Calculate the statistics
___(stat = ___, order = c("___", "___"))