How could Coronavirus layoffs impact Home Prices in the United States

May 13, 2020
Please take this post with a grain of salt. Its purpose is to demonstrate how to analyze simple datasets with Python, not how to make gold standard econometric predictions of home price changes based on unemployment rates. But since this is an actual question on many minds right now (including my own), I thought a 15 min exercise would be interesting.
So, we are going to look at the likely impact of the recent surge in the unemployment rate on home prices in the United States as a whole, as well as New York City and San Francisco.
If you are interested: the Python script that I used to build the charts below and make my predictions for home prices is at the bottom of the page.
I have broken the rest of this post into two sections. First, I answer the question posed, and make a prediction for future home prices. After that I will give a brief description of how this can be accomplished with Python (including the full script that you can run!).

What has been the impact of the COVID-19 corona virus lockdown on the U.S. Unemployment Rate?

This is more than a little worrying. The most recent unemployment numbers just came in at 14.7%. This is a massive increase from the prior range of 3%-4% over the last few years. This is even higher than the peaks seen in the 1970's and following the 2008 financial crisis.
Negative Chart
Turning to home prices, during the last serious financial crisis of 2008, we can see that home prices in the United States declined significantly. It is safe to assume that the recent unemployment numbers forecast another decline in home prices over the next few years - and possibly even greater than the decline seen in 2008.
Negative Chart

How much are home prices likely to decline?

If we assume that the past relationship between the Unemployment Rate and the U.S. Home Price Index holds over the next year or two, then this points to rather large (massive) declines in the value of homes across the United States.
If we run a simple OLS Regression with the Scipy module in Python, we can see that there is a negative relationship between changes in the unemployment rate and home prices for the US as a whole, New York City, and San Francisco.
In the below three charts we are regressing the change in Unemployment Rates against the change in each respective Home Price Index.

United States Home Price Index

Negative Chart

New York Home Price Index

Negative Chart

San Francisco Home Price Index

Negative Chart
Using the slope and intercept from each regressions above, we can make a prediction for the change in the Home Price Index for each series. Below we are using the most recent change in unemployment rates to compute the change in each respective Home Price Index.
Run the script at the bottom of this post, you should get the following (as of May 12, 2020) .
$ python3 Next Predicted Value for the change in United States HPI = -0.155293176776611 Next Predicted Value for the change in New York HPI = -0.1368264382570524 Next Predicted Value for the change in San Francisco HPI = -0.3806935848320704
A simple OLS regression points to the following:
(1) United States home prices are likely to decline by 15.5%
(2) New York home prices are likely to decline by 13.7%
(3) San Francisco home prices are likely to decline by a whopping 38%!

How can this be calculated with Python?

This script below can be broken down info a few steps:
(1) Pull all of the data needed from the FED FRED API
(2) Clean the data and prep a regression data set so that we regress the monthly change in unemployment and home prices
(3) Run an OLS regression to determine the intercept and beta for each data set
(4) Make a prediction using the most recent US Unemployment Rate and our estimated regression parameters

The Python Script

Note: You will need to get a FED FRED API key to run this. The good news is that it is free and takes 2 minutes to get on the FED FRED website.
from fredapi import Fred import numpy as np import pandas as pd import matplotlib.pyplot as plt import scipy.stats as stats import pickle api_key = 'your_api_key_goes_here' fred = Fred(api_key=api_key) def get_data(series_id, series_name): try: unemployment_data = pickle.load(open(series_name + '.pickle', "rb")) except (OSError, IOError) as e: unemployment_data = fred.get_series(series_id) pickle.dump(unemployment_data, open(series_name + '.pickle', "wb")) return unemployment_data def run_regression(d): # Get Data from Fed Fred unemployment_data = get_data('UNRATE', 'unemployment_data') home_price_data = fred.get_series(d['series']) # Clean/Prep data - we want to regress the changes in unemployment rates vs changes in HPI # Convert to DataFrame unemployment_data = unemployment_data.to_frame() unemployment_data.columns = ['Unemployment Rate'] home_price_data = home_price_data.to_frame() home_price_data.columns = ['Home Price Index'] # Merge data on dates all_data = pd.concat([unemployment_data, home_price_data], axis=1) all_data.columns = ['Unemployment Rate', 'Home Price Index'] # Add a few more rows to make the last bit of data easy to see on the charts for i in range(18): next_timestamp = all_data.index[-1] + pd.DateOffset(months=1) all_data.loc[next_timestamp] = np.NaN # Plot the data all_data['Unemployment Rate'].plot(linewidth=3, color='#4169e1') plt.title('Unemployment Rate') plt.xlabel('Year') plt.ylabel('%') plt.savefig('unemployment.png') plt.close() all_data['Home Price Index'].plot(linewidth=3, color='#bab86c') plt.title(d['title'] + ' Home Price Index') plt.xlabel('Year') plt.ylabel(d['title'] + ' HPI') plt.savefig(d['series_name'] + '.png') plt.close() # Calculate changes all_data['d Unemployment Rate'] = np.NaN all_data['d Home Price Index'] = np.NaN for i in range(1, len(all_data.index)): cols = [ ('Unemployment Rate', 'd Unemployment Rate'), ('Home Price Index', 'd Home Price Index') ] indx0 = all_data.index[i-1] indx = all_data.index[i] for col, dCol in cols : all_data.loc[indx, dCol] = all_data.loc[indx, col] / all_data.loc[indx0, col] - 1.0 all_data.dropna(inplace=True) # Drop Missing data regression_data = all_data.drop(columns=['Unemployment Rate', 'Home Price Index']) regression_data.dropna(inplace=True) # Run a Regression between Home Prices and Unemployment Rates slope, intercept, r_value, p_value, std_err = stats.linregress( regression_data['d Unemployment Rate'], regression_data['d Home Price Index'] ) plt.scatter( regression_data['d Unemployment Rate'], regression_data['d Home Price Index'], color='#2e1460', marker='o' ) plt.title( r'$\rho = $' + str(round(r_value, 2)) + ' ' + r'$\beta = $' + str(round(slope, 2)) ) plt.xlabel('d Unemployment Rate') plt.ylabel('d ' + d['title'] + ' HPI') line_plot = np.linspace( regression_data['d Unemployment Rate'].min(), regression_data['d Unemployment Rate'].max(), 100 ) plt.plot(line_plot, line_plot * slope + intercept, color='gray', linewidth=3) plt.savefig('Unemployment-' + d['series_name'] + '-HPI-Regression.png') plt.close() # Predict Impact on Home Prices hpi_change_pred = intercept + \ (slope * unemployment_data['Unemployment Rate'][-1] / unemployment_data['Unemployment Rate'][-2]) print('Next Predicted Value for the change in ' + d['title'] + ' HPI = ' + str(hpi_change_pred)) hpi_markets = [ { 'title' : 'United States', 'series' : 'CSUSHPISA', 'series_name' : 'US_HPI' }, { 'title' : 'New York', 'series' : 'NYXRSA', 'series_name' : 'NY_HPI' }, { 'title' : 'San Francisco', 'series' : 'SFXRSA', 'series_name' : 'SF_HPI' } ] if __name__ == '__main__': for d in hpi_markets: run_regression(d)