Administrator
|
We first need to make the two vectors: lower_vector and upper_vector.
So, run the following first:
population <- ames$Gr.Liv.Area
samp_mean <- rep(NA, 50)
n <- 60
pop_sd<-sd(population) # save population sd
for(i in 1:50){
samp <- sample(population, n) # obtain a sample of size n = 60 from the population
samp_mean[i] <- mean(samp) # save sample mean in ith element of samp_mean
}
lower_vector <- samp_mean - 1.96 * pop_sd / sqrt(n)
upper_vector <- samp_mean + 1.96 * pop_sd / sqrt(n)
Then, we can run the function:
plot_ci(lower_vector, upper_vector, mean(population))
Do you still have the error?
Then, let me know what kind of error you observe!
|