Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HMDA Analysis

Code and methodology for analyzing Home Mortgage Disclosure Act (HMDA) loan-level data and FFIEC Census data: mortgage-lending patterns, geographic disparities, tract-boundary corrections across vintages, longitudinal time-series, systemic-bank analysis, and a Python replication of published R methodologies (incl. a Bhutta-style replication).

This is a code-only release. The underlying HMDA LAR and Census corpora (hundreds of GB) are not included — see data/MANIFEST.md for the public sources and download links.

Repository layout

  • Technical/src/ — analysis library
    • hmda/, census/ — loaders / parsers for HMDA LAR and FFIEC Census flat files
    • analysis/ — disparity, geographic-aggregation, longitudinal, multi-scope analyses
    • bhutta_replication/ — Python port of the R replication (multiple iterations + diagnostics)
    • validation/, quality/ — tract-boundary correction/validation and data-quality monitors
    • api/ — Flask / Streamlit / FastAPI dashboards
  • Technical/scripts/ — CLI entry points
  • Technical/src/api/hmda_dashboard.py — the maintained Streamlit dashboard
  • Technical/src/api/stakeholder_dashboard.py — the Flask dashboard served by the Docker image
  • update_dashboard_data.py — dashboard data refresh
  • streamlit_dashboard.pystale stub, do not run; it is kept only as a pointer to the dashboard above (it showed a mislabeled approval rate)
  • comprehensive_*.py, hmda_master_workflow.py — top-level orchestration

Setup

python -m venv .venv
source .venv/bin/activate        # Windows: .venv\Scripts\activate
pip install -r requirements.txt

Data location (required)

The code reads inputs from DATA_ROOT and writes outputs to OUTPUT_ROOT, both set via environment variables (defaults: ./data and ./outputs). Point them at where you have downloaded the HMDA / Census data (see data/MANIFEST.md):

export DATA_ROOT=/path/to/your/hmda-and-census-data
export OUTPUT_ROOT=/path/to/where/outputs/should/go
$env:DATA_ROOT = "D:\path\to\data"
$env:OUTPUT_ROOT = "D:\path\to\outputs"

Inside DATA_ROOT, the loaders expect the original sub-layout (e.g. Inputs/Old/CRA_code/..., Inputs/Old/Python Stuff/schemas/...); data/MANIFEST.md documents which public files populate each path. Copy .env.example to .env and edit if you prefer a dotenv file.

Run

# Census flat-file parser
python "Technical/src/census/census_full_parser.py"

# Bhutta-style replication (latest)
python Technical/src/bhutta_replication/r_modified/bhutta_replication_FINAL.py

# Dashboard (Streamlit)
streamlit run Technical/src/api/hmda_dashboard.py

Do not run the root-level streamlit_dashboard.py: it is a stale stub kept only as a pointer (see the repository layout above).

Docker (optional)

The image in Dockerfile serves the Flask dashboard (Technical/src/api/stakeholder_dashboard.py) with Gunicorn on port 5000:

docker build -t hmda-analysis .
docker run --rm -p 5000:5000 -e SECRET_KEY=$(python -c "import secrets; print(secrets.token_hex(32))") hmda-analysis

The dashboard reads pre-processed outputs, so it renders real numbers only once you have run the analysis pipeline and mounted the results (see docker-compose.yml). This project is not hosted anywhere — there is no public deployment to visit.

API keys — bring your own

The analysis pipeline runs on local files and needs no API keys. The dashboards expose only operational settings (see .env.example): SECRET_KEY (generate your own with python -c "import secrets; print(secrets.token_hex(32))"), host/port, CORS, and optional GOOGLE_ANALYTICS_ID / SENTRY_DSN. None are required to run the analysis code.

Data

HMDA and FFIEC Census data are public. This repository ships no data. Download the required inputs yourself per data/MANIFEST.md and set DATA_ROOT.

License

This project is dual-licensed:

  • Code — MIT License.
  • Data & documentation produced by this project — Creative Commons Attribution 4.0 International (CC BY 4.0).

See LICENSE for the full text of both and LICENSES.md for a plain-language summary of which applies where. HMDA LAR and FFIEC Census data are U.S. public data and retain their own terms.

About

Analysis code for HMDA loan-level mortgage data and FFIEC Census files: lending disparities, tract-boundary corrections across vintages, longitudinal series, systemic-bank metrics, and a Python replication of published R methodology. Code-only; no data shipped.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages