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

Exercise

Do the data come from the population?

Recall that the observed difference (i.e. the difference in proportions in the homes dataset, shown as the red vertical line) was around -0.0078, which seems to fall below the bulk of the density of shuffled differences. It is important to know, however, whether any of the randomly permuted differences were as extreme as the observed difference.

In this exercise, you'll re-create this dotplot as a density plot and count the number of permuted differences that were to the left of the observed difference.

Instructions

100 XP

The homeown_perm dataset is available in your workspace.

  • Using geom_density(), plot the permuted differences.
  • Add a vertical red line with geom_vline() where the observed difference falls. diff_orig is provided in your workspace and represents the original value of the difference statistic.
  • Count the number of permuted differences that were less than or equal to the observed difference.