1. Learn
  2. /
  3. Courses
  4. /
  5. Data Analysis and Statistical Inference

Exercise

Challenge (1)

To learn a bit more about how sample means and confidence intervals vary from one sample to another: a challenge!

Using R, we're going to recreate many samples using a for loop. Here is the rough outline:

  1. Obtain a random sample.
  2. Calculate the sample's mean and standard deviation.
  3. Use these statistics to calculate a confidence interval.
  4. Repeat steps (1)-(3) 50 times.

But let's start slowly by initializing the objects you'll use to store the means and standard deviations. We'll also store the desired sample size as n.

Instructions

100 XP
  • Initialize samp_mean and samp_sd with 50 NA values. (Use the rep() function.)
  • Set n to 60.