Get startedGet started for free

Randomized data under null model of independence

The infer package will allow you to model a particular null hypothesis and then randomize the data to calculate permuted statistics. In this exercise, after specifying your null hypothesis you will permute the home ownership variable 10 times. By doing so, you will ensure that there is no relationship between home ownership and gender, so any difference in home ownership proportion for female versus male will be due only to natural variability.

This exercise will demonstrate the first three steps from the infer package:

  • specify will specify the response and explanatory variables.
  • hypothesize will declare the null hypothesis.
  • generate will generate resamples, permutations, or simulations.

The dplyr, ggplot2, NHANES, and infer packages have been loaded for you and the homes dataset you created in the last exercise is available in your workspace.

This exercise is part of the course

Foundations of Inference in R

View Course

Hands-on interactive exercise

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

# Specify variables
homeown_perm <- homes %>%
  ___(___ ~ ___, success = "___")

# Print results to console
homeown_perm
Edit and Run Code