Skip to content

Independent L_dom·y = q test with y read from the Use table's final demand - #1164

Merged
WesIngwersen merged 4 commits into
mainfrom
independent_ly_q_test
Nov 2, 2026
Merged

WesIngwersen merged 4 commits into
mainfrom
independent_ly_q_test

Conversation

@WesIngwersen

Copy link
Copy Markdown
Member

Why

The domestic L·y = q check (test_compare_output_and_L_y, domestic case) uses y_nab. derive_y_nab back-computes y_nab as (I − A_dom) q from the same A_dom and q the test then compares, so L_dom · y_nab = q holds by construction for any tables. It confirms the Leontief inverse is computed correctly, not that the tables are consistent.

The change

  • usa_matrices.derive_y_dom_from_use_final_demand() reads final demand from the Use table only:

    • every final-demand column, with exports included and the F05000 imports column negative;
    • plus the imports that industries use (Uimp row sums).

    The result is the domestic output taken by final demand, exports included. It never sees A or q. Negatives are kept, as in the published tables. The function is uncached and has no consumers other than the test.

  • test_domestic_L_y_from_use_final_demand_equals_q checks L_dom · y = q under the canonical config at 1% per sector.

What it shows

Sector output is commodity output q, and the gap is L_dom · y − q ($bn).

tables sum of absolute gap sectors off by more than 1% median absolute gap gap as a share of total output
canonical, MUT v0.5.0_a166975 (2024, before #1161) 1,604 285 of 405 3.35% 3.16%
2024 rebuilt in memory with #1162 (not stored) 78 13 of 405 0.05% 0.15%

On the stored tables, the largest gaps are retail and wholesale (454000 −$220bn, 424A00 +$89bn). This is the margin and tax mismatch #1162 fixes.

After #1162, the remaining failures are:

  • mostly the waste-disaggregation sectors: 562111 −9.4%, 562HAZ +41%, 562910 +25%, 562OTH +15%, 562212 −13%;
  • 331410 nonferrous smelting, +46%;
  • S00402 (used goods), where q is zero.

Waste disaggregation splits each parent sector's output across its children without keeping each child's row identity. This is the same cause as the existing xfail on test_compare_Uset_y_dom_and_q_usa.

The test is xfail until the stored MUT is rebuilt with #1162. Rebuilding it is on hold. Even after the rebuild, the waste sectors will keep it failing, so whether to fix them or exempt them is a separate decision.

Checks run locally

  • black --check, ruff check, mypy clean on both files.
  • The new test was run with --runxfail under the canonical config. It failed as expected: 286 sectors, the 285 above plus S00402.

🤖 Generated with Claude Code

…nal demand

The domestic L y = q test used y_nab, back-computed as (I - A_dom) q, so it
held by construction. derive_y_dom_from_use_final_demand reads y from the
Use table's final-demand columns plus industry imports, independent of A
and q. The new test is xfail: on the canonical MUT it misses q by $1.6T
(286 sectors); on #1161 tables by $78bn, mostly waste disaggregation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@WesIngwersen

Copy link
Copy Markdown
Member Author

@jvendries @bl-young @MoLi7 Our simple Ly=q test was still circular where y=y_nab=(I − A_dom)·q . y_nab has to be derived independently for this to be a valid test.

WesIngwersen and others added 2 commits October 31, 2026 15:14
The test now fails until Make and Use agree on commodity output sector by
sector, so it reports the gap instead of hiding it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The test is known to fail until the waste sectors and 331410 are fixed;
keep it xfail so it does not report on every PR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@bl-young bl-young left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to approve. The old domestic L·y = q path was circular (y_nab = (I − A_dom) q), so it only checked the inverse. Reading y = Y @ 1 + Uimp @ 1 from the Use table is the right independent demand, and under the canonical nowcast config derive_Aq_scaled is a no-op so units match. Keeping it eeio_integration + xfail is fine until the stored MUT moves off a166975 and #1165 lands.

Two small nits, neither blocking:

  1. Please leave a one-line comment on the domestic branch of test_compare_output_and_L_y that it only verifies L inversion given back-computed y_nab -- the independent check is the new test. Otherwise the circular path stays an easy place to hide table inconsistency again.

  2. Tighten the new test's xfail reason: #1162 is already on main; what still fails on the pinned v0.5.0_a166975 is the pre-rebuild MUT, and after a #1162/#1170 rebuild the leftovers are mostly waste kids (#1165) plus 331410 / S00402. Citing #1161 as the live cause is a bit stale.

…on (review on #1164)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@WesIngwersen

Copy link
Copy Markdown
Member Author

Both nits addressed in ad20d5a:

  1. The domestic branch of test_compare_output_and_L_y now says it is circular (y_nab = (I - Adom) q), so it only checks that L inverts (I - Adom), and points to test_domestic_L_y_from_use_final_demand_equals_q as the independent check.
  2. The xfail reason now says the pinned v0.5.0_a166975 is the pre-rebuild MUT ($1.6T, 286 of 405 sectors), and that on the Close the Step 6 commodity identity on the balanced Supply table (#1161) #1162 rebuild (feat(config): point the v1.0 configs at the MUT build v1.0.0_5514c3b #1170, v1.0.0_5514c3b) 15 sectors still fail: the waste children (562*, Waste disaggregation breaks each waste child's commodity identity (Make output vs Use row + final demand) #1165), 331410 and S00402.

@WesIngwersen
WesIngwersen merged commit 6cd8b86 into main Nov 2, 2026
5 checks passed
@WesIngwersen
WesIngwersen deleted the independent_ly_q_test branch November 2, 2026 16:57
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.

2 participants