feat(eeio): derive y_nab from Adom and scaled_q#458
Open
bl-young wants to merge 1 commit into
Open
Conversation
Backcompute national-accounting final demand from the same derive_cornerstone_Aq_scaled() path as scaled_q, enforcing q ≈ L_dom @ y_nab.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
cc:
Closes: #456
What changed? Why?
y_nab_USAfor the Cornerstone full model (2025_usa_cornerstone_full_model) is derived from the samederive_cornerstone_Aq_scaled()object that produces snapshottedscaled_q_USAandAdom_USA, viabackcompute_y_from_q_and_Aq(Adom, scaled_q). That enforces IO row balanceq = Adom @ diag(q) + y_naband domestic Leontief consistencyq ≈ L_dom @ y_nab.The prior path built
y_nabfrom BEA Y/trade disaggregation and inflation — parallel to the A/qpipeline and inconsistent with snapshottedscaled_q(323 commodity sectors failedq ≈ L·yat 1% tolerance on the domestic branch).derive_cornerstone_y_nab— replaces the BEA disaggregation/inflation body with a three-line backcompute fromderive_cornerstone_Aq_scaled(). Negativey_nabvalues are retained;handle_negative_vector_valuesbreaks the domestic Leontief identity becauseL_domis dense (24 clipped sectors caused 26 test failures during development).test_compare_output_and_L_y— adds a passing Cornerstone domestic case (Commodity,use_domestic=True). Total Leontief cases (Cornerstone and CEDA) remainxfail; Cornerstone total still pairs scaledAdom + Aimpwith BEA-derivedyfromderive_cornerstone_Y_and_trade_scaled.Unchanged:
scaled_q,Adom,ytot,ydom,yimp,exportsderivation paths. CEDA v7 legacy path.derive_y_for_national_accounting_balance_usarouter (Cornerstone branch still delegates toderive_cornerstone_y_nab).Follow-ups (not in this branch)
y_nab_USAvalues change;test_y_nab_usa_snapshotfails until Phase A regeneration (GCS upload,.SNAPSHOT_KEY,releases.py,usa_config.pyLiteral). Required before merge if integration tests gate on snapshots.457-refine-q-estimaterefinesscaled_qvia authoritative-xVscaling.y_nabcouples toderive_cornerstone_Aq_scaled(), so refinedqpropagates automatically once wired into that path. Coordinate stack order if both land near the same snapshot cut.ytot/ydom/yimp/exportswith IO-balancedy_nab, or adjust MRIO multi-regionYassembly (ydom + exportsvsy_nab_USAparquet).Testing
Domestic Cornerstone Leontief identity (passes, 0 failing sectors at 1% rtol):
Full diagnostics module (domestic passes; total cases xfail as expected):
Snapshot integration (fails until
y_nab_USAsnapshot regeneration):