Repository navigation
Description
Problem
PolicyEngine/uk-ai-study#16 asks whether Microcosm can carry occupation, so that occupation-level work can run on Microcosm without the raw FRS. The study scores exposure to AI by SOC 2020 major group. The UK build carries the FRS's industry (sic_industry_division, read from adult.tab in frs_employment), but not the occupation beside it.
What the FRS holds.
adult.tabcarriesSOC2020, the SOC 2020 major group, at nine groups in the end-user edition.- The employment questions also go to adults not in work who have ever worked (2024-25 question instructions, p. 183; PDF p. 184). So the code is the main job for adults in work and the last job for everyone else.
- In 2024-25, 92% of adults carry a code (weighted), and a third of them are not in work. 99.5% of adults in work have one.
SPI-channel rows would keep the wrong code.
spi_support_channelandspi_income_band_donorscopy whole FRS households.hmrc_spi_income_spinethen redraws their adults' incomes from the SPI tape, which holds no occupation.- So a copy would keep its twin's occupation, drawn for the twin's pay. It already keeps its twin's
sic_industry_divisionandemployment_sectorthat way.spi_housing_shellredraws housing for the same reason. - SPI-channel rows hold 42.6% of weighted workers in a recent calibrated UK build.
- Held out on FRS 2024-25 workers, a model given only what the twin is matched on (age, sex, region and employment status) misses the occupation shares within earnings bands by 0.15 to 0.38 (total variation). Conditioning on the incomes brings this down to 0.01 to 0.05.
Proposal
1. Carry the FRS code at frs_employment.
- Write
soc2020_major_group(person, string: the policyengine-uk enum's member names) fromSOC2020. Values 1000 to 9000 map to the nine major groups throughSOC2020_MAJOR_GROUP_CODES, andNONEgoes where the code is undefined and to child-table people. - Direct-index
soc2020, assicis, so a missing column fails the build. - Update the derived surfaces:
spec/sources.yamlandsource_stages.json;graph.py's_STAGE_CELLS;terminal_gates.py, and any domain entry ingates.json;- the national staging build record;
- the release input coverage manifest;
- the H2 spine fixture;
test_uk_frs_employment.pyand the battery bindings.
- Leave the eFRS parity reference out, since the incumbent has no such column.
- This needs Add
soc2020_major_group, an input for the SOC 2020 major group of a person's main or last job policyengine-uk#2856 in the pinned policyengine-uk.
2. Redraw it on the drawn SPI rows, in a new person stage after company_cars. At that point the SPI rows' pay is net of car benefits, the same concept as FRS pay.
- Rows drawn:
person_is_spi_income_recipientrows whose twin has a code, or that drew positive pay or profit.- Every other row is byte-unchanged.
- An undrawn copy keeps its twin's incomes, so it keeps the twin's code.
- Training rows: FRS-channel adults aged 16 and over, with a code and positive weight, and without CGT clones or support copies (as
salary_sacrificetrains). They are weighted byhousehold_weight. - Predictors, present on both channels:
- age, sex and region;
- employment-status group (employee, self-employed, retired, other);
- employment income, self-employment income, investment income (savings interest plus dividends) and private pension income.
- Left out: industry, hours and education predict occupation better, but on SPI rows they are the twin's. The full-time flag is left out for the same reason.
- Model and draw: a weighted gradient-boosted classifier, regularised with early stopping, with its settings declared in the spec. Draws are inverse-CDF on
stable_identity_uniformskeyed byperson_id, asspi_housing_shelldraws its categories. - Evidence, on household-grouped folds (Calibrate the QRF sign gates out of fold, for every gated UK imputation #1391's
_stratified_folds(groups=...)):- held-out log loss against the constant;
- the calibration slope;
- occupation shares within earnings bands.
- Then work through the new-stage checklist of derived surfaces.
3. Impute the sub-major group within the major group. This writes soc2020_sub_major_group, the second input in PolicyEngine/policyengine-uk#2856.
- Why: occupation-level work needs detail below the major group. Take the study's unit-group crosswalk, weighted by ASHE 2025 jobs:
- Major groups explain 75% of the spread in AI exposure (C-AIOE) across jobs, and sub-major groups 86%.
- Within major groups, exposure rises with pay, at a correlation of 0.32 across unit groups.
- For complementarity, which the study uses to spread wage gains, the shares are 51% and 69%.
- Donor: a survey that codes SOC 2020 below the major group, meaning the LFS or the APS (end-user editions). Which one, and which years, is still to be measured, on:
- the sample at sub-major level;
- pay coverage (the LFS asks about pay only at waves 1 and 5);
- the 2021-22 SOC coding revision.
- Rows: every adult with a major group. On FRS rows the draw is within their FRS code; on drawn SPI rows, within the redrawn code.
NONEstaysNONE. - Model and draw: a weighted classifier over the major group's sub-major groups, with keyed inverse-CDF draws as in part 2.
- FRS rows condition on everything both surveys carry: age, sex, region, employment status, full-time status, hours, pay, industry section and highest qualification.
- Drawn SPI rows condition only on the SPI set, since the rest is the twin's.
4. Open questions.
- Should the stage in part 2 also copy a coherent (
sic_industry_division,employment_sector) pair onto these rows, from an FRS worker with the drawn major group and the nearest pay rank? Both are the twin's today. - Should it fill the 0.5% of FRS adults in work who have no code, from the full predictor set, or leave them at
NONE?
Prior work: #325, as a reference
#325 built an occupation and AI-exposure stack for the populace layout. It conflicts with main, so this issue treats it as a reference, not a base. Its pieces, and what happens to each here:
- FRS occupation merge (
frs_occupation.py): replaced.- It joins
adult.tabonto a finished single-year dataset by person id, so it cannot follow cloned households (its own follow-up). - Part 1 reads the code where the spine reads
adult.tab, so every copy carries its source person's code. - Its loud-failure checks (duplicate keys, a join that matches nothing) carry over as tests.
- It joins
- Exposure imputation (
exposure_imputation.py): the idea stays, the method changes.- The idea is to refine within the observed major group from an LFS/APS donor.
- It imputes a numeric C-AIOE score with a QRF, because the QRF cannot draw codes. Microcosm now draws categories with keyed classifiers, as
spi_housing_shelldoes, so part 3 imputes the sub-major code instead. The dataset then does not fix one exposure measure, and users map whichever measure they need. - Its donor notes stay as reference: the LFS five-quarter variables, deduplicating on
PERSID, the 2021-22 SOC coding revision and the EUL terms.
- Occupation targets (
occupation_targets.pyand its CSVs): APS stays, ASHE changes role.- The APS sub-major and age margins stay, as checks first. Their facts come through Chronicle rather than CSVs in the tree.
- ASHE's 340 unit-group job counts do not become person targets: they count employee jobs rather than people, leave out the self-employed, and fall into thin cells. ASHE stays as the pay-by-occupation check.
- Exposure crosswalk (
ai_exposure.py,ai_exposure_sources.pyand the CSVs): stays out of Microcosm. It is analysis keyed on occupation codes. PolicyEngine/uk-ai-study already packages it, along with the composition question still open in UK AI-exposure analysis stack: exposure crosswalk, occupation targets, exposure imputation, and ESRI-style AI shock scenarios #325's thread. - Shock scenarios and runner (
ai_shock_scenarios.py,ai_shock_runner.py): stay out of Microcosm, with the study's analysis in PolicyEngine/uk-ai-study.
Checks
- Weighted workers by major and sub-major group against the APS (NOMIS) for the build year, for the UK and its regions. The tolerance is to be set. The APS facts need a Chronicle request.
- Median full-time employee pay by major group against ASHE Table 14. This is a soft check, since the pay concepts differ.
- The stages' held-out metrics, as stage health.
Done when
frs_employmentwritessoc2020_major_group, and every FRS-channel adult carries the survey's code.- Drawn SPI rows carry a redrawn code, and the stage records its held-out evidence.
- Every adult with a major group carries a sub-major group drawn within it.
- The pinned policyengine-uk carries both inputs, and the release carries both columns.
- The national is rebuilt, and the APS checks pass.
🤖 Generated with Claude Code
Activity
Merge pull request #1512 from PolicyEngine/uk-occupation-draws-1490
Merge main (9c81747) into #1511's branch
Bind the APS's people in employment by SOC 2020 sub-major group and s…
Merge main (f44512d) into uk-931-geography-first-prep
Fold geographic clones in the SPI employment fit (#931)
Drop community and civil enforcement's UK rows by sex and pin what th…
Merge pull request #1520 from PolicyEngine/uk-occupation-targets-1490
Fetch and pass the NTS vehicle and APS tabs main's spine now reads
Fold geographic clones in the SPI employment fit (#931)