Session Ready
Exercise

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 data sets.

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.

Instructions 1/2
undefined XP
  • 1
    • Extend your code from the previous exercise to generate 500 data sets under the null hypothesis that natspac is independent from party. Save this as null_spac.
    • Create a density plot of null_spac and add a vertical red line to indicate the location of the observed statistic (saved in your workspace as chi_obs_spac).
    • 2
      • Construct a similar null distribution under the hypothesis that natarms is independent from party using the "Chisq" statistic. Save this as null_arms.
      • Create a density plot of null_arms and add a vertical red line to indicate the location of the observed statistic (saved in your workspace as chi_obs_arms).