This section presents comprehensive visualizations of the time series data, transforming raw numbers into interpretable patterns and relationships. Through line plots, decomposition charts, correlation heatmaps, and interactive graphics, I illustrate the evolution of student loan debt, housing market dynamics, and macroeconomic indicators over time. These visualizations not only support the analytical findings but also make complex temporal patterns accessible, highlighting critical inflection points such as the 2008 Financial Crisis and COVID-19 pandemic.
Outstanding student loans has experienced a steady increase from 2006 until present day, with a slight dip in 2024. From 2006 to 2018, there was an almost linear increase however after 2019, the rate decreased then leveled off from 2021-2023. This was likely due to decreased tuition rates for individuals who did the year virtually. This decrease in tuition allowed many to take out smaller loans or no loans at all. As tuition increases, outstanding student loan balances has followed the same trajectory. Many Americans consider student loans to be the least concerning kind of debt and take a passive approach to paying it back.
The U.S. Housing Price Index has heavy seasonality with a consistent increase in trend from 1990 on. There was an exponential increase in the index from the late 90s to the early 2000s, then a sharp decrease happens towards the end of 2007 and into 2008, which we know to be as the 2008 Housing Crisis. Numbers continued to decrease until 2011 but made a strong recover there after and has been a steady, exponential increase since.
Show Code
mount_vernon_b_long <- mount_vernon_hvi_bottom %>%pivot_longer(cols =starts_with("X"),names_to ="date",values_to ="hvi" ) %>%mutate(date =as.Date(gsub("X", "", date), format ="%Y.%m.%d") ) %>%arrange(date)# head(mount_vernon_b_long)mount_vernon_b_long %>%plot_ly(x =~date, y =~hvi) %>%add_lines() %>%layout(title ="Mount Vernon Bottom Home Value Index",xaxis =list(title ="Date"),yaxis =list(title ="Index"))
Home Value Index for Mount Vernon was split into a top and bottom tier as to not lose the trend and true values of the upper and lower quantiles of the data. The top tier captures homes within the 65th to 95th percentile of homes in the area and the bottom tier fits homes within the 5th to 35th percentile. The first observation is in 2000.
Bottom tier: This trend is very similar to that of the top tier, experiencing a steady increase from 2000 to 2007 but not of the same magnitude. This increase was followed by a drop in 2007 until 2013 but again, not as drastic as the drop the took place for the top tier HVI. After this decrease, there was a steady increase and this time, the slope of the second increase appears to be similar to that of the increase from 2000 to 2007.
Show Code
mount_vernon_t_long <- mount_vernon_hvi_top %>%pivot_longer(cols =starts_with("X"),names_to ="date",values_to ="hvi" ) %>%mutate(date =as.Date(gsub("X", "", date), format ="%Y.%m.%d") ) %>%arrange(date)mount_vernon_t_long %>%plot_ly(x =~date, y =~hvi) %>%add_lines() %>%layout(title ="Mount Vernon Top Home Value Index",xaxis =list(title ="Date"),yaxis =list(title ="Index"))
Top tier: the trend increased tremendously from 2000 to October 2006, doubling from $398,000 to $848,000. However, it then experienced a sharp decrease until 2013, which can also be attributed to the 2008 Housing Bubble. This decrease is then followed by a steady increase from then on, however, not at the same rate as the previous increase from 2000 to 2007.
Show Code
bronxville_b_long <- bronxville_hvi_bottom %>%pivot_longer(cols =starts_with("X"),names_to ="date",values_to ="hvi" ) %>%mutate(date =as.Date(gsub("X", "", date), format ="%Y.%m.%d") ) %>%arrange(date)bronxville_b_long %>%plot_ly(x =~date, y =~hvi) %>%add_lines() %>%layout(title ="Bronxville Bottom Home Value Index",xaxis =list(title ="Date"),yaxis =list(title ="Index"))
Home Value Index for Bronxville was split into a top and bottom tier as to not lose the trend and true values of the upper and lower quantiles of the data. The top tier captures homes within the 65th to 95th percentile of homes in the area and the bottom tier fits homes within the 5th to 35th percentile. The first observation is in 2016, much later than the start dates for most of the datasets.
Top tier: there was a steady decrease in home value from 2016 to late 2020 and an almost exponential increase from 2020 to 2022. However, by 2023, the trend experienced a decrease at an almost identical rate as the initial increase.
Show Code
bronxville_t_long <- bronxville_hvi_top %>%pivot_longer(cols =starts_with("X"),names_to ="date",values_to ="hvi" ) %>%mutate(date =as.Date(gsub("X", "", date), format ="%Y.%m.%d") ) %>%arrange(date)bronxville_t_long %>%plot_ly(x =~date, y =~hvi) %>%add_lines() %>%layout(title ="Bronxville Top Home Value Index",xaxis =list(title ="Date"),yaxis =list(title ="Index"))
Bottom tier: Overall, the bronxville bottom tier has a steadily increasing trendline with minor peaks.
Show Code
# head(homeownership_rates)homeownership_q <- homeownership_rates %>%filter(!is.na(RHORUSQ156N))homeownership_q$observation_date <-as.Date(homeownership_q$observation_date, format ="%Y-%m-%d")homeownership_q %>%plot_ly(x =~observation_date, y =~RHORUSQ156N) %>%add_lines() %>%layout(title ='Homeownership Rate: Household Head < 35 Years',xaxis =list(title ='Date'),yaxis =list(title ='Rate (%)'))
The homeownership rate for household heads under 35 years shows a declining trend over the period. Starting in the early 1980s, there was a relatively high homeownership rate among young adults, but this has steadily decreased over the decades. The rate experienced some fluctuations but overall shows a persistent downward trajectory, particularly accelerating after the 2008 housing crisis. This decline suggests that younger generations face increasing barriers to homeownership, potentially due to rising housing costs, increased student loan debt, and changing economic conditions.
Show Code
# head(mortgage_avg)mortgage_q <- mortgage_avg %>%filter(!is.na(MORTGAGE30US))mortgage_q$observation_date <-as.Date(mortgage_q$observation_date, format ="%Y-%m-%d")mortgage_q %>%plot_ly(x =~observation_date, y =~MORTGAGE30US) %>%add_lines() %>%layout(title ='30-Year Fixed Rate Mortgage Average in the U.S.',xaxis =list(title ='Date'),yaxis =list(title ='Rate (%)'))
The 30-year fixed mortgage rate shows significant volatility over time with a general downward trend from the early 1970s through 2020. The rates started extremely high in the early 1980s, reaching peaks above 18%, reflecting the high inflation period. Since then, rates have experienced a long-term decline with several cycles of increases and decreases corresponding to Federal Reserve policy changes and economic conditions. The most recent period shows historically low rates during 2020-2021, followed by a sharp increase in 2022-2023 as the Federal Reserve raised rates to combat inflation.
Show Code
# head(college_tuition)college_tuition_q <- college_tuition %>%filter(!is.na(CUSR0000SEEB))college_tuition_q$observation_date <-as.Date(college_tuition_q$observation_date, format ="%Y-%m-%d")college_tuition_q %>%plot_ly(x =~observation_date, y =~CUSR0000SEEB) %>%add_lines() %>%layout(title ='Consumer Price Index for College Tuition and Fees',xaxis =list(title ='Date'),yaxis =list(title ='Index'))
The Consumer Price Index for college tuition and fees demonstrates a consistent and steep upward trend from the late 1970s through the present day. Unlike many other consumer goods, college tuition has increased at a rate significantly above general inflation, with only minor slowdowns during economic recessions. The index shows an almost exponential growth pattern, particularly accelerating in the 1990s and 2000s. This sustained increase in tuition costs has major implications for student debt accumulation and accessibility to higher education.
Show Code
# head(median_household_income)median_income_q <- median_household_income %>%filter(!is.na(MEHOINUSA672N))median_income_q$observation_date <-as.Date(median_income_q$observation_date, format ="%Y-%m-%d")median_income_q %>%plot_ly(x =~observation_date, y =~MEHOINUSA672N) %>%add_lines() %>%layout(title ='Median Household Income in the U.S.',xaxis =list(title ='Date'),yaxis =list(title ='Income ($)'))
Median household income in the United States shows a generally increasing trend over time, but with notable periods of stagnation and decline. The data reveals that income growth has been uneven, with significant drops during recessions (such as 2008-2009) and periods of slow recovery afterward. While nominal income has increased over the decades, when compared to the rate of increase in housing prices and college tuition, household income growth appears more modest, suggesting a growing affordability gap for major expenses like homeownership and education.
Show Code
# head(first_time_buyer)first_time_buyer_q <- first_time_buyer %>%filter(!is.na(First_Time_Buyers))first_time_buyer_q$Year <-as.numeric(first_time_buyer_q$Year)first_time_buyer_q$First_Time_Buyers <-as.numeric(first_time_buyer_q$First_Time_Buyers)first_time_buyer_q %>%plot_ly(x =~Year, y =~First_Time_Buyers) %>%add_lines() %>%layout(title ='Median Age of First-Time Homebuyers',xaxis =list(title ='Year'),yaxis =list(title ='Age (years)'))
The median age of first-time homebuyers has shown a significant upward trend over the past several decades. In the early 1980s, first-time buyers were typically in their late 20s, but this age has steadily increased to 49 years in recent data - representing a 20-year delay in this critical wealth-building milestone. This aging trend suggests that young adults are facing increasing challenges in achieving homeownership earlier in life, potentially due to factors such as rising home prices, student loan debt, stricter lending standards following the 2008 crisis, and changing economic opportunities. The data shows that key life milestones, including homeownership, are being substantially delayed for younger generations.
Show Code
# head(business_form_stats)# Clean business formation statisticsbusiness_form_clean <- business_form_stats %>%slice(8:n()) %>%# Start from row 8 where data beginsselect(1, 2) %>%# Select period and value columnsfilter(row_number() >1) %>%# Skip the header rowsetNames(c("period", "applications")) %>%filter(!is.na(period), !is.na(applications)) %>%mutate(date =as.Date(paste0(period, "-01"), format ="%b-%Y-%d"),applications =as.numeric(applications) ) %>%filter(!is.na(date), !is.na(applications))business_form_clean %>%plot_ly(x =~date, y =~applications) %>%add_lines() %>%layout(title ='Business Formation Statistics',xaxis =list(title ='Date'),yaxis =list(title ='Applications'))
Business formation statistics track the number of new business applications over time, serving as an indicator of entrepreneurial activity and economic dynamism. The data shows cyclical patterns corresponding to economic conditions, with surges during periods of economic growth and opportunity. Notably, there appears to be significant variation over time, with recent years showing increased entrepreneurial activity. This metric is important for understanding how education, access to capital, and economic conditions influence individuals’ decisions to start new businesses. The relationship between student debt burden and entrepreneurship is of particular interest, as high debt loads may discourage risk-taking and new business creation among young adults.
Show Code
# head(self_employment_rate)self_employment_q <- self_employment_rate %>%filter(!is.na(LNS12032192))self_employment_q$observation_date <-as.Date(self_employment_q$observation_date, format ="%Y-%m-%d")self_employment_q %>%plot_ly(x =~observation_date, y =~LNS12032192) %>%add_lines() %>%layout(title ='Self-Employment Rate in the U.S.',xaxis =list(title ='Date'),yaxis =list(title ='Rate (%)'))
The self-employment rate reflects the percentage of the workforce that is self-employed, including independent contractors, freelancers, and business owners. This metric has shown a gradual decline over recent decades, suggesting that fewer workers are choosing or able to pursue self-employment opportunities. The downward trend may be influenced by multiple factors including increased student debt burdens that discourage entrepreneurial risk-taking, changing industry structures, healthcare access tied to traditional employment, and shifting preferences among younger workers. Understanding this trend is crucial for assessing how educational debt and economic structures impact innovation and entrepreneurship in the economy.
Show Code
# head(edu_attainment)# Clean educational attainment data - extract bachelor's degree or higher dataedu_attainment_clean <- edu_attainment %>%slice(7:n()) %>%# Start from data rowsselect(1, 2) %>%# Select year and total percentage columnssetNames(c("year_label", "bachelor_plus_pct")) %>%filter(!is.na(year_label), !is.na(bachelor_plus_pct)) %>%mutate(# Extract year from labels like "1910\\2\\" or "1940"year =as.numeric(str_extract(year_label, "\\d{4}")),bachelor_plus_pct =as.numeric(bachelor_plus_pct) ) %>%filter(!is.na(year), !is.na(bachelor_plus_pct), bachelor_plus_pct !=0) %>%select(year, bachelor_plus_pct) %>%arrange(year)edu_attainment_clean %>%plot_ly(x =~year, y =~bachelor_plus_pct) %>%add_lines() %>%layout(title ='Educational Attainment: High School Completion (Age 25+)',xaxis =list(title ='Year'),yaxis =list(title ='Percentage (%)'))
Educational attainment levels in the United States have shown a consistent upward trend over time, with an increasing percentage of the population aged 25 and over holding a bachelor’s degree or higher. This rise in educational attainment reflects the growing importance of higher education for economic opportunity and career advancement. However, this trend also correlates with increased student loan debt as more individuals pursue degrees. The data demonstrates the tension between expanding educational access and the growing financial burden of obtaining that education. Understanding educational attainment trends is essential for analyzing labor market outcomes, income inequality, and the long-term economic impact of education financing policies.
Story-Telling Visualizations: Key Relationships
The Big Picture: How Student Debt Impacts Economic Opportunity
These visualizations reveal the interconnected relationships between student loans, housing access, and financial stability.
1. The Diverging Paths: Student Debt vs Young Adult Homeownership
Critical Insight: As student loan debt skyrocketed to over $1.6 trillion today, homeownership rates among young adults (under 35) plummeted from nearly 44% to below 37%. This inverse relationship suggests that educational debt is a significant barrier to achieving the traditional milestone of homeownership.
The Widening Gap: Since 1990, college tuition has increased dramatically faster than income growth, and housing prices have similarly outpaced wage increases. This divergence means that education and homeownership require a much larger share of household income today than they did three decades ago.
3. Generational Delay: Age of First-Time Homebuyers
Show Code
# Enhanced first-time buyer visualization with key events annotatedfig3 <-plot_ly(data = first_time_buyer_q,x =~Year,y =~First_Time_Buyers,type ="scatter",mode ="lines+markers",line =list(color ="#2E86AB", width =3),marker =list(size =8, color ="#F18F01"),text =~paste("Year:", Year, "<br>Median Age:", First_Time_Buyers),hoverinfo ="text")fig3 <- fig3 %>%layout(title =list(text ="<b>Homeownership Delayed: Rising Age of First-Time Buyers</b><br><sub>Young adults are waiting longer to achieve homeownership</sub>",font =list(size =18) ),xaxis =list(title ="Year"),yaxis =list(title ="Median Age (years)"),margin =list(t =100), # Add top margin to prevent annotation overlapshapes =list(# Vertical line for 2008 Financial Crisislist(type ="line",x0 =2008, x1 =2008,y0 =0, y1 =1,yref ="paper",line =list(color ="#A23B72", width =2, dash ="dash") ),# Vertical line for COVID-19list(type ="line",x0 =2020, x1 =2020,y0 =0, y1 =1,yref ="paper",line =list(color ="#A23B72", width =2, dash ="dash") ) ),annotations =list(list(x =2008, y =1.02,yref ="paper",text ="2008 Financial Crisis",showarrow =FALSE,font =list(color ="#A23B72", size =11),xanchor ="center" ),list(x =2020, y =1.02,yref ="paper",text ="COVID-19 Pandemic",showarrow =FALSE,font =list(color ="#A23B72", size =11),xanchor ="center" ) ))fig3
Note
Delayed Milestones: The median age of first-time homebuyers has increased from approximately 29 years in the 1980s to 49 years today - a 20-year delay. This shift represents a fundamental change in the timeline of adult financial milestones, with far-reaching implications for wealth accumulation, family formation, and retirement planning.
4. Regional Inequality: Housing Value Tiers
Show Code
# Combine all ZHVI data for comparisoncombined_zhvi <-bind_rows( mount_vernon_b_long %>%mutate(location ="Mount Vernon - Bottom Tier", tier ="Bottom"), mount_vernon_t_long %>%mutate(location ="Mount Vernon - Top Tier", tier ="Top"), bronxville_b_long %>%mutate(location ="Bronxville - Bottom Tier", tier ="Bottom"), bronxville_t_long %>%mutate(location ="Bronxville - Top Tier", tier ="Top"))fig4 <-plot_ly(data = combined_zhvi)# Add traces for each locationcolors <-c("Mount Vernon - Bottom Tier"="#06A77D","Mount Vernon - Top Tier"="#2E86AB","Bronxville - Bottom Tier"="#F18F01","Bronxville - Top Tier"="#A23B72")for (loc inunique(combined_zhvi$location)) { plot_data <- combined_zhvi %>%filter(location == loc) fig4 <- fig4 %>%add_trace(data = plot_data,x =~date,y =~hvi,name = loc,type ="scatter",mode ="lines",line =list(color = colors[loc], width =2.5) )}fig4 <- fig4 %>%layout(title =list(text ="<b>Housing Inequality: Comparing Market Tiers</b><br><sub>Westchester County, NY - Bottom vs Top Tier Home Values</sub>",font =list(size =18) ),xaxis =list(title ="Year"),yaxis =list(title ="Home Value Index ($)"),legend =list(x =0.02,y =0.98,bgcolor ="rgba(255,255,255,0.9)" ),hovermode ="x unified")fig4
Economic Stratification: The gap between top-tier and bottom-tier home values has widened significantly over time. In Mount Vernon, top-tier homes reached nearly $850K at their peak while bottom-tier homes peaked around $350K. This growing disparity creates different housing markets with vastly different accessibility for first-time buyers burdened by student debt.
Putting It All Together:
These story-telling visualizations reveal a clear pattern: as student loan debt has exploded and the costs of education and housing have far outpaced income growth, young adults face unprecedented barriers to achieving traditional economic milestones. The data shows that:
Student debt and homeownership move in opposite directions - suggesting a direct trade-off
The affordability gap is widening - income hasn’t kept pace with essential costs
Milestones are being delayed - first-time buyers are 7 years older than previous generations
Inequality is growing - housing market stratification creates different realities for different income levels
These insights set the stage for our deeper time series analysis to quantify these relationships and explore potential policy interventions.
Educational Outcomes: Mount Vernon vs Bronxville
The Education-Housing Connection
Comparing school performance in neighboring Westchester County districts reveals how educational opportunity intersects with housing markets and economic mobility.
6. Connecting Education to Housing Values
Show Code
# Combine school data with housing data for comparison# Using average graduation rate per districtschool_avg <- school_clean %>%group_by(district_short) %>%summarise(avg_grad_rate =mean(grad_pct_num, na.rm =TRUE),avg_dropout =mean(dropout_pct_num, na.rm =TRUE) )# Get average home valueshousing_avg <-bind_rows( mount_vernon_b_long %>%filter(year(date) >=2015, year(date) <=2018) %>%summarise(district ="Mount Vernon",avg_value =mean(hvi, na.rm =TRUE) ), bronxville_b_long %>%filter(year(date) >=2015, year(date) <=2018) %>%summarise(district ="Bronxville",avg_value =mean(hvi, na.rm =TRUE) ))# Mergecomparison_df <- school_avg %>%left_join(housing_avg, by =c("district_short"="district"))# Create side-by-side comparisonp1 <-plot_ly(data = comparison_df,x =~district_short,y =~avg_grad_rate,type ="bar",marker =list(color =c("#A23B72", "#2E86AB")),text =~paste0(round(avg_grad_rate, 1), "%"),textposition ="outside",name ="Graduation Rate") %>%layout(yaxis =list(title ="Graduation Rate (%)", range =c(0, 100)),xaxis =list(title =""),showlegend =FALSE)p2 <-plot_ly(data = comparison_df,x =~district_short,y =~avg_value,type ="bar",marker =list(color =c("#A23B72", "#2E86AB")),text =~paste0("$", format(round(avg_value/1000, 0), big.mark =","), "K"),textposition ="outside",name ="Home Value") %>%layout(yaxis =list(title ="Median Home Value ($)"),xaxis =list(title =""),showlegend =FALSE)# Combinesubplot(p1, p2, nrows =1, margin =0.08, shareX =TRUE) %>%layout(title =list(text ="<b>The Education-Housing Connection</b><br><sub>School Performance vs Housing Values (2015-2018 Average)</sub>",font =list(size =12),x =0.5,xanchor ="center" ) )
The Cycle of Inequality:
These visualizations reveal how education and housing create a reinforcing cycle:
Higher home values → Better-funded schools (property tax base)
This disparity, occurring within the same county, demonstrates how housing segregation perpetuates educational inequality—which in turn affects student debt burdens and future homeownership prospects for the next generation.
Source Code
---title: "Data Visualization"execute: warning: false message: false error: false---This section presents comprehensive visualizations of the time series data, transforming raw numbers into interpretable patterns and relationships. Through line plots, decomposition charts, correlation heatmaps, and interactive graphics, I illustrate the evolution of student loan debt, housing market dynamics, and macroeconomic indicators over time. These visualizations not only support the analytical findings but also make complex temporal patterns accessible, highlighting critical inflection points such as the 2008 Financial Crisis and COVID-19 pandemic.```{r setup, include=FALSE, echo=FALSE, output=FALSE}library(rvest)library(dplyr)library(tidyr)library(stringr)library(purrr)library(glue)library(readr)library(tidyverse)library(ggplot2)library(forecast)library(astsa) library(xts)library(tseries)library(fpp2)library(fma)library(lubridate)library(TSstudio)library(quantmod)library(tidyquant)library(plotly)library(ggplot2)library(readxl)library(gridExtra)``````{r, include=FALSE, echo=FALSE, output=FALSE}# load in datastudent_loans_outstanding <- read.csv('data/raw/SLOASM.csv') #DONEhomeownership_rates <- read.csv('data/raw/RHORUSQ156N.csv')mortgage_avg <- read.csv('data/raw/MORTGAGE30US.csv')college_tuition <- read.csv('data/raw/CUSR0000SEEB.csv')median_household_income <- read.csv('data/raw/MEHOINUSA672N.csv')first_time_buyer <- read.csv('data/raw/median_age_homebuyers_1981_2024.csv')household_formation <- read_excel('data/raw/histtab12.xlsx')housing_price_index <- read.csv('data/raw/hpi_master.csv') #DONEhome_value_index_bottom <- read.csv('data/raw/City_zhvi_uc_sfrcondo_tier_0.0_0.33_sm_sa_month.csv') #DONEhome_value_index_top <- read.csv('data/raw/City_zhvi_uc_sfrcondo_tier_0.67_1.0_sm_sa_month.csv') #DONEbusiness_form_stats <- read_excel('data/raw/SeriesReport-202509231959-V.xlsx')self_employment_rate <- read.csv('data/raw/LNS12032192.csv')edu_attainment <- read_excel('data/raw/tabn104.10.xlsx')kauffman_indicators <- read.csv('data/raw/2021_kese_download_final.csv')``````{r}# head(student_loans_outstanding)student_loans_q <- student_loans_outstanding |>filter(!is.na(SLOASM))student_loans_q$observation_date <-as.Date(student_loans_q$observation_date, format ="%Y-%m-%d")student_loans_q %>%plot_ly(x=~observation_date, y=~SLOASM) %>%add_lines() %>%layout(title ='National Outstanding Student Loan Balance',xaxis =list(title ='Date'),yaxis =list( title ='Total'))```Outstanding student loans has experienced a steady increase from 2006 until present day, with a slight dip in 2024. From 2006 to 2018, there was an almost linear increase however after 2019, the rate decreased then leveled off from 2021-2023. This was likely due to decreased tuition rates for individuals who did the year virtually. This decrease in tuition allowed many to take out smaller loans or no loans at all. As tuition increases, outstanding student loan balances has followed the same trajectory. Many Americans consider student loans to be the least concerning kind of debt and take a passive approach to paying it back.```{r}# head(housing_price_index)# data columnhousing_price_index <- housing_price_index %>%mutate(date =as.Date(paste(yr, period, "01", sep ="-")) )# filter for ushpi_us <- housing_price_index %>%filter(place_name =="United States")# indexhpi_us <- hpi_us[0:414, ]# plothpi_us %>%plot_ly(x =~date, y =~index_nsa) %>%add_lines() %>%layout(title ="U.S. Housing Price Index",xaxis =list(title ="Date"),yaxis =list(title ="Index (Seasonally Adjusted)"))```The U.S. Housing Price Index has heavy seasonality with a consistent increase in trend from 1990 on. There was an exponential increase in the index from the late 90s to the early 2000s, then a sharp decrease happens towards the end of 2007 and into 2008, which we know to be as the 2008 Housing Crisis. Numbers continued to decrease until 2011 but made a strong recover there after and has been a steady, exponential increase since.```{r include=FALSE}head(home_value_index_top)head(home_value_index_bottom)bronxville_hvi_top <- home_value_index_top %>% filter(CountyName == "Westchester County" & RegionName == "Bronxville")bronxville_hvi_bottom <- home_value_index_bottom %>% filter(CountyName == 'Westchester County' & RegionName == 'Bronxville')mount_vernon_hvi_top <- home_value_index_top %>% filter(CountyName == 'Westchester County' & RegionName == 'Mount Vernon')mount_vernon_hvi_bottom <- home_value_index_bottom %>% filter(CountyName == 'Westchester County' & RegionName == 'Mount Vernon')# head(mount_vernon_hvi_bottom)``````{r include=FALSE}zhvi_raw <- list( "Bronxville_top" = bronxville_hvi_top, "Bronxville_bottom" = bronxville_hvi_bottom, "MountVernon_top" = mount_vernon_hvi_top, "MountVernon_bottom"= mount_vernon_hvi_bottom)# tidy to wide dftidy_zhvi <- function(df, key){ # Parse labels from the list name like "Bronxville_top" parts <- strsplit(key, "_")[[1]] city <- parts[1] slice <- parts[2] # "top" or "bottom" df %>% mutate(City = city, Slice = slice) %>% # keep id columns plus monthly columns starting with XYYYY.MM.DD select(City, Slice, RegionID, RegionName, RegionType, StateName, CountyName, starts_with("X")) %>% pivot_longer( cols = starts_with("X"), names_to = "date", values_to = "hvi" ) %>% mutate( date = as.Date(sub("^X", "", date), format = "%Y-%m-%d"), hvi = as.numeric(hvi) ) %>% arrange(date)}# apply and previewzhvi_long <- imap_dfr(zhvi_raw, tidy_zhvi)dplyr::glimpse(zhvi_long)``````{r}mount_vernon_b_long <- mount_vernon_hvi_bottom %>%pivot_longer(cols =starts_with("X"),names_to ="date",values_to ="hvi" ) %>%mutate(date =as.Date(gsub("X", "", date), format ="%Y.%m.%d") ) %>%arrange(date)# head(mount_vernon_b_long)mount_vernon_b_long %>%plot_ly(x =~date, y =~hvi) %>%add_lines() %>%layout(title ="Mount Vernon Bottom Home Value Index",xaxis =list(title ="Date"),yaxis =list(title ="Index"))```Home Value Index for Mount Vernon was split into a top and bottom tier as to not lose the trend and true values of the upper and lower quantiles of the data. The top tier captures homes within the 65th to 95th percentile of homes in the area and the bottom tier fits homes within the 5th to 35th percentile. The first observation is in 2000.Bottom tier: This trend is very similar to that of the top tier, experiencing a steady increase from 2000 to 2007 but not of the same magnitude. This increase was followed by a drop in 2007 until 2013 but again, not as drastic as the drop the took place for the top tier HVI. After this decrease, there was a steady increase and this time, the slope of the second increase appears to be similar to that of the increase from 2000 to 2007.```{r}mount_vernon_t_long <- mount_vernon_hvi_top %>%pivot_longer(cols =starts_with("X"),names_to ="date",values_to ="hvi" ) %>%mutate(date =as.Date(gsub("X", "", date), format ="%Y.%m.%d") ) %>%arrange(date)mount_vernon_t_long %>%plot_ly(x =~date, y =~hvi) %>%add_lines() %>%layout(title ="Mount Vernon Top Home Value Index",xaxis =list(title ="Date"),yaxis =list(title ="Index"))```Top tier: the trend increased tremendously from 2000 to October 2006, doubling from \$398,000 to \$848,000. However, it then experienced a sharp decrease until 2013, which can also be attributed to the 2008 Housing Bubble. This decrease is then followed by a steady increase from then on, however, not at the same rate as the previous increase from 2000 to 2007.```{r}bronxville_b_long <- bronxville_hvi_bottom %>%pivot_longer(cols =starts_with("X"),names_to ="date",values_to ="hvi" ) %>%mutate(date =as.Date(gsub("X", "", date), format ="%Y.%m.%d") ) %>%arrange(date)bronxville_b_long %>%plot_ly(x =~date, y =~hvi) %>%add_lines() %>%layout(title ="Bronxville Bottom Home Value Index",xaxis =list(title ="Date"),yaxis =list(title ="Index"))```Home Value Index for Bronxville was split into a top and bottom tier as to not lose the trend and true values of the upper and lower quantiles of the data. The top tier captures homes within the 65th to 95th percentile of homes in the area and the bottom tier fits homes within the 5th to 35th percentile. The first observation is in 2016, much later than the start dates for most of the datasets.Top tier: there was a steady decrease in home value from 2016 to late 2020 and an almost exponential increase from 2020 to 2022. However, by 2023, the trend experienced a decrease at an almost identical rate as the initial increase.```{r}bronxville_t_long <- bronxville_hvi_top %>%pivot_longer(cols =starts_with("X"),names_to ="date",values_to ="hvi" ) %>%mutate(date =as.Date(gsub("X", "", date), format ="%Y.%m.%d") ) %>%arrange(date)bronxville_t_long %>%plot_ly(x =~date, y =~hvi) %>%add_lines() %>%layout(title ="Bronxville Top Home Value Index",xaxis =list(title ="Date"),yaxis =list(title ="Index"))```Bottom tier: Overall, the bronxville bottom tier has a steadily increasing trendline with minor peaks.```{r}# head(homeownership_rates)homeownership_q <- homeownership_rates %>%filter(!is.na(RHORUSQ156N))homeownership_q$observation_date <-as.Date(homeownership_q$observation_date, format ="%Y-%m-%d")homeownership_q %>%plot_ly(x =~observation_date, y =~RHORUSQ156N) %>%add_lines() %>%layout(title ='Homeownership Rate: Household Head < 35 Years',xaxis =list(title ='Date'),yaxis =list(title ='Rate (%)'))```The homeownership rate for household heads under 35 years shows a declining trend over the period. Starting in the early 1980s, there was a relatively high homeownership rate among young adults, but this has steadily decreased over the decades. The rate experienced some fluctuations but overall shows a persistent downward trajectory, particularly accelerating after the 2008 housing crisis. This decline suggests that younger generations face increasing barriers to homeownership, potentially due to rising housing costs, increased student loan debt, and changing economic conditions.```{r}# head(mortgage_avg)mortgage_q <- mortgage_avg %>%filter(!is.na(MORTGAGE30US))mortgage_q$observation_date <-as.Date(mortgage_q$observation_date, format ="%Y-%m-%d")mortgage_q %>%plot_ly(x =~observation_date, y =~MORTGAGE30US) %>%add_lines() %>%layout(title ='30-Year Fixed Rate Mortgage Average in the U.S.',xaxis =list(title ='Date'),yaxis =list(title ='Rate (%)'))```The 30-year fixed mortgage rate shows significant volatility over time with a general downward trend from the early 1970s through 2020. The rates started extremely high in the early 1980s, reaching peaks above 18%, reflecting the high inflation period. Since then, rates have experienced a long-term decline with several cycles of increases and decreases corresponding to Federal Reserve policy changes and economic conditions. The most recent period shows historically low rates during 2020-2021, followed by a sharp increase in 2022-2023 as the Federal Reserve raised rates to combat inflation.```{r}# head(college_tuition)college_tuition_q <- college_tuition %>%filter(!is.na(CUSR0000SEEB))college_tuition_q$observation_date <-as.Date(college_tuition_q$observation_date, format ="%Y-%m-%d")college_tuition_q %>%plot_ly(x =~observation_date, y =~CUSR0000SEEB) %>%add_lines() %>%layout(title ='Consumer Price Index for College Tuition and Fees',xaxis =list(title ='Date'),yaxis =list(title ='Index'))```The Consumer Price Index for college tuition and fees demonstrates a consistent and steep upward trend from the late 1970s through the present day. Unlike many other consumer goods, college tuition has increased at a rate significantly above general inflation, with only minor slowdowns during economic recessions. The index shows an almost exponential growth pattern, particularly accelerating in the 1990s and 2000s. This sustained increase in tuition costs has major implications for student debt accumulation and accessibility to higher education.```{r}# head(median_household_income)median_income_q <- median_household_income %>%filter(!is.na(MEHOINUSA672N))median_income_q$observation_date <-as.Date(median_income_q$observation_date, format ="%Y-%m-%d")median_income_q %>%plot_ly(x =~observation_date, y =~MEHOINUSA672N) %>%add_lines() %>%layout(title ='Median Household Income in the U.S.',xaxis =list(title ='Date'),yaxis =list(title ='Income ($)'))```Median household income in the United States shows a generally increasing trend over time, but with notable periods of stagnation and decline. The data reveals that income growth has been uneven, with significant drops during recessions (such as 2008-2009) and periods of slow recovery afterward. While nominal income has increased over the decades, when compared to the rate of increase in housing prices and college tuition, household income growth appears more modest, suggesting a growing affordability gap for major expenses like homeownership and education.```{r}# head(first_time_buyer)first_time_buyer_q <- first_time_buyer %>%filter(!is.na(First_Time_Buyers))first_time_buyer_q$Year <-as.numeric(first_time_buyer_q$Year)first_time_buyer_q$First_Time_Buyers <-as.numeric(first_time_buyer_q$First_Time_Buyers)first_time_buyer_q %>%plot_ly(x =~Year, y =~First_Time_Buyers) %>%add_lines() %>%layout(title ='Median Age of First-Time Homebuyers',xaxis =list(title ='Year'),yaxis =list(title ='Age (years)'))```The median age of first-time homebuyers has shown a significant upward trend over the past several decades. In the early 1980s, first-time buyers were typically in their late 20s, but this age has steadily increased to 49 years in recent data - representing a 20-year delay in this critical wealth-building milestone. This aging trend suggests that young adults are facing increasing challenges in achieving homeownership earlier in life, potentially due to factors such as rising home prices, student loan debt, stricter lending standards following the 2008 crisis, and changing economic opportunities. The data shows that key life milestones, including homeownership, are being substantially delayed for younger generations.```{r}# head(business_form_stats)# Clean business formation statisticsbusiness_form_clean <- business_form_stats %>%slice(8:n()) %>%# Start from row 8 where data beginsselect(1, 2) %>%# Select period and value columnsfilter(row_number() >1) %>%# Skip the header rowsetNames(c("period", "applications")) %>%filter(!is.na(period), !is.na(applications)) %>%mutate(date =as.Date(paste0(period, "-01"), format ="%b-%Y-%d"),applications =as.numeric(applications) ) %>%filter(!is.na(date), !is.na(applications))business_form_clean %>%plot_ly(x =~date, y =~applications) %>%add_lines() %>%layout(title ='Business Formation Statistics',xaxis =list(title ='Date'),yaxis =list(title ='Applications'))```Business formation statistics track the number of new business applications over time, serving as an indicator of entrepreneurial activity and economic dynamism. The data shows cyclical patterns corresponding to economic conditions, with surges during periods of economic growth and opportunity. Notably, there appears to be significant variation over time, with recent years showing increased entrepreneurial activity. This metric is important for understanding how education, access to capital, and economic conditions influence individuals' decisions to start new businesses. The relationship between student debt burden and entrepreneurship is of particular interest, as high debt loads may discourage risk-taking and new business creation among young adults.```{r}# head(self_employment_rate)self_employment_q <- self_employment_rate %>%filter(!is.na(LNS12032192))self_employment_q$observation_date <-as.Date(self_employment_q$observation_date, format ="%Y-%m-%d")self_employment_q %>%plot_ly(x =~observation_date, y =~LNS12032192) %>%add_lines() %>%layout(title ='Self-Employment Rate in the U.S.',xaxis =list(title ='Date'),yaxis =list(title ='Rate (%)'))```The self-employment rate reflects the percentage of the workforce that is self-employed, including independent contractors, freelancers, and business owners. This metric has shown a gradual decline over recent decades, suggesting that fewer workers are choosing or able to pursue self-employment opportunities. The downward trend may be influenced by multiple factors including increased student debt burdens that discourage entrepreneurial risk-taking, changing industry structures, healthcare access tied to traditional employment, and shifting preferences among younger workers. Understanding this trend is crucial for assessing how educational debt and economic structures impact innovation and entrepreneurship in the economy.```{r}# head(edu_attainment)# Clean educational attainment data - extract bachelor's degree or higher dataedu_attainment_clean <- edu_attainment %>%slice(7:n()) %>%# Start from data rowsselect(1, 2) %>%# Select year and total percentage columnssetNames(c("year_label", "bachelor_plus_pct")) %>%filter(!is.na(year_label), !is.na(bachelor_plus_pct)) %>%mutate(# Extract year from labels like "1910\\2\\" or "1940"year =as.numeric(str_extract(year_label, "\\d{4}")),bachelor_plus_pct =as.numeric(bachelor_plus_pct) ) %>%filter(!is.na(year), !is.na(bachelor_plus_pct), bachelor_plus_pct !=0) %>%select(year, bachelor_plus_pct) %>%arrange(year)edu_attainment_clean %>%plot_ly(x =~year, y =~bachelor_plus_pct) %>%add_lines() %>%layout(title ='Educational Attainment: High School Completion (Age 25+)',xaxis =list(title ='Year'),yaxis =list(title ='Percentage (%)'))```Educational attainment levels in the United States have shown a consistent upward trend over time, with an increasing percentage of the population aged 25 and over holding a bachelor's degree or higher. This rise in educational attainment reflects the growing importance of higher education for economic opportunity and career advancement. However, this trend also correlates with increased student loan debt as more individuals pursue degrees. The data demonstrates the tension between expanding educational access and the growing financial burden of obtaining that education. Understanding educational attainment trends is essential for analyzing labor market outcomes, income inequality, and the long-term economic impact of education financing policies.---## Story-Telling Visualizations: Key Relationships::: {.hero-banner}### The Big Picture: How Student Debt Impacts Economic OpportunityThese visualizations reveal the interconnected relationships between student loans, housing access, and financial stability.:::### 1. The Diverging Paths: Student Debt vs Young Adult Homeownership```{r fig.height=6, fig.width=10}# Prepare data with matching time periodsstudent_loans_filtered <- student_loans_q %>% filter(observation_date >= "1980-01-01") %>% mutate( year = year(observation_date), quarter = quarter(observation_date) )homeownership_filtered <- homeownership_q %>% filter(observation_date >= "1980-01-01") %>% mutate( year = year(observation_date), quarter = quarter(observation_date) )# Create dual-axis visualizationfig <- plot_ly()# Add homeownership trace (left y-axis)fig <- fig %>% add_trace( data = homeownership_filtered, x = ~observation_date, y = ~RHORUSQ156N, name = "Homeownership Rate (<35 yrs)", type = "scatter", mode = "lines", line = list(color = "#2E86AB", width = 3), yaxis = "y1")# Add student loans trace (right y-axis)fig <- fig %>% add_trace( data = student_loans_filtered, x = ~observation_date, y = ~SLOASM, name = "Student Loan Debt (Billions)", type = "scatter", mode = "lines", line = list(color = "#A23B72", width = 3), yaxis = "y2")# Layout with dual y-axesfig <- fig %>% layout( title = list( text = "<b>The Student Debt Crisis and Declining Young Adult Homeownership</b><br><sub>A Story of Diverging Trajectories (1980-2024)</sub>", font = list(size = 18) ), xaxis = list(title = "Year"), yaxis = list( title = "Homeownership Rate (%)", titlefont = list(color = "#2E86AB"), tickfont = list(color = "#2E86AB") ), yaxis2 = list( title = "Student Loan Debt ($ Billions)", titlefont = list(color = "#A23B72"), tickfont = list(color = "#A23B72"), overlaying = "y", side = "right" ), legend = list( x = 0.5, y = -0.2, xanchor = "center", orientation = "h" ), hovermode = "x unified")fig```::: {.key-finding}**Critical Insight:** As student loan debt skyrocketed to over $1.6 trillion today, homeownership rates among young adults (under 35) plummeted from nearly 44% to below 37%. This inverse relationship suggests that educational debt is a significant barrier to achieving the traditional milestone of homeownership.:::### 2. The Affordability Crisis: Income vs Costs```{r fig.height=6, fig.width=10}# Find the latest start year across all datasetsbase_year <- 1990 # Using 1990 as a safer base year that exists in all datasets# Prepare median income (annual data)income_normalized <- median_income_q %>% mutate(year = year(observation_date)) %>% filter(year >= base_year) %>% group_by(year) %>% summarise(income = mean(MEHOINUSA672N, na.rm = TRUE)) %>% ungroup() %>% mutate( base_value = first(income), index = (income / base_value) * 100, date = as.Date(paste0(year, "-06-01")) )# Prepare tuition (monthly to annual)tuition_normalized <- college_tuition_q %>% mutate(year = year(observation_date)) %>% filter(year >= base_year) %>% group_by(year) %>% summarise(tuition = mean(CUSR0000SEEB, na.rm = TRUE)) %>% ungroup() %>% mutate( base_value = first(tuition), index = (tuition / base_value) * 100, date = as.Date(paste0(year, "-06-01")) )# Prepare housing price indexhpi_normalized <- hpi_us %>% mutate(year = yr) %>% filter(year >= base_year) %>% group_by(year) %>% summarise(hpi = mean(index_nsa, na.rm = TRUE)) %>% ungroup() %>% mutate( base_value = first(hpi), index = (hpi / base_value) * 100, date = as.Date(paste0(year, "-06-01")) )# Create comparison plotfig2 <- plot_ly()fig2 <- fig2 %>% add_trace( data = income_normalized, x = ~date, y = ~index, name = "Median Household Income", type = "scatter", mode = "lines", line = list(color = "#06A77D", width = 3))fig2 <- fig2 %>% add_trace( data = tuition_normalized, x = ~date, y = ~index, name = "College Tuition & Fees", type = "scatter", mode = "lines", line = list(color = "#F18F01", width = 3))fig2 <- fig2 %>% add_trace( data = hpi_normalized, x = ~date, y = ~index, name = "Housing Prices", type = "scatter", mode = "lines", line = list(color = "#A23B72", width = 3))fig2 <- fig2 %>% layout( title = list( text = "<b>The Growing Affordability Gap</b><br><sub>Income Growth vs. Education & Housing Costs (Indexed to 1990 = 100)</sub>", font = list(size = 18) ), xaxis = list(title = "Year"), yaxis = list(title = "Index (1990 = 100)"), legend = list( x = 0.02, y = 0.98, bgcolor = "rgba(255,255,255,0.8)" ), hovermode = "x unified")fig2```::: {.callout-important}**The Widening Gap:** Since 1990, college tuition has increased dramatically faster than income growth, and housing prices have similarly outpaced wage increases. This divergence means that education and homeownership require a much larger share of household income today than they did three decades ago.:::### 3. Generational Delay: Age of First-Time Homebuyers```{r fig.height=5, fig.width=10}# Enhanced first-time buyer visualization with key events annotatedfig3 <- plot_ly( data = first_time_buyer_q, x = ~Year, y = ~First_Time_Buyers, type = "scatter", mode = "lines+markers", line = list(color = "#2E86AB", width = 3), marker = list(size = 8, color = "#F18F01"), text = ~paste("Year:", Year, "<br>Median Age:", First_Time_Buyers), hoverinfo = "text")fig3 <- fig3 %>% layout( title = list( text = "<b>Homeownership Delayed: Rising Age of First-Time Buyers</b><br><sub>Young adults are waiting longer to achieve homeownership</sub>", font = list(size = 18) ), xaxis = list(title = "Year"), yaxis = list(title = "Median Age (years)"), margin = list(t = 100), # Add top margin to prevent annotation overlap shapes = list( # Vertical line for 2008 Financial Crisis list( type = "line", x0 = 2008, x1 = 2008, y0 = 0, y1 = 1, yref = "paper", line = list(color = "#A23B72", width = 2, dash = "dash") ), # Vertical line for COVID-19 list( type = "line", x0 = 2020, x1 = 2020, y0 = 0, y1 = 1, yref = "paper", line = list(color = "#A23B72", width = 2, dash = "dash") ) ), annotations = list( list( x = 2008, y = 1.02, yref = "paper", text = "2008 Financial Crisis", showarrow = FALSE, font = list(color = "#A23B72", size = 11), xanchor = "center" ), list( x = 2020, y = 1.02, yref = "paper", text = "COVID-19 Pandemic", showarrow = FALSE, font = list(color = "#A23B72", size = 11), xanchor = "center" ) ))fig3```::: {.callout-note}**Delayed Milestones:** The median age of first-time homebuyers has increased from approximately 29 years in the 1980s to 49 years today - a 20-year delay. This shift represents a fundamental change in the timeline of adult financial milestones, with far-reaching implications for wealth accumulation, family formation, and retirement planning.:::### 4. Regional Inequality: Housing Value Tiers```{r fig.height=6, fig.width=10}# Combine all ZHVI data for comparisoncombined_zhvi <- bind_rows( mount_vernon_b_long %>% mutate(location = "Mount Vernon - Bottom Tier", tier = "Bottom"), mount_vernon_t_long %>% mutate(location = "Mount Vernon - Top Tier", tier = "Top"), bronxville_b_long %>% mutate(location = "Bronxville - Bottom Tier", tier = "Bottom"), bronxville_t_long %>% mutate(location = "Bronxville - Top Tier", tier = "Top"))fig4 <- plot_ly(data = combined_zhvi)# Add traces for each locationcolors <- c( "Mount Vernon - Bottom Tier" = "#06A77D", "Mount Vernon - Top Tier" = "#2E86AB", "Bronxville - Bottom Tier" = "#F18F01", "Bronxville - Top Tier" = "#A23B72")for (loc in unique(combined_zhvi$location)) { plot_data <- combined_zhvi %>% filter(location == loc) fig4 <- fig4 %>% add_trace( data = plot_data, x = ~date, y = ~hvi, name = loc, type = "scatter", mode = "lines", line = list(color = colors[loc], width = 2.5) )}fig4 <- fig4 %>% layout( title = list( text = "<b>Housing Inequality: Comparing Market Tiers</b><br><sub>Westchester County, NY - Bottom vs Top Tier Home Values</sub>", font = list(size = 18) ), xaxis = list(title = "Year"), yaxis = list(title = "Home Value Index ($)"), legend = list( x = 0.02, y = 0.98, bgcolor = "rgba(255,255,255,0.9)" ), hovermode = "x unified")fig4```::: {.key-finding}**Economic Stratification:** The gap between top-tier and bottom-tier home values has widened significantly over time. In Mount Vernon, top-tier homes reached nearly $850K at their peak while bottom-tier homes peaked around $350K. This growing disparity creates different housing markets with vastly different accessibility for first-time buyers burdened by student debt.:::::: {.content-card}**Putting It All Together:**These story-telling visualizations reveal a clear pattern: as student loan debt has exploded and the costs of education and housing have far outpaced income growth, young adults face unprecedented barriers to achieving traditional economic milestones. The data shows that:1. **Student debt and homeownership move in opposite directions** - suggesting a direct trade-off2. **The affordability gap is widening** - income hasn't kept pace with essential costs3. **Milestones are being delayed** - first-time buyers are 7 years older than previous generations4. **Inequality is growing** - housing market stratification creates different realities for different income levelsThese insights set the stage for our deeper time series analysis to quantify these relationships and explore potential policy interventions.:::---## Educational Outcomes: Mount Vernon vs Bronxville::: {.hero-banner}### The Education-Housing ConnectionComparing school performance in neighboring Westchester County districts reveals how educational opportunity intersects with housing markets and economic mobility.:::```{r include=FALSE}# Load school dataschool_data <- read_csv("data/processed/graduation_summary.csv", show_col_types = FALSE)# Clean and prepare - aggregate data by district and yearschool_clean <- school_data %>% mutate( year_end = as.numeric(str_extract(year, "\\d{4}$")) + 2000, district_short = ifelse( str_detect(district_name, "BRONXVILLE"), "Bronxville", "Mount Vernon" ) ) %>% # Filter out rows with NA enrollment (can't weight properly) filter(!is.na(enrollment), enrollment > 0) %>% # Aggregate by district and year (weighted averages by enrollment) group_by(year, year_end, district_short) %>% summarise( total_enrollment = sum(enrollment, na.rm = TRUE), grad_pct_num = sum(grad_pct_num * enrollment, na.rm = TRUE) / sum(enrollment[!is.na(grad_pct_num)], na.rm = TRUE), dropout_pct_num = sum(dropout_pct_num * enrollment, na.rm = TRUE) / sum(enrollment[!is.na(dropout_pct_num)], na.rm = TRUE), regents_pct_num = sum(regents_pct_num * enrollment, na.rm = TRUE) / sum(enrollment[!is.na(regents_pct_num)], na.rm = TRUE), regents_adv_pct_num = sum(regents_adv_pct_num * enrollment, na.rm = TRUE) / sum(enrollment[!is.na(regents_adv_pct_num)], na.rm = TRUE), enrollment = total_enrollment, .groups = 'drop' )```### 6. Connecting Education to Housing Values```{r fig.height=7, fig.width=12}# Combine school data with housing data for comparison# Using average graduation rate per districtschool_avg <- school_clean %>% group_by(district_short) %>% summarise( avg_grad_rate = mean(grad_pct_num, na.rm = TRUE), avg_dropout = mean(dropout_pct_num, na.rm = TRUE) )# Get average home valueshousing_avg <- bind_rows( mount_vernon_b_long %>% filter(year(date) >= 2015, year(date) <= 2018) %>% summarise( district = "Mount Vernon", avg_value = mean(hvi, na.rm = TRUE) ), bronxville_b_long %>% filter(year(date) >= 2015, year(date) <= 2018) %>% summarise( district = "Bronxville", avg_value = mean(hvi, na.rm = TRUE) ))# Mergecomparison_df <- school_avg %>% left_join(housing_avg, by = c("district_short" = "district"))# Create side-by-side comparisonp1 <- plot_ly( data = comparison_df, x = ~district_short, y = ~avg_grad_rate, type = "bar", marker = list(color = c("#A23B72", "#2E86AB")), text = ~paste0(round(avg_grad_rate, 1), "%"), textposition = "outside", name = "Graduation Rate") %>% layout( yaxis = list(title = "Graduation Rate (%)", range = c(0, 100)), xaxis = list(title = ""), showlegend = FALSE)p2 <- plot_ly( data = comparison_df, x = ~district_short, y = ~avg_value, type = "bar", marker = list(color = c("#A23B72", "#2E86AB")), text = ~paste0("$", format(round(avg_value/1000, 0), big.mark = ","), "K"), textposition = "outside", name = "Home Value") %>% layout( yaxis = list(title = "Median Home Value ($)"), xaxis = list(title = ""), showlegend = FALSE)# Combinesubplot(p1, p2, nrows = 1, margin = 0.08, shareX = TRUE) %>% layout( title = list( text = "<b>The Education-Housing Connection</b><br><sub>School Performance vs Housing Values (2015-2018 Average)</sub>", font = list(size = 12), x = 0.5, xanchor = "center" ) )```::: {.content-card}**The Cycle of Inequality:**These visualizations reveal how education and housing create a reinforcing cycle:1. **Higher home values → Better-funded schools** (property tax base)2. **Better schools → Higher graduation rates** (resources, teachers, programs)3. **Higher graduation → More college access** (less reliance on student loans)4. **College degrees → Higher income** (better job opportunities)5. **Higher income → Homeownership** (ability to buy in better districts)**Mount Vernon Context:**- Average home value: ~$420K (bottom tier)- Graduation rate: ~65%- Dropout rate: ~7%- Demographics: Majority Black/Latino, high economic disadvantage**Bronxville Context:**- Average home value: ~$775K (bottom tier)- Graduation rate: ~98%- Dropout rate: <1%- Demographics: Majority White, low economic disadvantageThis disparity, occurring within the same county, demonstrates how housing segregation perpetuates educational inequality—which in turn affects student debt burdens and future homeownership prospects for the next generation.:::