Skip to content

468 use equivalent q for a b y nab in scaling method#475

Open
WesIngwersen wants to merge 15 commits into
mainfrom
468-use-equivalent-q-for-a-b-y_nab-in-scaling-method
Open

468 use equivalent q for a b y nab in scaling method#475
WesIngwersen wants to merge 15 commits into
mainfrom
468-use-equivalent-q-for-a-b-y_nab-in-scaling-method

Conversation

@WesIngwersen

@WesIngwersen WesIngwersen commented Jun 18, 2026

Copy link
Copy Markdown
Member

cc: @MoLi7
Closes: #468

Summary

Extends the scaled-year A-matrix methodology to also produce a consistent scaled B matrix (E/x @ Vnorm) using equivalent summary-table scaling for both x and Vnorm.

New config flag: use_scaled_x_and_scaled_Vnorm_for_B

  • Added use_scaled_x_and_scaled_Vnorm_for_B: bool to USAConfig with a validator that enforces scale_a_matrix_with_summary_tables or scale_a_matrix_with_ceda_method_as_fallback, and use_E_data_year_for_x_in_B, as prerequisites.
  • Added config 2025_usa_cornerstone_full_model_scaling_for_A_and_B.yaml to exercise the full scaled A+B pipeline.

scale_cornerstone_x and scale_cornerstone_V (new)

  • Exposed derive_summary_x_usa as a public function (was private).
  • Added scale_cornerstone_x in cornerstone_year_scaling.py: scales detail industry gross output using summary x ratios, with optional dollar-year rebasing via the summary industry price ratio when adjust_summary_dollar_year_before_scaling is set.
  • Added scale_cornerstone_V in cornerstone_year_scaling.py: scales the detail Make table using summary V block ratios, following the same pattern as scale_cornerstone_A but without the out-of-bounds clamping assertion (V row sums are not constrained to ≤ 1).

Rename: adjust_summary_A_and_q_dollar_yearadjust_summary_dollar_year_before_scaling

  • Renamed the config field and all call sites across cornerstone_year_scaling.py, derived_cornerstone.py, YAML configs, and tests to better reflect that the flag now governs dollar-year alignment for A, q, V, and x.

Summary-level industry price index (new)

  • Added _aggregate_industry_pi: x-weighted aggregation of Cornerstone-detail industry PI to BEA summary level using the bea_v2017_industry__bea_v2017_summary mapping.
  • Added _get_summary_industry_price_index (cached): aggregates detail PI to summary using 2017 base-year Cornerstone x as weights (avoids a circular dependency through scale_cornerstone_x).
  • Added get_summary_industry_price_ratio (cached): cross-year ratio of summary industry PI, used as the dollar-year deflator for adjust_summary_V_dollar_year and adjust_summary_x_dollar_year.
  • Added adjust_summary_V_dollar_year: rebases summary V from one year's prices to another by dividing rows by the industry price ratio (row-axis only, consistent with inflate_cornerstone_V_with_industry_pi).
  • Added adjust_summary_x_dollar_year: rebases summary x by dividing by the industry price ratio.

Scaled B matrix wiring (derive_cornerstone_Vnorm_scrap_corrected, derive_cornerstone_x_after_redefinition)

  • When use_scaled_x_and_scaled_Vnorm_for_B is set, derive_cornerstone_Vnorm_scrap_corrected now uses scale_cornerstone_V for V and derive_cornerstone_x_after_redefinition for the scrap correction denominator. The x in the scrap correction uses the same summary industry output scaling as scale_cornerstone_A, keeping A and Vnorm consistent.
  • derive_cornerstone_x_after_redefinition routes through scale_cornerstone_x(derive_cornerstone_x(), ...) when the flag is set, so derive_cornerstone_B_via_vnorm gets a detail x consistent with the A-matrix scaling denominators.
  • derive_cornerstone_x now applies _distribute_waste_parent_x_using_v_row_shares so that waste-sector children receive proportional shares of parent gross output in all callers, including the PI aggregation weights in _get_summary_industry_price_index.

Analysis script

  • Added bedrock/analysis/compare_x_approaches.py to compare derive_cornerstone_x_after_redefinition() (Approach A: summary x scaling) against compute_x(V=scale_cornerstone_V(...)) (Approach B: V row sums). Results show 401/405 sectors differ >1% (mean ~22%), driven by waste redistribution, confirming Approach A as the internally consistent choice for the B matrix.

Testing

Confirmed successful build of new model config 2025_usa_cornerstone_full_model_scaling_for_A_and_B

@WesIngwersen WesIngwersen linked an issue Jun 18, 2026 that may be closed by this pull request
@WesIngwersen WesIngwersen requested a review from MoLi7 June 18, 2026 17:07
@WesIngwersen WesIngwersen added this to the v0.4 milestone Jun 18, 2026
@WesIngwersen WesIngwersen marked this pull request as ready for review June 18, 2026 17:30
@WesIngwersen WesIngwersen marked this pull request as draft June 18, 2026 17:31
@WesIngwersen WesIngwersen marked this pull request as ready for review June 18, 2026 21:56
@WesIngwersen WesIngwersen requested review from bl-young and jvendries and removed request for MoLi7 and bl-young June 28, 2026 13:20
@WesIngwersen WesIngwersen self-assigned this Jun 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use equivalent q for A, B, y_nab in scaling method

1 participant