HW 6 Part 2

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

HW 6 Part 2

Madisyn Eppleman
How do you set up question one on RStudio and when I plug in that function given, I get an error. Thank you!
Reply | Threaded
Open this post in threaded view
|

Re: HW 6 Part 2

Taeho Kim
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!