Skip to content

Add household and housing tenure weights for NHGIS crosswalks - #23

Open
wcurrangroome wants to merge 1 commit into
mainfrom
issue-20-household-weights
Open

wcurrangroome wants to merge 1 commit into
mainfrom
issue-20-household-weights

Conversation

@wcurrangroome

Copy link
Copy Markdown
Collaborator

Closes #20.

What this changes

  • get_crosswalk() and crosswalk_data() accept weight = "household", "housing_owned" and "housing_rented". For NHGIS block group and tract crosswalks, these select the NHGIS wt_hh, wt_ownhu and wt_renthu weights.
  • Every step of a crosswalk plan is checked before anything is downloaded. Asking a GeoCorr step for one of the new weights raises an error that names the step (for example, "step 2 of 2") and lists the weights GeoCorr offers: population, housing and land.
  • An NHGIS file that lacks a requested household or tenure weight raises an error that lists the weights the file has. Another weight is never substituted. Block-based files are expected to fall in this group.
  • CT Data (2020↔2022) and county-events steps have no choice of weight. They accept any valid weight and print a message when they use population-based factors instead.
  • crosswalk_metadata$weighting_variable records the weight actually used, using NHGIS's own label. For example, weight = "housing" on a tract file now records "housing_all"; the value the user passed is still in call_parameters$weight.
  • The help pages and the interpolation vignette list the weights each source offers.
  • The six tests on the CT Data 2020→2022 path now skip when IPUMS_API_KEY is not set, because that path downloads an NHGIS file.

Decisions

  • No "adult" or "family" weights for now.
  • get_available_crosswalks() gets no new column; the available weights are only documented.

Testing

  • test-crosswalk-weights.R: 16 tests, 0 failed, 4 skipped. The skipped ones need IPUMS_API_KEY or slow tests turned on.
  • test-get_crosswalk.R: 0 failed. test-crosswalk_data.R: 0 failed.
  • Not yet confirmed against a real NHGIS file: that the tract and block group files carry wt_hh, wt_ownhu and wt_renthu. No API key was available. Those tests run when IPUMS_API_KEY is set.

Stacked pull requests: #22's PR is based on this branch, and #21's PR is based on #22's.

🤖 Generated with Claude Code

get_crosswalk() now accepts weight = "household", "housing_owned" and
"housing_rented" for NHGIS block group and tract crosswalks. These select
the NHGIS wt_hh, wt_ownhu and wt_renthu weights.

- Every step of a crosswalk plan is checked before any download. A GeoCorr
  step asked for one of the new weights raises an error that names the
  step and lists the weights GeoCorr offers.
- An NHGIS file that lacks a requested household or tenure weight raises
  an error; another weight is never substituted.
- CT Data and county-events steps, which have no choice of weight, accept
  any valid weight and print a message when population-based factors are
  used instead.
- crosswalk_metadata$weighting_variable records the weight actually used.
- Documentation lists the weights each source offers.
- Tests for the CT Data 2020-2022 path now skip when IPUMS_API_KEY is not
  set, since that path downloads an NHGIS file.

Closes #20

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

Add a household weight option for NHGIS crosswalks

1 participant