-
Notifications
You must be signed in to change notification settings - Fork 10
Use spm-calculator to compute SPM thresholds #453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Add spm-calculator as a dependency (from GitHub) - Create policyengine_us_data/utils/spm.py with threshold calculation utilities - Update CPS dataset to use spm-calculator with Census-provided GEOADJ factors - Update ACS dataset to use spm-calculator with national-level thresholds For CPS: Uses the SPM_GEOADJ values from Census data combined with spm-calculator's base thresholds and equivalence scale, providing geographically-adjusted thresholds. For ACS: Uses national-level thresholds (no geographic adjustment) since ACS doesn't include pre-computed GEOADJ values. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add spm-calculator as a dependency (from GitHub) - Create policyengine_us_data/utils/spm.py with threshold calculation utilities - Update CPS dataset to use spm-calculator with Census-provided GEOADJ factors - Update ACS dataset to use spm-calculator with national-level thresholds For CPS: Uses the SPM_GEOADJ values from Census data combined with spm-calculator's base thresholds and equivalence scale, providing geographically-adjusted thresholds. For ACS: Uses national-level thresholds (no geographic adjustment) since ACS doesn't include pre-computed GEOADJ values. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
…yengine-us-data into use-spm-calculator
The long_term_projections.ipynb notebook outputs were causing a "useOutputsContext must be used within a OutputsContextProvider" error in MyST's book-theme during documentation build. Clearing the outputs resolves this issue. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
The Jupyter notebook was causing "useOutputsContext must be used within a OutputsContextProvider" errors in the MyST book-theme. Converting to markdown preserves all content while avoiding the rendering bug. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Previously, ACS SPM thresholds used national-level values only (GEOADJ=1.0). This update uses spm-calculator's PUMA-level geographic adjustment lookup to compute thresholds with local housing cost adjustments. Changes: - Add calculate_spm_thresholds_by_puma() function to spm.py - Update ACS dataset to pass state FIPS and PUMA codes to the new function - PUMA identifiers are constructed as 7-digit codes (2-digit state + 5-digit PUMA) Note: Requires CENSUS_API_KEY environment variable for PUMA lookups. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update: PUMA-level geographic adjustments for ACSThis commit adds PUMA-level geographic adjustments for ACS SPM thresholds. ChangesPreviously: ACS used national-level thresholds only ( Now: ACS uses PUMA-level geographic adjustments via
Geographic identifier formatThe spm-calculator supports these geography levels for SPM thresholds:
For ACS, we use PUMA since:
RequirementsGenerating ACS data now requires |
|
Per our discussion, we need to discard |
baogorek
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @DTrim99, I think I understand what's going on here. One of my comments is actually a question for my own understanding of MyST documentation.
I understand this PR will lead to a new CPS h5 file and I believe you can merge it independently of anything I'm working on. If you agree, let's focus on getting your tests to pass.
My one ask is that you'd think about how you might be able to use your SPM calculator without using the CENSUS_API_KEY (causing the tests to fail). If you cannot, we can add the key to the environment variables of this repo.
- Switch from calculate_spm_thresholds_by_puma to calculate_spm_thresholds_national to avoid Census API dependency that was causing CI failures - Geographic adjustments will be applied later in the pipeline when households are assigned to specific areas (per discussion with Max) - Remove obsolete long_term_projections.ipynb reference from myst.yml 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Addressed the review feedback:
Note for follow-up: Geographic adjustments ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @DTrim99 , I hope I don't sound too grumpy here. There's just a lot going on with additional dependencies and new responsibilities and I want to make sure we get this right.
So the good news is that, if you're okay with me bringing my own geoadj values for congressional districts, I can run with calculate_spm_thresholds_with_geoadj(), which does not need the census api key, and then I'm using the calculator.
We do need to discuss the following points:
- Why not use spm_unit.SPM_POVTHRESHOLD when it is available to us? Do we think that our calculator has a superior formula? It seems like we're using the same inputs that it would use. So why take on the work and add more lines of code?
- Why mess with acs.py at all, especially since moving to the national level feels like a regression from .SPM_POVTHRESHOLD?
- You'll see that I gripe about the
time_periodargument a few times. I need to be convinced that having a free time argument in a method is needed, since the class hastime_periodas a property. There's the potential for getting out of sync, and extra arguments are more complexity. - If we're going to use the calculator, I think we should prioritize getting it on PyPI so we don't have to use the github pattern in the pyproject.toml
- Revert all ACS changes - no longer touching ACS since SPM_POVTHRESHOLD is already available and we don't need to calculate thresholds there - Remove time_period argument from add_spm_variables, use self.time_period instead to match pattern of other functions like add_rent 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Hi @baogorek, thanks for the thorough review! I've addressed your feedback: Changes made:
Regarding your other points:
Let me know if you have any other concerns! |
- Remove redundant comment above TENURE_CODE_MAP (self-explanatory) - Remove calculate_spm_thresholds_national (unused after ACS revert) - Remove map_tenure_acs_to_spm (unused after ACS revert) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
SPM_POVTHRESHOLD from the CPS uses SPM_GEOADJ - that's why we need to recalculate it |
baogorek
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Summary
spm-calculatoras a dependency (from GitHub)policyengine_us_data/utils/spm.pywith SPM threshold calculation utilitiesDetails
For CPS: Uses the
SPM_GEOADJvalues already computed by the Census Bureau, combined with spm-calculator's base thresholds and equivalence scale formula. This provides geographically-adjusted thresholds without requiring a Census API key.For ACS: Uses national-level thresholds (geoadj=1.0) since ACS doesn't include pre-computed geographic adjustment factors.
Test plan
🤖 Generated with Claude Code