psrc / urbansim2

3 stars 0 forks source link

Figure out best way to calculate mortgage/housing cost #137

Open stefancoe opened 6 years ago

stefancoe commented 6 years ago

@hanase As discussed in the email string, there seems to be an issue with how the mortgage cost variable (beyond the issue with existing_units) is calculated on the housing table. I tested the following simplified version suggested by Mike and it seems to result in more realistic values:

return buildings.price_per_unit * .06

Instead of: pbsqft = misc.reindex(parcels.building_sqft_pcl, buildings.parcel_id).replace(0, np.nan) return (0.06/12 (1+0.06/12)360)/((((1+0.06/12)360)-1)12) ( buildings.unit_price buildings.building_sqft_per_unit + buildings.sqft_per_unit.divide(pbsqft).fillna(0) * misc.reindex(parcels.land_value, buildings.parcel_id))

stefancoe commented 6 years ago

Also, for context, I discovered these issues while debugging an estimated coeffiicent of -3 on the hlcm for this variable: I((income>0)1):I(1(np.logical_or(mortgage_cost/income < 0.1, mortgage_cost/income > 0.5)))

This variable now estimates with the fix to parcels.existing units: https://github.com/psrc/urbansim2/issues/136

hanase commented 6 years ago

@stefancoe - it is still giving me coefficient 3. (I fixed the households_for_estimation by selecting only the "for_estimation" records rather than the whole households dataset.)

stefancoe commented 6 years ago

@hanase I will take a look tomorrow.

stefancoe commented 6 years ago

@hanase see this commit: https://github.com/psrc/urbansim2/commit/9eee5936fd77e545e370684fc7bf58b988d944a8

I do not get coefficient = 3 when I use mortgage_cost2, but I do for the 'True' (in_migrants) model when I use the old mortgage_cost variable.

hanase commented 6 years ago

Thanks @stefancoe - I updated the repo and it works now. (Thought I still get coef 3 for multifamily_generic_type for in_migrants.)

BTW, in the commit above you have choosers_fit_filters: [building_id > 0, for_estimation == 1] We don't need the for_estimation filter as the households_for_estimation are filtered in datasources.py. Similarly for jobs_for_estimation.