Skip to content

feat: Fay–Herriot measurement-error method for sample-based auxiliaries (Phase 7, v1.1.0)#9

Merged
bakodramane merged 1 commit into
mainfrom
phase/7-survey-auxiliary
Jun 18, 2026
Merged

feat: Fay–Herriot measurement-error method for sample-based auxiliaries (Phase 7, v1.1.0)#9
bakodramane merged 1 commit into
mainfrom
phase/7-survey-auxiliary

Conversation

@bakodramane

Copy link
Copy Markdown
Owner

Trimmed Phase 7 — Survey-based auxiliary variables (v1.1.0)

Adds one new area-level method, fh-me — the Fay–Herriot model with measurement error (Ybarra & Lohr, 2008) — for auxiliary variables that come from a large sample (e.g. an agricultural census run as a sample) rather than a full census or register, and therefore carry sampling error. Standard Fay–Herriot assumes auxiliaries are known exactly; FH-ME corrects for that. No existing method's behaviour changes except the recommender/wizard extensions described below.

=== PHASE 7 (TRIMMED) REVIEW REPORT ===
Branch:        phase/7-survey-auxiliary
PR:            (this PR)
Build:         PASS
Tests:         PASS (473 unit passed, 0 failed; 3 Playwright e2e passed, 0 failed)
Lint:          PASS

What was built:
- types/index.ts: DataAvailability.auxiliaryFromSample + hasAuxiliaryVariances;
  CatalogueEntry.requiresAuxiliaryVariances + mseMethod 'jackknife';
  UserInputs.auxiliaryVarianceVars; new 'auxiliary-variance' VariableRole
- src/catalogue/fh-me.ts (new) + registered in index.ts → 17 entries
- catalogue.test.ts: expects 17 entries; mseMethod union accepts 'jackknife'
- engine/recommender.ts: ranks fh-me first for sample-based continuous/proportion
  targets; sampling-error caveat on fh-eblup/spatial-fh/robust-fh; blocking caveat
  on fh-me when variances missing; hides fh-me for register auxiliaries
- engine/codegen.ts: {{AUX_VAR_VARIANCES_R}} + {{CI_ARRAY_BUILDER_R}} tokens
- wizard: Step3 auxiliary-source question + follow-up; Step2 variance pairing;
  Step4 badge + prominent amber caveat; Step5 variance mapping in summary
- tests: 3 new recommender scenarios; fh-me codegen snapshot; Playwright sample-aux flow
- docs: SAE-CATALOGUE.md §7 + §1 tokens; adding-a-method.md; README feature

Acceptance criteria:
- [x] All pre-existing tests still pass; new recommender, codegen, and e2e tests pass
- [x] 17 catalogue entries validate, including extended mseMethod union
- [x] FH-ME generates a runnable, commented R script using emdi::fh(method = "me")
      with a correctly assembled Ci array and no unreplaced tokens
- [x] Wizard lets the user declare sample-based auxiliaries, supply variance columns,
      and reach a downloadable FH-ME R script; standard area-level methods show the
      sampling-error caveat in that flow
- [x] npm run build, npm test, the Playwright suite, and npm run lint all pass

Known gaps or decisions deferred:
- Auxiliary↔variance pairing uses an optional 'auxiliary-variance' role matched by
  order (the spec's "keep it simple" option), with a validation message if the counts
  differ. A strict per-row paired selector was deliberately not built.
- The generated Ci array assumes zero covariance between auxiliaries (documented in a
  comment in the script), as the spec specifies; covariance columns are not collected.
- fh-me is hidden from the recommender unless sample-based auxiliaries are declared, so
  register-auxiliary flows are byte-for-byte unchanged.

Ready for review: YES

Tag v1.1.0 after merge.

🤖 Generated with Claude Code

…iaries (fh-me)

Trimmed Phase 7 (v1.1.0). Adds one new area-level method, fh-me (Ybarra & Lohr,
2008), for auxiliary variables that come from a sample rather than a full census,
plus the inputs, recommender logic, code generation, wizard changes, and docs to
support it. No existing method behaviour changes.

- types: add auxiliaryFromSample/hasAuxiliaryVariances to DataAvailability,
  requiresAuxiliaryVariances + mseMethod jackknife to CatalogueEntry,
  auxiliaryVarianceVars to UserInputs, and an auxiliary-variance VariableRole
- catalogue: new src/catalogue/fh-me.ts (17 entries); schema test accepts jackknife
- recommender: rank fh-me first for sample-based continuous/proportion targets;
  sampling-error caveat on fh-eblup/spatial-fh/robust-fh; blocking caveat on fh-me
  when variances are missing; hide fh-me for register auxiliaries
- codegen: {{AUX_VAR_VARIANCES_R}} and {{CI_ARRAY_BUILDER_R}} tokens + emdi fh(method=me)
- wizard: Step 3 auxiliary-source question + follow-up; Step 2 auxiliary-variance
  pairing; Step 4 badge + prominent amber caveat; Step 5 variance mapping in summary
- tests: 3 recommender scenarios, fh-me codegen snapshot, Playwright sample-aux flow
- docs: SAE-CATALOGUE.md §7 + tokens, adding-a-method.md, README feature

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@bakodramane bakodramane merged commit 443088a into main Jun 18, 2026
2 checks passed
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.

1 participant