Administrator
|
Hi Kelsi,
You've already tried several approaches.
It is not a time wasting because we learn things
when we try many different things.
Now for the question, let us take a look at that the following codes:
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)
plot_ci(lower_vector, upper_vector, mean(population))
If you run this code, then it will show you the plot
so that you can calculate the proportion.
Now, to repeat this procedure, we need to rerun this code again.
(Practically speaking the part with bold letters.)
We could set up another for loop for this repetition.
This will certainly be an interesting task.
But, since the repetition is just 10 times.
You could choose to run this sequence of code for 10 times
and record the proportion for each trial.
It is your call which way you want to go.
If you want to set up another loop, then I can give you more tips.
So, just let me know!
|