Randomized statistics and dotplot
By permuting the home ownership variable multiple times, you generate differences in proportions that are consistent with the assumption that the variables are unrelated. The statistic of interest is the difference in proportions given by stat = "diff in props"
. After calculating the randomized statistics, you will plot them in a dotplot.
This exercise shows all four 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.calculate
will calculate summary statistics.
Each step will be covered throughout the course; in this exercise you'll write code for calculate()
.
The dplyr
, ggplot2
, NHANES
, and infer
packages have been loaded for you. Repeat the permuting and plotting with 100 differences in proportions generated by shuffling the HomeOwn
variable.
Este exercício faz parte do curso
Foundations of Inference in R
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
# Perform 100 permutations
homeown_perm <- homes %>%
specify(HomeOwn ~ Gender, success = "Own") %>%
hypothesize(null = "independence") %>%
generate(reps = 100, type = "permute") %>%
___(___, order = ___)
# Print results to console
homeown_perm