fix(trade): Census residuals, direction-specific IEA financials, and explore S00300 imports - #720
Conversation
Instead of using frozen 2017 weights for export ratios, use commodity output which is a better annual signal. |
Ok both trade methods are set up to use their respective vectors as the allocation - are you suggesting that we make that change across the board (for both imports and exports, for just exports, or just for these |
For exports it should be commodity output. For imports it should be scaled on total uses. We do not yet have total uses until we get a full Use block (For FD its change in inventories (me) and exports (you) then we are complete, and for intermediate uses its in the big stack of Step 3 related PRs (not clearly marked at step 3; most in draft). I would suggest handling this for exports in this PR and we create an issue to do this for Imports as a Step 5 precursor. |
WesIngwersen
left a comment
There was a problem hiding this comment.
As described in comments - tie export allocaton to commodity output and not frozen 2017 shares
Slight revision to previous recommendation. Use allocation factors based on ratios of total uses - commodity output to be more precise |
|
Clarification on export approach: |
|
ok tell you what I'm working on the time series stacked on top of this. why don't i do a stack next to focus just on that shift of allocation source for imports and exports to keep that delta clean. |
Add Trade-FBS and Crosswalk review probes so Crosswalk work does not rebuild the full supply bridge.
…entiate imports and exports
On BEA_IEA_imports only, map TransportSeaFreight, CipLicenses* (533000 targets), and TradeRelated to S00300; exports keep Detail commodity targets. Clears EXTRA MCIF on 533000/483000/425000 (~$64B toward S00300).
Route TransportAirPort/TransportSeaPort imports to noncomparable S00300; map TransportAirFreight 1:m onto 481000/492000 via native F040/MCIF weights. Pin the 2017 trade scorecard baseline.
576f2b2 to
0abadd6
Compare
cc:
Closes:
What changed? Why?
Three Crosswalk fixes on the 2017 Trade FBS path, each tied to a specific sector cluster scored against published Use
F04000/ SupplyMCIF. Census goods keep one shared Crosswalk; IEA services split into direction-specific files because BEA books financial trade and noncomparable imports asymmetrically between exports and imports.Aerospace and other Census residual NAICS (
33641*,1121*,3113*,3118*)Problem. Census USA Trade publishes suppressed-detail residual codes (
33641X,11211X,1123XX,31131X,31135X,31181X) alongside digit-6 NAICS. The extract dropped\d{5}X/\d{4}XXrows, so Crosswalk targets for those residuals were unreachable. Aerospace exports (336411–336413) were MISS by ~$100 B combined; bakery (311810), sugar/confectionery (311300), and livestock residuals were zeroed.Approach.
census_usatrade_parseretains residual NAICS patterns.Sector_Crosswalk_Census_USATrade.csvmaps each residual 1:m onto the Detail commodities of that family, split by frozen 2017 UseF04000weights (same rule as other 1:m Census rows).33641X(~$121 B export mass) fans out to336411/336412/336413/336414/33641A.Scorecard (baseline pin).
336411/336412/336413move from ~0.05–0.25× ref toward ~1.1–1.9× ref (PARTIAL, not MISS).311810,1121A0,112300,311300fill from their*Xresiduals.Financial services imports (
52A000family)Problem. A single IEA Crosswalk mapped parent
Financial(~ $38 B imports) 1:m onto all four financial Detail codes by SupplyMCIFweights. Published 2017MCIFis almost entirely FISIM on52A000(~$6.6 B); explicit fee subtypes (FinSecBrokAndMM,FinCredCard*, …) have no matchingMCIFcells. The unified map put ~$37.6 B on52A000(5.7× published).Approach. Replace
Sector_Crosswalk_BEA_IEA.csvwith direction-specific files:Sector_Crosswalk_BEA_IEA_exports.csvFinancial1:m →52A000,522A00,523A00,523900; split by 2017 UseF04000Sector_Crosswalk_BEA_IEA_imports.csvFinFisim1:1 →52A000only; parentFinancialand explicitFin*leaves unmappedTrade_Exports_2017.yamlselectsBEA_IEA_exports;Trade_Imports_2017.yamlselectsBEA_IEA_imports. Non-financial rows match across both files except the#606block below.Scorecard. Import
52A000moves from +466% (EXTRA-class) to ~−0.7% vs ref ($6.6 B). Import523A00EXTRA clears (mass no longer misallocated from parentFinancial).Noncomparable imports —
#606tranche 1 (S00300,533000,483000,425000)Problem. Five IEA service types land on Detail commodities with zero published Supply
MCIF. The top three (533000licensing ~$33 B,483000sea freight ~$28 B,425000trade-related wholesale ~$2 B) are textbook noncomparable imports per #606: services produced and consumed abroad, and payments for IP rights. Exports correctly book these on named Detail commodities (F04000).Approach. On
BEA_IEA_importsonly, route:TypeOfServiceTransportSeaFreightS00300483000CipLicensesOutcomesResearchAndDevS00300533000CipLicensesFranchiseFeesS00300533000CipLicensesTrademarksS00300533000TradeRelatedS00300425000TransportAirPort/TransportSeaPortS00300488000;48A000F040 ≪ IEA port mass)Scorecard. Import EXTRA clears on
533000,483000,425000(~ $64 B reallocated). ImportS00300moves from MISS ($0) to PARTIAL (~$79 B vs $260 B ref — ~30% of the published bucket). RemainingS00300mass is hold-from-Supply / residual allocation, not Trade FBS.Couriers
Both IEA Crosswalks:
TransportAirFreight1:m →481000/492000(native proportional weights). Export492000~$2.4 B PARTIAL (was MISS); fixed-share splits deferred. Export ports remain unmapped.Crosswalk review tooling
score_2017_trade_fbs.py— score mapped Trade FBS parquet without rebuilding the supply bridge.review_census_crosswalk.py— probe Census NAICS coverage vs Crosswalk membership and residual reachability.Documented in
bedrock/transform/trade/README.md(direction-specific IEA table, residual rules, rejected experiments).Checked and rejected (not in diff)
Prototypes were scored on 2017 Trade FBS; neither ships in this PR. Rationale is recorded under Crosswalk experiments (rejected) in
bedrock/transform/trade/README.md.Census goods →
S00300on imports (339116,33211A). Direction-specific Census Crosswalk routed dental-lab and forging NAICS (~$668 M) toS00300when DetailMCIFis zero. That cleared import EXTRA on those codes but#606covers services/IP licensing, not Census merchandise.intermediate_estimation_plan.mdtreats339116/33211Aas concordance noise;339116has nonzero exportF040. Family-level fit did not meaningfully improve. Track under #658 / #670.TravelHealth1:m across healthcare Detail (621100–621900,622000,623A00,623B00). Split ~$1.1 B export / ~$640 M importTravelHealthby frozen SUT F040/MCIF weights. Healthcare family L1 error vs published totals unchanged ($2.7 B exports / $3.9 B imports). Ambulatory/residential MISS became PARTIAL by shifting mass off622000without improving fit. IEATravelHealthcovers ~29% of published healthcare exportF040; the remainder has no IntlServTrade or Census source — TTSA or otherTravel*types are the path if pursued.Live scorecard after these commits (pinned with
--update-baseline):S00*S00*Export national % rises mainly from Census
33641Xaerospace recovery (~ $121 B). Import national % and non-S00*Pearson hold;S00300is PARTIAL (~$64 B mapped), not a ≥$1 B MISS hole.Testing
Regenerate Trade FBS and pin baseline per commodity:
Fast sector checks without full bridge rebuild:
Spot-check baseline pins for:
336411/336412/336413— PARTIAL, no longer MISS52A000— ~$6.6 B (was ~$37.6 B)533000/483000/425000— zero EXTRAS00300— ~$64 B mapped (PARTIAL vs $260 B ref)