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:
- Obtain a random sample.
- Calculate the sample's mean and standard deviation.
- Use these statistics to calculate a confidence interval.
- 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
.
This exercise is part of the course
Data Analysis and Statistical Inference
Exercise instructions
- Initialize
samp_mean
andsamp_sd
with 50NA
values. (Use therep()
function.) - Set
n
to 60.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# The ames data frame is already loaded into the workspace
# Initialize samp_mean, samp_sd and n:
samp_mean <-
samp_sd <-
n <-