Get startedGet started for free

Building two null distributions

To get a sense of the full distribution that the chi-squared test statistic can take under this hypothesis, you need to generate many more datasets.

Do this by first adding onto your work from the previous exercise with the natspac variable, then conduct a second hypothesis test to see if party is independent of natarms. Once you have both null distributions, you can visualize them to see if they're consistent with your observed statistics.

This exercise is part of the course

Inference for Categorical Data in R

View Course

Hands-on interactive exercise

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

# Create null
___ <- gss_party %>%
  specify(natspac ~ party) %>%
  hypothesize(null = "independence") %>%
  generate(reps = ___, type = "permute") %>%
  calculate(stat = "Chisq")

# Visualize null
___ +
  # Add density layer
  ___ +
  # Add vertical line at obs stat
  ___
Edit and Run Code