Question: Use R Studio for this please, any other programming language is not acceptable or supported, thank you. Assignment Overview - For this lab, we're going


Use R Studio for this please, any other programming language is not acceptable or supported, thank you.
Assignment Overview - For this lab, we're going to explore distributions and the variability of a sample statistic through simulation! - To do this, we will explore the diamonds dataset saved in the ggplot2 package. This dataset has over 59,000 diamonds catalogued, and we will treat this dataset like it's a population. - Let's see how much variation we see from sample to sample and how reliable our sample statistics are in different situations! Step 0 - Pre-lab work - Complete the pre-lab tutorials for Lab 3 first: https://stat212-learnr.stat.illinois.edu/ - Open RStudio (or RStudio Cloud) to get started and open a new script. - We will be using the diamonds dataset stored in the tidyverse package. So start by running library (tidyverse) - Open the diamonds data by running the code: View (diamonds). Each row represents one diamond from a collection of over 59,000. - Take a look at the documentation for diamonds by running the code: ?diamonds Question 3 (5pts): Next, set up a for loop to simulate taking a sample of size 50 at least 10,000 times. Inside your loop, calculate the mean price and save it to a vector called means. Here are two tips: - Remember before the loop to define means = NULL so that your loop knows where to save the means. - Remember inside the loop to include an index indicator with your means vector so that the vector fills iteratively for each iteration of the loop. - Try running the loop 10 times to ensure it works. This should be instantaneous. Then try running it 10,000 times. The loop should only take a few seconds to complete at 10,000 simulations, so if you wait more than a minute, click the stop button and see if something is defined incorrectly. After successfully running your simulation, create a histogram of your means vector. Again, continue to use the hist () function for all histograms in this lab. Include the image of your histogram in your report Include the R code you used to generate this loop Briefly describe the shape of your histogram. Is this a symmetric distribution or would you say it's skewed? How does this relate to the Central Limit Theorem we learned in class
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
