Skip to main content

Census ACS data pull and fixed effects models for Utah housing research

Project description

utah-housing

Census ACS 5-year data fetcher and fixed effects models for Utah housing research.

Setup

pip install -e ".[dev]"
export CENSUS_API_KEY=your_key_here  # https://api.census.gov/data/key_signup.html

Usage

Pull data

from utah_housing import fetch_all_years

df = fetch_all_years(years=range(2009, 2024))
df.to_csv("utah_housing_2009_2023.csv", index=False)

Pull a single year:

from utah_housing import fetch_year

df_2022 = fetch_year(2022)

Run models

import pandas as pd
from utah_housing import run_base_model, run_complex_model, compare_models

df = pd.read_csv("utah_housing_2009_2023.csv")

result1, coef1 = run_base_model(df)
result2, coef2 = run_complex_model(df)

comparison = compare_models(coef1, coef2)
coef1.to_csv("base_results.csv")
coef2.to_csv("complex_results.csv")

Run diagnostics

from utah_housing.models import run_diagnostics
from utah_housing import COMPLEX_PREDICTORS

run_diagnostics(df, COMPLEX_PREDICTORS)

Models

Model Fixed effects Extra predictor
Base tract + year
Complex tract + county×year pop_in_occupied_total

Outcome: median_owner_costs_with_mortgage

Predictors:

  • pct_sf_renter_occupied — share of single-family homes that are renter-occupied (investor proxy)
  • median_household_income — demand-side income
  • owner_renter_income_gap — income stratification signal
  • pct_vacant — market slack

Data tables pulled

Table Description
B25024 Units in structure
B25001 Total housing units
B25002 Occupancy status
B25003 Tenure (owner vs. renter)
B25008 Population in occupied housing by tenure
B25119 Median household income by tenure
B25032 Units in structure by tenure
B25088 Median monthly owner costs
B19013 Median household income

Package layout

utah_housing/
├── __init__.py      # public API
├── variables.py     # all ACS variable lists, rename map, model variable sets
├── fetch.py         # Census API fetcher
└── models.py        # fixed effects models + diagnostics

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

utah_housing-0.1.0.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

utah_housing-0.1.0-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file utah_housing-0.1.0.tar.gz.

File metadata

  • Download URL: utah_housing-0.1.0.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for utah_housing-0.1.0.tar.gz
Algorithm Hash digest
SHA256 962473fe5d5dae0e0e4060f0208ab39f57b99087390be44d750be657951d5e63
MD5 5cf6b9e111a81420810f1ce13e506a2d
BLAKE2b-256 4efaff8e56a944f05874d8f778ea398be81099c7fb35c3935ba1ae78f3e118bb

See more details on using hashes here.

File details

Details for the file utah_housing-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: utah_housing-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for utah_housing-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bfef1161bfc11a6f253d112ce183637dc088a0bd7942c03422a0a0a92be95cb2
MD5 bbb2fb12d8f7e96f6b5ec48d3fccab4c
BLAKE2b-256 84edfe1f93fb752f5d8bc9115c76c57f0763611bbc6cfffbb02444af96bf3b75

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page