## D.11 Chapter 11 Solutions

library(tidyverse)
library(moderndive)
library(skimr)
library(fivethirtyeight)

(LC11.1) Repeat the regression modeling in Subsection 11.2.3 and the prediction making you just did on the house of condition 5 and size 1900 square feet in Subsection 11.2.4, but using the parallel slopes model you visualized in Figure 11.6. Show that it’s \$525,191!

house_prices <- house_prices %>%
mutate(
log10_price = log10(price),
log10_size = log10(sqft_living)
)
# Fit regression model:
price_interaction <- lm(log10_price ~ log10_size + condition,
data = house_prices
)

# Get regression table:
get_regression_table(price_interaction)

10^(2.88 + 0.096 + 0.837 * log10(1900))

(LC11.2) What date between 1994 and 2003 has the fewest number of births in the US? What story could you tell about why this is the case?

US_births_1994_2003 %>%
arrange(births)
# A tibble: 3,652 x 6
year month date_of_month date       day_of_week births
<int> <int>         <int> <date>     <ord>        <int>
1  2001    12            25 2001-12-25 Tues          6443
2  2000    12            25 2000-12-25 Mon           6566
3  2003    12            25 2003-12-25 Thurs         6628
4  2002    12            25 2002-12-25 Wed           6629
5  1999    12            25 1999-12-25 Sat           6674
6  2000    12            24 2000-12-24 Sun           6801
7  1995    12            24 1995-12-24 Sun           6999
8  2002     4             7 2002-04-07 Sun           7008
9  2002     3            31 2002-03-31 Sun           7019
10  1998    12            25 1998-12-25 Fri           7020
# … with 3,642 more rows

The dates with the fewest number of births in the US was 12/25 of the years of 2001, 2000, 2003, 2002, and 1999. Because it is Christmas Day and hospitals don’t generally induce labor on that day.