Due Today:
homework 04 released today
By the end of today you will
infer
to obtain a bootstrap distributionlibrary(tidyverse)
library(tidymodels)
manhattan = read_csv("data/manhattan.csv")
On a given day in 2018, twenty one-bedroom apartments were randomly selected on Craigslist Manhattan from apartments listed as “by owner”. The data are in the manhattan
data frame. We will use this sample to conduct inference on the typical rent of 1 bedroom apartments in Manhattan.
Let’s start by using bootstrapping to estimate the mean rent of one-bedroom apartments in Manhattan.
What is the point estimate of the typical rent?
Let’s bootstrap!
Fill in the values from the bootstrap sample conducted in class. Once the values are filled in, uncomment the code.
# class_bootstrap <- c()
# add code
We will use the infer
package, included as part of tidymodels
to calculate a 95% confidence interval for the mean rent of one-bedroom apartments in Manhattan.
We start by setting a seed to ensure our analysis is reproducible.
We can use R to take many bootstrap samples and generate a bootstrap distribution
Uncomment the lines and fill in the blanks to create the bootstrap distribution of sample means and save the results in the data frame boot_dist
.
Use 100 reps for the in-class activity. (You will use about 15,000 reps for assignments outsdie of class.)
set.seed(2252022)
boot_dist <- manhattan #%>%
#specify(______) %>%
#generate(______) %>%
#calculate(______)
boot_dist
?boot_dist
? What do they mean?Visualize the bootstrap distribution using a histogram. Describe the shape, center, and spread of this distribution.
# add code
Uncomment the lines and fill in the blanks to construct the 95% bootstrap confidence interval for the mean rent of one-bedroom apartments in Manhattan.
#___ %>%
# summarize(lower = quantile(______),
# upper = quantile(______))
Write the interpretation for the interval calculated above.
#calculate a 90% confidence interval
#calculate a 99% confidence interval
Question: Does a confidence interval have to be symmetric?
What is one advantage to using a 90% confidence interval instead of a 95% confidence interval to estimate a parameter? - What is one advantage to using a 99% confidence interval instead of a 95% confidence interval to estimate a parameter?
Next, use bootstrapping to estimate the median rent for one-bedroom apartments in Manhattan. - Generate the bootstrap distribution of the sample medians. Use 100 reps. Save the results in boot_dist_median
.
set.seed(100)
## add code
## add code