1. Learn
  2. /
  3. Courses
  4. /
  5. HarvardX Data Science Module 4 - Inference and Modeling

Exercise

Exercise 6. Multiple plots of se versus p

Using the same code as in the previous exercise, create a for-loop that generates three plots of p versus se when the sample sizes equal \(N = 25\), \(N = 100\), and \(N = 1000\).

Instructions

100 XP
  • Your for-loop should contain two lines of code to be repeated for three different values of N.
  • The first line within the for-loop should use the sqrt function to generate a vector of standard errors se for all values of p.
  • The second line within the for-loop should use the plot function to generate a plot with p on the x-axis and se on the y-axis.
  • Use the ylim argument to keep the y-axis limits constant across all three plots. The lower limit should be equal to 0 and the upper limit should equal 0.1 (it can be shown that this value is the highest calculated standard error across all values of p and N).