download.file("http://www.openintro.org/stat/data/ames.RData", destfile = "ames.RData")
load("ames.RData")
area<-ames$Gr.Liv.Area
price<-ames$SalePrice
Exercise 1 Take a random sample of size 50 from price. Using this sample, what is your best point estimate of the population mean?
set.seed(50)
samp5<-sample(price,50)
summary(samp5)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   76500  112425  140250  171148  202250  584500
Exercise 2: Since you have access to the population, simulate the sampling distribution for x¯price by taking 5000 samples from the population of size 50 and computing 5000 sample means. Store these means in a vector called sample_means50. Plot the data, then describe the shape of this sampling distribution. Based on this sampling distribution, what would you guess the mean home price of the population to be? Finally, calculate and report the population mean.
sample_means50<-rep(0,5000)
for(i in 1:5000){
samp<-sample(price,50)
sample_means50[i]<-mean(samp)
}
hist(sample_means50, breaks = 25)

Exercise 3 - Change your sample size from 50 to 150, then compute the sampling distribution using the same method as above, and store these means in a new vector called sample_means150. Describe the shape of this sampling distribution, and compare it to the sampling distribution for a sample size of 50. Based on this sampling distribution, what would you guess to be the mean sale price of homes in Ames?
sample_means150<-rep(0,5000)
for(i in 1:5000){
samp<-sample(price,150)
sample_means150[i]<-mean(samp)
}
hist(sample_means150, breaks = 25)

4.Of the sampling distributions from 2 and 3, which has a smaller spread? If we’re concerned with making estimates that are more often close to the true value, would we prefer a distribution with a large or small spread?
#Sampling distributions from 3 has smaller spread. We would prefer a distribution with a small spread because it is associated with low data variability.