download.file("http://www.openintro.org/stat/data/ames.RData", destfile = "ames.RData")
load("ames.RData")
area <- ames$Gr.Liv.Area
price <- ames$SalePrice
Take a random sample of size 50 from price. Using this sample, what is your best point estimate of the population mean?
price <- sample(ames$SalePrice, 50, replace = FALSE, prob = NULL)
mean(price)
## [1] 169229
The best point estimate of the population mean is 171 953.6 dollars.
Since you have access to the population, simulate the sampling distribution for \(\bar{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(5000)
for(i in 5000) {sample_means50[i] <- mean(sample(ames$SalePrice, 50))}
par(mfrow =c(1,1))
hist(sample_means50)
mean(sample_means50)
## [1] NA
Mean isn’t available,
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?
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?
#You don't NEED to show any output to answer this question, but it might be nice to show the two histograms stacked on top of each other:)
The 50 sample has the smaller spread, and we would prefer a distribution with a small spread.