468 use equivalent q for a b y nab in scaling method#475
Open
WesIngwersen wants to merge 15 commits into
Open
Conversation
…ternal callers; add scale_cornerstone_x
…dation check _validate_scaled_x_vnorm_for_B_prerequisites
…ar_before_scaling
…ne_Vnorm_scrap_corrected() to work for scaled approach for use in B matrix
…_year > adjust_summary_dollar_year_before_scaling
…http://github.com/cornerstone-data/bedrock into 468-use-equivalent-q-for-a-b-y_nab-in-scaling-method
…Vnorm_for_B is true
…d() when that config flag is set
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: @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 bothxandVnorm.New config flag:
use_scaled_x_and_scaled_Vnorm_for_Buse_scaled_x_and_scaled_Vnorm_for_B: booltoUSAConfigwith a validator that enforcesscale_a_matrix_with_summary_tablesorscale_a_matrix_with_ceda_method_as_fallback, anduse_E_data_year_for_x_in_B, as prerequisites.2025_usa_cornerstone_full_model_scaling_for_A_and_B.yamlto exercise the full scaled A+B pipeline.scale_cornerstone_xandscale_cornerstone_V(new)derive_summary_x_usaas a public function (was private).scale_cornerstone_xincornerstone_year_scaling.py: scales detail industry gross output using summary x ratios, with optional dollar-year rebasing via the summary industry price ratio whenadjust_summary_dollar_year_before_scalingis set.scale_cornerstone_Vincornerstone_year_scaling.py: scales the detail Make table using summary V block ratios, following the same pattern asscale_cornerstone_Abut without the out-of-bounds clamping assertion (V row sums are not constrained to ≤ 1).Rename:
adjust_summary_A_and_q_dollar_year→adjust_summary_dollar_year_before_scalingcornerstone_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)
_aggregate_industry_pi: x-weighted aggregation of Cornerstone-detail industry PI to BEA summary level using thebea_v2017_industry__bea_v2017_summarymapping._get_summary_industry_price_index(cached): aggregates detail PI to summary using 2017 base-year Cornerstone x as weights (avoids a circular dependency throughscale_cornerstone_x).get_summary_industry_price_ratio(cached): cross-year ratio of summary industry PI, used as the dollar-year deflator foradjust_summary_V_dollar_yearandadjust_summary_x_dollar_year.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 withinflate_cornerstone_V_with_industry_pi).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)use_scaled_x_and_scaled_Vnorm_for_Bis set,derive_cornerstone_Vnorm_scrap_correctednow usesscale_cornerstone_Vfor V andderive_cornerstone_x_after_redefinitionfor the scrap correction denominator. Thexin the scrap correction uses the same summary industry output scaling asscale_cornerstone_A, keeping A and Vnorm consistent.derive_cornerstone_x_after_redefinitionroutes throughscale_cornerstone_x(derive_cornerstone_x(), ...)when the flag is set, soderive_cornerstone_B_via_vnormgets a detail x consistent with the A-matrix scaling denominators.derive_cornerstone_xnow applies_distribute_waste_parent_x_using_v_row_sharesso 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
bedrock/analysis/compare_x_approaches.pyto comparederive_cornerstone_x_after_redefinition()(Approach A: summary x scaling) againstcompute_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