At one point, I decided that I wanted to track the cost of living of every place, so I started delving into American Community Survey data to find what I needed. I wound up picking three variables to display: median annual income, median monthly housing cost, and median housing cost as a percentage of income.
I had to aggregate a bunch of stuff together for this, as the data was divided up between renters, owners with a mortgage, and owners without a mortgage.
Here's the query I made against the ACS API to pull the data I needed: http://api.census.gov/data/2015/acs5?get=NAME%2CB25106_001E%...
For the purposes of this post, I'll call the pieces of data this gives me by the following names (I don't remember if this is in the same order the API call returns... I'm copying and pasting this from notes I took when I was coming up with my calculations):
housingunits
renters
owners
ownersmortgage
ownersnomortgage
grent
smocmortgage
smocnomortgage
annualincome
First five variables are totals, the next four are all median values. SMOC stands for "selected monthly ownership costs", which is basically mortgage (if applicable) + property taxes + average utility payment. Grent stands for "gross rent" and is rent + average utility payment.
I then can do the following intermediate calculations:
rentpct = renters / housingunits
ownerpct = owners / housingunits
mortgagepct = ownersmortgage / owners
nomortgagepct = ownersnomortgage / owners
monthlyincome = annualincome / 12
And get the data points that will be displayed on the model's UI:
housingcost = grent * rentpct + (smocmortgage * mortgagepct + smocnomortgage * nomortgagepct) * ownerpct
housingcostapi = housingcost / monthlyincome
("api" here stands for "as percentage of income", and the acronym is used heavily within the American Community Survey's documentation of their income data, so I picked it up as wlel)
(and I'm displaying annualincome as well, which is just raw data from the ACS and not a calculation)
I've found that nicer places tend to have a lower housingcostapi, but within a narrow range. A wealthy suburb might be around 20%, while the ghetto might be around 30%. But there are tons of exceptions... middle-class suburbs tend to run a really wide gamut all over the 20s, so I wouldn't consider things like "20% housingcostapi = filthy rich people" to be gospel.
I'm not comfortable linking my census tool here because I've yet to set up safeguards to prevent my server from getting hammered by crawlers (my tool has a very large amount of dynamically-generated graphics that are CPU intensive to generate and are then cached... and there are so many possible permutations that a crawler could easily exhaust my disk space), but I might consider sending the link privately to people if I think they won't share it publicly.