~/data/

Total Aggregate Household Credit (NY FED)

household_credit %>%
  mutate(date = year %>% paste0("-01-01") %>% as.Date) %>%
  spread(variable, value) %>%
  mutate(mortgage_total = mortgage*population) %>%
  group_by(date) %>%
  summarise(mortgage_total = sum(mortgage_total) / 10^9) %>%
  ggplot(.) + geom_line(aes(x = date, y = mortgage_total)) +
  theme_minimal() + xlab("") + ylab("") +
  scale_x_date(breaks = seq(1870, 2020, 1) %>% paste0("-01-01") %>% as.Date,
               labels = date_format("%y")) + 
  scale_y_continuous(breaks = seq(2000, 10000, 1000),
                     labels = dollar_format(suffix = "Bn", prefix = "$"))

U.S.

household_credit %>%
  filter(variable == "mortgage",
         year == 2007) %>%
  select(county_code = fips, value) %>%
  left_join(county_code_name %>%
              select(county_code, subregion = county_name3, region = state_name3),
            by = "county_code") %>%
  right_join(county, 
             by = c("region", "subregion")) %>%
  ggplot(aes(long, lat, group = group)) +
  geom_polygon(aes(fill = value), colour = alpha("black", 1/2), size = 0.2)  + 
  scale_fill_viridis_c(labels = scales::dollar_format(accuracy = 1),
                       na.value = "white",
                       breaks = c(25000, 50000, 75000, 100000, 125000)) +
  theme_void() +
  theme(legend.position = c(0.9, 0.2)) + 
  labs(fill = "Per Capita\nMortgage Debt")
Mortgage Debt Per Capita, 2007-Q4, FRB

Figure 1: Mortgage Debt Per Capita, 2007-Q4, FRB

California

household_credit %>%
  filter(variable == "mortgage",
         year == 2006) %>%
  select(county_code = fips, value) %>%
  left_join(county_code_name %>%
              select(county_code, subregion = county_name3, region = state_name3),
            by = "county_code") %>%
  right_join(county %>%
               filter(region == "california"),
             by = c("region", "subregion")) %>%
  ggplot(aes(long, lat, group = group)) +
  geom_polygon(aes(fill = value), colour = alpha("black", 1/2), size = 0.2)  + 
  scale_fill_viridis_c(na.value = "white",
                       labels = scales::dollar_format(accuracy = 1)) +
  theme_void() + theme(legend.position = c(0.9, 0.8)) + 
  labs(fill = "Per Capita\nMortgage Debt") + coord_fixed(ratio = 1)
Mortgage Debt Per Capita, California, 2006-Q4, FRB

Figure 2: Mortgage Debt Per Capita, California, 2006-Q4, FRB

Vermont

household_credit %>%
  filter(variable == "mortgage",
         year == 2006) %>%
  select(county_code = fips, value) %>%
  left_join(county_code_name %>%
              select(county_code, subregion = county_name3, region = state_name3),
            by = "county_code") %>%
  right_join(county %>%
               filter(region == "vermont"),
             by = c("region", "subregion")) %>%
  ggplot(aes(long, lat, group = group)) +
  geom_polygon(aes(fill = value), colour = alpha("black", 1/2), size = 0.2)  + 
  scale_fill_viridis_c(na.value = "white",
                       labels = scales::dollar_format(accuracy = 1)) +
  theme_void() + theme(legend.position = c(1, 0.4)) + 
  labs(fill = "Per Capita\nMortgage Debt") + coord_fixed(ratio = 1)
Mortgage Debt Per Capita, Vermont, 2006-Q4, FRB

Figure 3: Mortgage Debt Per Capita, Vermont, 2006-Q4, FRB

Texas

household_credit %>%
  filter(variable == "mortgage",
         year == 2006) %>%
  select(county_code = fips, value) %>%
  left_join(county_code_name %>%
              select(county_code, subregion = county_name3, region = state_name3),
            by = "county_code") %>%
  right_join(county %>%
               filter(region == "texas"),
             by = c("region", "subregion")) %>%
  ggplot(aes(long, lat, group = group)) +
  geom_polygon(aes(fill = value), colour = alpha("black", 1/2), size = 0.2)  + 
  scale_fill_viridis_c(na.value = "white",
                       labels = scales::dollar_format(accuracy = 1)) +
  theme_void() + theme(legend.position = c(0.05, 0.2)) + 
  labs(fill = "Per Capita\nMortgage Debt") + coord_fixed(ratio = 1)
Mortgage Debt Per Capita, Texas, 2006-Q4, FRB

Figure 4: Mortgage Debt Per Capita, Texas, 2006-Q4, FRB

Massachusetts

household_credit %>%
  filter(variable == "mortgage",
         year == 2006) %>%
  select(county_code = fips, value) %>%
  left_join(county_code_name %>%
              select(county_code, subregion = county_name3, region = state_name3),
            by = "county_code") %>%
  right_join(county %>%
               filter(region == "massachusetts"),
             by = c("region", "subregion")) %>%
  ggplot(aes(long, lat, group = group)) +
  geom_polygon(aes(fill = value), colour = alpha("black", 1/2), size = 0.2)  + 
  scale_fill_viridis_c(na.value = "white",
                       labels = scales::dollar_format(accuracy = 1)) +
  theme_void() + theme(legend.position = c(0.2, 0.2)) + 
  labs(fill = "Per Capita\nMortgage Debt") + coord_fixed(ratio = 1)
Mortgage Debt Per Capita, Massachusetts, 2006-Q4, FRB

Figure 5: Mortgage Debt Per Capita, Massachusetts, 2006-Q4, FRB