Add new q deriviation and compare q's against references#459
Add new q deriviation and compare q's against references#459WesIngwersen wants to merge 10 commits into
Conversation
|
I'm fixing the type error(s) |
| ``derive_cornerstone_x()``. | ||
| """ | ||
| cfg = get_usa_config() | ||
| effective_year = cfg.usa_ghg_data_year if year == 0 else year |
There was a problem hiding this comment.
I'm curious about the choice of usa_ghg_data_year instead of model_year
There was a problem hiding this comment.
That is an old choice to make it work for the useeio model... not related to this PR except a param was added to be able to override it. It does need to be relooked at maybe in an issue outside this PR.
Co-authored-by: Ben Young (ERG) <44471635+bl-young@users.noreply.github.com>
|
@bl-young I added the text of the analysis run which includes additional summaries but note one aggregation error occuring in |
I'm working on this... |
331314 industry output is getting lost in the industry output mapping to commodity output for the comparison and the totaling. |
I think this was fixed in #454 |
Claude did this. I guess the fix is identical character-by-character so no merge conflict is showing up, so easier just to leave it it in code again but I removed it from the description of the changes in this PR. |
Fixed to assign it temporarily to 331313 only in the scope of this script. Updated results. Now scaled V approach q sum = authoritative x sum. |
|
@WesIngwersen thanks for doing this analysis and sharing the results, it makes the differences between approaches much easier to see. One piece still missing for a fully informed comparison would be EF diagnostics ( Beyond EF impacts, each approach seems to have a distinct main benefit:
If EF diagnostics show relatively little difference between |
@jvendries I will do a full N comparison in a future PR. |
cc: @MoLi7
Closes: #457
Summary
Adds a new q-estimation pathway — scaling the 2017 Cornerstone Make matrix to match BEA annual gross industry output — and an analysis script that compares it against the two existing pathways at both Cornerstone detail and BEA summary level.
NOTE This PR does not implement the new q-estimation pathway into any model builds - it just creates the pathway and compares it with existing pathways.
New functions in
derived_cornerstone.pyscale_cornerstone_V_with_authoritative_x(): inflates the base-2017 V matrix tomodel_base_year(optionally applying commodity PI inflation), then row-scales each industry so that V's row sums exactly matchderive_cornerstone_x_after_redefinition(model_base_year)— the BEA annual gross industry output time series. The result is a Make matrix consistent with authoritative BEA output totals.derive_q_from_scaled_cornerstone_V_from_authoritative_x(): thin wrapper that calls the above and returns commodity q =V.sum(axis=0).derive_cornerstone_x_after_redefinitiongains an optionalyearparameter (defaults tousa_ghg_data_yearwhen omitted, preserving existing behavior) so callers can request a specific year without re-reading config.New analysis script:
bedrock/analysis/q/compare_alt_q.pyCompares three q-estimation pathways at the 405-sector Cornerstone detail level and aggregated to BEA summary level:
derive_q_from_scaled_cornerstone_V_from_authoritative_x()(this branch)scale_a_matrix_with_summary_tables=True+adjust_summary_A_and_q_dollar_year=Trueby callingadjust_summary_q_dollar_year()andinflate_cornerstone_q_or_y_with_commodity_pi()directly, independent of the active configinflate_cornerstone_q_or_y_with_commodity_pi()applied to the base scaled q without the dollar-year rebase stepReference benchmarks:
derive_cornerstone_x_after_redefinition(model_year)(authoritative BEA x) andderive_summary_q_usa(model_year)(summary Make table q).Outputs three matplotlib plots to
bedrock/analysis/q/output/plots/:detail_scatter_{year}.png— 1×4 log-log scatter at Cornerstone detail level; panels 1–3 show each pathway vs authoritative x; panel 4 is a 2017 reference showingcompute_q(V)vscompute_x(V)from the unmodified Make matrixsummary_levels_{year}.png— ranked line plot of all five series at BEA summary levelsummary_pct_deviations_{year}.png— grouped bar chart of % deviation from each reference benchmarkTests
test_scale_V_from_authoritative_x.pyverifies thatscale_cornerstone_V_with_authoritative_x()row sums match the authoritative x vector to within 1e-6 relative tolerance.Analysis results
Aggregate totals at summary level ($M):
x_authoritative 48,424,233,164,693
q_make_table 48,366,332,000,000
V_scaled 48,424,233,164,693
Aq_scaled 48,307,281,448,622
inflated 42,699,140,375,411
Overall pct deviation from Make Table q:
V_scaled +0.120%
Aq_scaled -0.122%
inflated -11.717%
Overall pct deviation from x_authoritative:
V_scaled -0.000%
Aq_scaled -0.242%
inflated -11.823%