LoslegenKostenlos loslegen

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 statistic 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.

Diese Übung ist Teil des Kurses

Inference for Categorical Data in R

Kurs anzeigen

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

# 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("___", "___"))
Code bearbeiten und ausführen