phats c Create an empty vector to store the simulated sample proportion from

# Phats c create an empty vector to store the simulated

• 9

This preview shows page 3 - 5 out of 9 pages.

phats <- c() # Create an empty vector to store the simulated sample proportion from each repetition for (i in 1:M){ # Let i cycle over numbers 1 to 1000 index <- sample(N, size=n) # Take a simple random sample of size n from the popul ation of size N sample_i <- college[index,] # Save the random sample in the sample_i vector phats[i] <- mean(sample_i\$OnCampus == "Y") # Compute the proportion of students in the sample living on campus for each sample } histogram(phats, fit="normal") # Create a histogram of the sampling distribution of sample proportions & superimpose a normal curve
7. Code: mean(phats) # Find the mean of the sampling distribution of sample proportions ## [1] 0.7752 ad(phats) # Find the standard deviation of the sampling distribution of sample proportions ## [1] 0.7323699 8. I think that the sampling distribution is not normal because on average, a sample size of 30 from the population does not satisfy the validity condition of having at least 10 successes and 10 failures. As seen above, there are about 23 successes and only 6.7 failures. This means that we cannot use theory-based method to approximate the simulation by normal distribution. 9. Code: mean(college\$OnCampus=="Y") # Using theory-based approach, the mean of the population distribution is equal to the mean of the sampling distribution.

#### You've reached the end of your free preview.

Want to read all 9 pages?

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern