1. Learn
  2. /
  3. Courses
  4. /
  5. Foundations of Inference in R

Exercise

Visualizing the variability of p-hat

In order to compare the variability of the sampled \(\hat{p}\) and \(\hat{p}^*\) values in the previous exercises, it is valuable to visualize their distributions. To recall, the exercises walked through two different experiments for investigating the variability of \(\hat{p}\) and \(\hat{p}^*\):

  • Experiment 1: Sample (\(n = 30\)) repeatedly from an extremely large population (gold standard, but unrealistic)
  • Experiment 2: Resample (\(n = 30\)) repeatedly with replacement from a single sample of size 30

Instructions

100 XP
  • Combine data from both experiments by calling bind_rows(), passing ex1_props and ex2_props. Call this both_ex_props. A dataset ID column named experiment will be created.
  • Using both_ex_props, plot stat colored by experiment.
  • Add a density curve using geom_density(), setting the bandwidth argument, bw, to 0.1.