CommencerCommencer gratuitement

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.

Cet exercice fait partie du cours

Inference for Categorical Data in R

Afficher le cours

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de 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
  ___
Modifier et exécuter le code