|
| 1 | +--- |
| 2 | +title: "Model architecture" |
| 3 | +--- |
| 4 | + |
| 5 | +PolicyEngine models tax and benefit systems as a set of country packages wrapped by the `policyengine` Python interface. The country packages contain the policy rules; this package provides the user-facing calculation and analysis surface. |
| 6 | + |
| 7 | +This page describes the documentation structure we would choose if starting fresh. |
| 8 | + |
| 9 | +## Three layers |
| 10 | + |
| 11 | +PolicyEngine documentation should keep three layers separate: |
| 12 | + |
| 13 | +| Layer | Owns | Should answer | |
| 14 | +|---|---|---| |
| 15 | +| Methodology | Authored prose | Why the model is structured this way, how concepts flow, where assumptions enter | |
| 16 | +| Program pages | Authored prose plus generated links | What a program does, who qualifies, how values and household costs are represented | |
| 17 | +| Reference | Generated from code and data packages | What variables, parameters, programs, sources, and calibration targets exist in a release | |
| 18 | + |
| 19 | +This split avoids two common failure modes: |
| 20 | + |
| 21 | +- Long-form methodology pages becoming stale variable catalogs. |
| 22 | +- Generated reference pages trying to explain modeling choices that need narrative context. |
| 23 | + |
| 24 | +## Source of truth |
| 25 | + |
| 26 | +The source of truth should depend on content type: |
| 27 | + |
| 28 | +| Content | Source | |
| 29 | +|---|---| |
| 30 | +| Formulas, entities, variable metadata | Country model packages such as `policyengine-us` | |
| 31 | +| Parameter values, uprating, legislative references | Country model parameter YAML | |
| 32 | +| Microdata construction, imputations, calibration targets | Country data packages such as `policyengine-us-data` | |
| 33 | +| User tutorials, model-wide methodology, program narratives | `policyengine.py` docs | |
| 34 | + |
| 35 | +The documentation site should not manually copy reference metadata that can be regenerated from a release. It should explain how the generated pieces fit together. |
| 36 | + |
| 37 | +## Rules, data, calibration, outputs |
| 38 | + |
| 39 | +A complete model page should be explicit about four pieces: |
| 40 | + |
| 41 | +1. Rules: statutory formulas and administrative program rules. |
| 42 | +2. Data: the household or person records to which rules are applied. |
| 43 | +3. Calibration: adjustments that align the data and model outputs with external targets. |
| 44 | +4. Outputs: the resource, budget, poverty, inequality, and distributional concepts returned to users. |
| 45 | + |
| 46 | +For example, a program page should not stop at eligibility. It should say how benefit value is represented, whether household-paid costs are modeled, what data inputs are required, and how the program enters aggregate output concepts. |
| 47 | + |
| 48 | +## What belongs in generated reference |
| 49 | + |
| 50 | +Generated reference pages should include: |
| 51 | + |
| 52 | +- variable name, entity, period, unit, label, and documentation |
| 53 | +- `adds`, `subtracts`, and `defined_for` relationships |
| 54 | +- source file path and source line |
| 55 | +- parameter value history and references |
| 56 | +- program coverage metadata |
| 57 | +- calibration target source, vintage, unit, and current model fit |
| 58 | + |
| 59 | +The existing reference generator is a prototype for the variable and program parts. Parameter and data-lineage generation should follow the same pattern. |
| 60 | + |
| 61 | +## What belongs in authored methodology |
| 62 | + |
| 63 | +Authored methodology pages should focus on model choices: |
| 64 | + |
| 65 | +- why a decomposition exists |
| 66 | +- which entity owns a concept |
| 67 | +- how gross and net quantities differ |
| 68 | +- where a reform can change outcomes |
| 69 | +- what is intentionally left as an imputed residual |
| 70 | +- what current limitations users should know before interpreting outputs |
| 71 | + |
| 72 | +That is the structure used by the first new US health-cost page. |
| 73 | + |
0 commit comments