US State Level Choropleth using FHFA HPI Data

. 1 min read

My LinkedIn News (spam?) feed just flashed an interesting choropleth of housing price changes across states (House Prices in Sep 2016 relative to pre-2008 peak)

House Prices in Sep 2016 relative to pre-2008 peak

I'll try to replicate something similar using FHFA data available here

For ease, I'm actually plotting the Price Index itself for Q3-2016 for purchase-only transactions. choroplethr & choroplethrMaps are the packages that make this job really easy!

I use stringdist for some fuzzy matching to cater to the package requirements. Yeah! My sweet little AI tool! :-) ... any it actually works perfectly! ;-)

Here is the output and it is amazing to be able to produce such a neat graphic with so little code!

TODO: I'll revisit this for a lot of analysis that can done from this wealth of information as I find time

Q3-2016 State-Level-Choropleth-using-FHFA-HPI-Data.png

Here is the code!

require("data.table")
dt <- fread("data/HPI_master.csv")


# Let us get the state level data for purchase-only transactions
dt <- dt[yr==2016][level=="State"][period == 3][hpi_flavor == "purchase-only"]

# Credit: https://cran.r-project.org/web/packages/choroplethr/vignettes/b-state-choropleth.html
library(choroplethr)
library(choroplethrMaps)

# install.packages('stringdist')
require("stringdist")
standard_states <- state.regions$region
dt[,state_num:=amatch(place_name, standard_states, maxDist = 5)]

dt[,state_final:=standard_states[state_num]]
dt[,region:=state_final]
dt[,value:=as.numeric(index_nsa)]
state_choropleth(dt)

Tags

AWS Analytics Antifragile Apache Spark Apple Apps Arbitrage Automation Awesome BBMP Bangalore Black Swan Bonds Boonex Bootstrap Brokerage Charges CFPB CMS CSS Calypso Camelot Capital Markets Charts Chirp Choropleth Chrome Code Igniter Collections Containerization Converters Cycling DalalBeat Data Analytics Data Journalism Data Mining Data Munging Data Privacy Data Science Databases Debt Design Design Stock DesignStock Diet Django Docker Document Processing Dropbox Electron Electronics Entertainment Entrepreneurship Exercise FFMPEG Facebook Finance Fire TV Stick Fitness Forerunner From-The-News Fun Futures Gaana Garmin General Geocoding Getting Started Ghost Google APIs GraphicsMagick HHVM HTTPS Hackathon Hacks Hardware Health House Keeping Housing IBM BlueMix IBrokers IPinfo Ideas Image Conversion Image Processing Infographics Interactive Brokers Internet Investing IoT Legal Lets Encrypt Mac Machine Learning Mailbox app Mapbox Markdown Marketing Meteor Mockups MongoDB Mortgages Movies Music MyPad MySQL Nativefier Nature Netflix Newsletters Nginx Node.js Notes OCR OSX Open Source OpenCPU Options PDF PHP Pebble Peloton Personal Photography Picture Platforms Plex Portable Apps Productivity Property Tax PyroCMS Quantitative Finance R-Project Random Raspberry Pi Research Resources Reticulate Robot S3 SQLite STT Scraping Security Server Shell Shiny Side Project Sikuli Speech Recognition Spider Pro Spinning Spotify Startup Resources Startups Strategy Sublime Text System Monitoring Tax Terminal Tips To Do Tools Torrent Trading Trends Troubleshooting USElection2016 Ubuntu Unix Valuations Video Conversion Visualization Wagtail Wearables Weekend Fun WhatsApp Wordpress anaconda annie bash catalina cv2 daily coding dailycoding data.table debugging devtools downloader e-Signatures ggplot git go google maps hat-tip iOS iPad iPhone iTunes javascript jupyter logging macos numpy opencv optionality plotly python rstats videos youtube