$ show PSLmodels/Tax-Calculator
Tax-Calculator is a mature, open-source microsimulation library for static (and simple behavioral) analysis of the US federal individual income and payroll tax system. It provides a Python API and a CLI tool (`tc`) that allow users to define policy reforms via JSON parameter files, apply them to microdata samples (CPS, PUF, or TMD), and produce distributional tables, revenue estimates, marginal tax rates, and welfare measures. The core architecture separates policy parameters (`Policy`), taxpayer records (`Records`), and economic adjustments (`GrowFactors`, `GrowDiff`, `Consumption`) from the calculation engine (`Calculator`), which uses Numba JIT compilation for performance. While primarily an application/library with formal releases and CI/CD, it also bundles research data (CPS microdata, grow factors) and includes extensive cross-validation against NBER's TAXSIM-35 model. The codebase is well-structured, heavily tested, and actively maintained, with a clear modular design that supports both CLI and programmatic use.
The LLM identified 2 files worth highlighting for reuse:
Provides `iterate_jit` and `JIT` decorators that wrap numerical functions with Numba's `njit` for vectorized array computations. Includes a global `DO_JIT` toggle (settable via environment variable or API) to fall back to pure Python for debugging. This pattern is self-contained (only depends on numpy and numba) and can be extracted for any project needing optional JIT acceleration on array operations.
Implements weighted statistical functions (`weighted_mean`, `wage_weighted_mean`, `agi_weighted_mean`, `expanded_income_weighted_mean`) that operate on numpy arrays with sample weights. No internal package dependencies beyond numpy; these functions are reusable for any weighted survey data analysis and are parameterized by the weight array and optional filter.