# US House Prices, Default and Bankruptcy Rates in R

**plausibel**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Some time ago I got inspired by a post on r-bloggers.com, showing the housing bubble in several US cities, nicely done with ggplot. I extended this to incorporate two measures of problems in the consumer credit markets: the percentage of people with a new bankruptcy, and the percentage of people with a new foreclosure, in each quarter from 2006 up to the end of 2011. The data are public (S&P Case-Shiller and NY Fed credit data).

I know this relationship is kind of common knowledge – at least for the foreclosure part – but I was surprised as to how pronounced it is. I did this for 2 groups of states. In both groups, in general, states whose house price came down from a higher level, have more people getting into credit difficulties. (I am not trying to establish a causal relationship here.)

I often find that preparing the data is much more demanding than actually producing the plot (which tells you something about the quality of ggplot). For this plot I had to learn some new things (date formatting, time series aggregation from {zoo}), all of which I found on the web (stackoverflow mostly), so thanks to all for sharing. I post my code below, maybe somebody finds it useful.

**UPDATE: **I got a useful comment for another visualization. Using phaseplots, or just plotting bankruptcy/default rates against the house price index. Here I add the time dimension as an additional layer in the plot (i label some points with their date), Here is what you get:

**leave a comment**for the author, please follow the link and comment on their blog:

**plausibel**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.