From 7a41be45e973fd4ca07c0777ac40347c60f606f3 Mon Sep 17 00:00:00 2001 From: "baogorek@gmail.com" Date: Mon, 2 Feb 2026 18:26:52 -0500 Subject: [PATCH 1/9] Add state-specific Medicaid takeup rates and Section 1931 deprivation rules Fixes #7316 - Replace uniform 93% national takeup rate with state-specific rates derived from MACPAC enrollment targets (range: 58% Utah to 99% Colorado) - Add requires_deprivation parameter for non-expansion states using Section 1931 criteria (TX, FL, GA, AL, MS, SC, TN, KS, WY, SD, WI) - Add is_single_parent_household variable for deprivation determination - Update is_parent_for_medicaid_nfc to check deprivation requirement, correctly excluding married parents in non-expansion states Co-Authored-By: Claude Opus 4.5 --- changelog_entry.yaml | 8 ++ .../parent/requires_deprivation.yaml | 123 ++++++++++++++++++ .../gov/hhs/medicaid/takeup_rate.yaml | 110 +++++++++++++++- .../parent/is_parent_for_medicaid_nfc.py | 32 ++++- .../parent/is_single_parent_household.py | 39 ++++++ .../medicaid/takes_up_medicaid_if_eligible.py | 5 +- 6 files changed, 311 insertions(+), 6 deletions(-) create mode 100644 policyengine_us/parameters/gov/hhs/medicaid/eligibility/categories/parent/requires_deprivation.yaml create mode 100644 policyengine_us/variables/gov/hhs/medicaid/eligibility/categories/parent/is_single_parent_household.py diff --git a/changelog_entry.yaml b/changelog_entry.yaml index e69de29bb2d..22cebad2806 100644 --- a/changelog_entry.yaml +++ b/changelog_entry.yaml @@ -0,0 +1,8 @@ +- bump: minor + changes: + added: + - State-specific Medicaid takeup rates based on MACPAC enrollment targets vs modeled eligibility. Rates range from 58% (Utah) to 99% (Colorado), replacing the uniform 93% national rate. + - Deprivation requirement parameter for Medicaid parent eligibility in non-expansion states (TX, FL, GA, etc.). + - is_single_parent_household variable to determine if a person qualifies under Section 1931 deprivation rules. + changed: + - Medicaid parent eligibility (is_parent_for_medicaid_nfc) now checks deprivation requirement for non-expansion states, correctly excluding married parents who don't meet Section 1931 criteria. diff --git a/policyengine_us/parameters/gov/hhs/medicaid/eligibility/categories/parent/requires_deprivation.yaml b/policyengine_us/parameters/gov/hhs/medicaid/eligibility/categories/parent/requires_deprivation.yaml new file mode 100644 index 00000000000..dc3f48d8ef8 --- /dev/null +++ b/policyengine_us/parameters/gov/hhs/medicaid/eligibility/categories/parent/requires_deprivation.yaml @@ -0,0 +1,123 @@ +description: > + Whether the state requires a child to be "deprived of parental support" + for parent Medicaid eligibility. This is based on Section 1931 criteria + which applies to non-expansion states using pre-ACA AFDC rules. + In practice, this means two-parent households generally do not qualify + unless one parent is incapacitated or unemployed. +metadata: + label: Medicaid parent eligibility requires deprivation + unit: bool + period: year + breakdown: + - state_code + reference: + - title: Section 1931 Medicaid Eligibility + href: https://www.law.cornell.edu/uscode/text/42/1396u-1 + - title: KFF - Medicaid Eligibility for Parents + href: https://www.kff.org/medicaid/state-indicator/medicaid-income-eligibility-limits-for-parents/ +# Non-expansion states that use Section 1931 deprivation rules +# These states did NOT expand Medicaid and have very restrictive parent eligibility +AL: + 2018-01-01: true +FL: + 2018-01-01: true +GA: + 2018-01-01: true +KS: + 2018-01-01: true +MS: + 2018-01-01: true +NC: + 2018-01-01: true + 2023-12-01: false # NC expanded Medicaid +SC: + 2018-01-01: true +SD: + 2018-01-01: true +TN: + 2018-01-01: true +TX: + 2018-01-01: true +WI: + 2018-01-01: true # WI has unusual partial expansion but keeps deprivation +WY: + 2018-01-01: true +# Expansion states - no deprivation requirement +AK: + 2018-01-01: false +AR: + 2018-01-01: false +AZ: + 2018-01-01: false +CA: + 2018-01-01: false +CO: + 2018-01-01: false +CT: + 2018-01-01: false +DC: + 2018-01-01: false +DE: + 2018-01-01: false +HI: + 2018-01-01: false +IA: + 2018-01-01: false +ID: + 2018-01-01: false +IL: + 2018-01-01: false +IN: + 2018-01-01: false +KY: + 2018-01-01: false +LA: + 2018-01-01: false +MA: + 2018-01-01: false +MD: + 2018-01-01: false +ME: + 2018-01-01: false +MI: + 2018-01-01: false +MN: + 2018-01-01: false +MO: + 2018-01-01: false +MT: + 2018-01-01: false +ND: + 2018-01-01: false +NE: + 2018-01-01: false +NH: + 2018-01-01: false +NJ: + 2018-01-01: false +NM: + 2018-01-01: false +NV: + 2018-01-01: false +NY: + 2018-01-01: false +OH: + 2018-01-01: false +OK: + 2018-01-01: false +OR: + 2018-01-01: false +PA: + 2018-01-01: false +RI: + 2018-01-01: false +UT: + 2018-01-01: false +VA: + 2018-01-01: false +VT: + 2018-01-01: false +WA: + 2018-01-01: false +WV: + 2018-01-01: false diff --git a/policyengine_us/parameters/gov/hhs/medicaid/takeup_rate.yaml b/policyengine_us/parameters/gov/hhs/medicaid/takeup_rate.yaml index 1a3a6db93a2..b9d387cdd98 100644 --- a/policyengine_us/parameters/gov/hhs/medicaid/takeup_rate.yaml +++ b/policyengine_us/parameters/gov/hhs/medicaid/takeup_rate.yaml @@ -1,12 +1,116 @@ description: Percentage of people who do enroll in Medicaid, if eligible. -values: - 2018-01-01: 0.93 metadata: label: Medicaid takeup rate unit: /1 period: year economy: false household: false + breakdown: + - state_code reference: - title: KFF "A Closer Look at the Remaining Uninsured Population Eligible for Medicaid and CHIP" - href: https://www.kff.org/uninsured/issue-brief/a-closer-look-at-the-remaining-uninsured-population-eligible-for-medicaid-and-chip/#:~:text=the%20uninsured%20rate%20dropped%20to,States%20began%20the + href: https://www.kff.org/uninsured/issue-brief/a-closer-look-at-the-remaining-uninsured-population-eligible-for-medicaid-and-chip/ + - title: State-specific rates derived from MACPAC enrollment targets vs modeled eligibility + href: https://www.medicaid.gov/medicaid/program-information/medicaid-and-chip-enrollment-data/report-highlights/index.html +AK: + 2018-01-01: 0.88 +AL: + 2018-01-01: 0.92 +AR: + 2018-01-01: 0.79 +AZ: + 2018-01-01: 0.95 +CA: + 2018-01-01: 0.78 +CO: + 2018-01-01: 0.99 +CT: + 2018-01-01: 0.89 +DC: + 2018-01-01: 0.99 +DE: + 2018-01-01: 0.86 +FL: + 2018-01-01: 0.98 +GA: + 2018-01-01: 0.73 +HI: + 2018-01-01: 0.88 +IA: + 2018-01-01: 0.84 +ID: + 2018-01-01: 0.78 +IL: + 2018-01-01: 0.85 +IN: + 2018-01-01: 0.99 +KS: + 2018-01-01: 0.92 +KY: + 2018-01-01: 0.87 +LA: + 2018-01-01: 0.79 +MA: + 2018-01-01: 0.94 +MD: + 2018-01-01: 0.95 +ME: + 2018-01-01: 0.92 +MI: + 2018-01-01: 0.91 +MN: + 2018-01-01: 0.89 +MO: + 2018-01-01: 0.89 +MS: + 2018-01-01: 0.75 +MT: + 2018-01-01: 0.83 +NC: + 2018-01-01: 0.94 +ND: + 2018-01-01: 0.91 +NE: + 2018-01-01: 0.79 +NH: + 2018-01-01: 0.84 +NJ: + 2018-01-01: 0.74 +NM: + 2018-01-01: 0.84 +NV: + 2018-01-01: 0.93 +NY: + 2018-01-01: 0.86 +OH: + 2018-01-01: 0.82 +OK: + 2018-01-01: 0.77 +OR: + 2018-01-01: 0.92 +PA: + 2018-01-01: 0.64 +RI: + 2018-01-01: 0.94 +SC: + 2018-01-01: 0.93 +SD: + 2018-01-01: 0.88 +TN: + 2018-01-01: 0.92 +TX: + 2018-01-01: 0.95 +UT: + 2018-01-01: 0.58 +VA: + 2018-01-01: 0.82 +VT: + 2018-01-01: 0.93 +WA: + 2018-01-01: 0.98 +WI: + 2018-01-01: 0.91 +WV: + 2018-01-01: 0.83 +WY: + 2018-01-01: 0.70 diff --git a/policyengine_us/variables/gov/hhs/medicaid/eligibility/categories/parent/is_parent_for_medicaid_nfc.py b/policyengine_us/variables/gov/hhs/medicaid/eligibility/categories/parent/is_parent_for_medicaid_nfc.py index 31348017c29..6b4807aef81 100644 --- a/policyengine_us/variables/gov/hhs/medicaid/eligibility/categories/parent/is_parent_for_medicaid_nfc.py +++ b/policyengine_us/variables/gov/hhs/medicaid/eligibility/categories/parent/is_parent_for_medicaid_nfc.py @@ -6,10 +6,40 @@ class is_parent_for_medicaid_nfc(Variable): entity = Person label = "Medicaid parent non-financial criteria" definition_period = YEAR + documentation = """ + Determines if a person meets the non-financial criteria for Medicaid + parent eligibility. + + In expansion states: Any adult who is not a dependent and has dependents + in their tax unit qualifies. + + In non-expansion states (Section 1931 states): The state requires a child + to be "deprived of parental support" which typically means single-parent + households only. Two-parent households generally do not qualify unless + one parent is incapacitated or unemployed. + + References: + - 42 USC 1396u-1 (Section 1931) + - https://www.kff.org/medicaid/state-indicator/medicaid-income-eligibility-limits-for-parents/ + """ def formula(person, period, parameters): is_dependent = person("is_tax_unit_dependent", period) has_dependent_in_tax_unit = ( person.tax_unit("tax_unit_count_dependents", period) > 0 ) - return ~is_dependent & has_dependent_in_tax_unit + + # Basic criteria: not a dependent AND has dependents + meets_basic_criteria = ~is_dependent & has_dependent_in_tax_unit + + # Check if state requires deprivation (non-expansion states) + state = person.household("state_code_str", period) + p = parameters(period).gov.hhs.medicaid.eligibility.categories.parent + requires_deprivation = p.requires_deprivation[state] + + # For states requiring deprivation, must be single parent + is_single_parent = person("is_single_parent_household", period) + requires_deprivation_bool = requires_deprivation.astype(bool) + meets_deprivation = ~requires_deprivation_bool | is_single_parent + + return meets_basic_criteria & meets_deprivation diff --git a/policyengine_us/variables/gov/hhs/medicaid/eligibility/categories/parent/is_single_parent_household.py b/policyengine_us/variables/gov/hhs/medicaid/eligibility/categories/parent/is_single_parent_household.py new file mode 100644 index 00000000000..4c3259e8ac4 --- /dev/null +++ b/policyengine_us/variables/gov/hhs/medicaid/eligibility/categories/parent/is_single_parent_household.py @@ -0,0 +1,39 @@ +from policyengine_us.model_api import * + + +class is_single_parent_household(Variable): + value_type = bool + entity = Person + label = "Person is in a single-parent household (for Medicaid deprivation)" + definition_period = YEAR + documentation = """ + Determines if a person is a single parent for purposes of Medicaid + Section 1931 eligibility in non-expansion states. + + Under Section 1931, states that did not expand Medicaid require a child + to be "deprived of parental support" for the parent to qualify. This + typically means single-parent households qualify, while two-parent + households generally do not (unless one parent is incapacitated/unemployed). + + This variable returns True for: + - Head of Household filers with dependents (clearly single parents) + - Single filers with dependents + + It returns False for: + - Joint filers (married couples) + - Married filing separately (still married) + """ + + def formula(person, period, parameters): + filing_status = person.tax_unit("filing_status", period) + is_head = person("is_tax_unit_head", period) + has_dependents = ( + person.tax_unit("tax_unit_count_dependents", period) > 0 + ) + + # Single parent = not married AND has dependents AND is the head + is_joint = filing_status == filing_status.possible_values.JOINT + is_separate = filing_status == filing_status.possible_values.SEPARATE + is_married_filing = is_joint | is_separate + + return ~is_married_filing & has_dependents & is_head diff --git a/policyengine_us/variables/gov/hhs/medicaid/takes_up_medicaid_if_eligible.py b/policyengine_us/variables/gov/hhs/medicaid/takes_up_medicaid_if_eligible.py index c1497f24557..2a11c49127f 100644 --- a/policyengine_us/variables/gov/hhs/medicaid/takes_up_medicaid_if_eligible.py +++ b/policyengine_us/variables/gov/hhs/medicaid/takes_up_medicaid_if_eligible.py @@ -4,10 +4,11 @@ class takes_up_medicaid_if_eligible(Variable): value_type = bool entity = Person - label = "Whether a random eligible person unit does not enroll in Medicaid" + label = "Whether a random eligible person takes up Medicaid" definition_period = YEAR def formula(person, period, parameters): seed = person("medicaid_take_up_seed", period) - takeup_rate = parameters(period).gov.hhs.medicaid.takeup_rate + state = person.household("state_code_str", period) + takeup_rate = parameters(period).gov.hhs.medicaid.takeup_rate[state] return seed < takeup_rate From 47c0e564bca69afae7cfe692c1fc7e11c3da9caf Mon Sep 17 00:00:00 2001 From: "baogorek@gmail.com" Date: Tue, 3 Feb 2026 07:47:13 -0500 Subject: [PATCH 2/9] Refine Medicaid takeup rates for Utah and Texas based on calibration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Utah: 58% → 53% (was 10% high vs administrative enrollment target) - Texas: 95% → 76% (was 25% high; 95% unrealistic for non-expansion state) These adjustments improve calibration match to state Medicaid enrollment targets. Co-Authored-By: Claude Opus 4.5 --- changelog_entry.yaml | 3 ++- policyengine_us/parameters/gov/hhs/medicaid/takeup_rate.yaml | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/changelog_entry.yaml b/changelog_entry.yaml index 22cebad2806..9672889fd38 100644 --- a/changelog_entry.yaml +++ b/changelog_entry.yaml @@ -1,8 +1,9 @@ - bump: minor changes: added: - - State-specific Medicaid takeup rates based on MACPAC enrollment targets vs modeled eligibility. Rates range from 58% (Utah) to 99% (Colorado), replacing the uniform 93% national rate. + - State-specific Medicaid takeup rates calibrated against administrative enrollment data. Rates range from 53% (Utah) to 99% (Colorado), replacing the uniform 93% national rate. - Deprivation requirement parameter for Medicaid parent eligibility in non-expansion states (TX, FL, GA, etc.). - is_single_parent_household variable to determine if a person qualifies under Section 1931 deprivation rules. changed: - Medicaid parent eligibility (is_parent_for_medicaid_nfc) now checks deprivation requirement for non-expansion states, correctly excluding married parents who don't meet Section 1931 criteria. + - Refined takeup rates for Utah (53%) and Texas (76%) based on calibration to state enrollment targets. diff --git a/policyengine_us/parameters/gov/hhs/medicaid/takeup_rate.yaml b/policyengine_us/parameters/gov/hhs/medicaid/takeup_rate.yaml index b9d387cdd98..1c38156ad8d 100644 --- a/policyengine_us/parameters/gov/hhs/medicaid/takeup_rate.yaml +++ b/policyengine_us/parameters/gov/hhs/medicaid/takeup_rate.yaml @@ -99,9 +99,9 @@ SD: TN: 2018-01-01: 0.92 TX: - 2018-01-01: 0.95 + 2018-01-01: 0.76 UT: - 2018-01-01: 0.58 + 2018-01-01: 0.53 VA: 2018-01-01: 0.82 VT: From da57eaf993dffa8b4eade4bc28405a57e27ac9bc Mon Sep 17 00:00:00 2001 From: "baogorek@gmail.com" Date: Tue, 3 Feb 2026 07:55:03 -0500 Subject: [PATCH 3/9] Fix Medicaid takeup test for state-specific rates Update test seed values to work with CA's 0.78 takeup rate (default state). Previous values assumed a ~93% rate which no longer applies. Co-Authored-By: Claude Opus 4.5 --- .../gov/hhs/medicaid/takes_up_medicaid_if_eligible.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/takes_up_medicaid_if_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/takes_up_medicaid_if_eligible.yaml index 0ec73681c48..857d8752bd8 100644 --- a/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/takes_up_medicaid_if_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/takes_up_medicaid_if_eligible.yaml @@ -1,13 +1,13 @@ - name: Seed above takeup rate period: 2025 input: - medicaid_take_up_seed: 1 + medicaid_take_up_seed: 0.79 output: takes_up_medicaid_if_eligible: false - name: Seed below takeup rate period: 2025 input: - medicaid_take_up_seed: 0.9 + medicaid_take_up_seed: 0.77 output: takes_up_medicaid_if_eligible: true From 82edb409aa88317e71ecaf84558eb643af63c3d9 Mon Sep 17 00:00:00 2001 From: "baogorek@gmail.com" Date: Tue, 3 Feb 2026 08:35:32 -0500 Subject: [PATCH 4/9] Make medicaid takeup seed deterministic --- policyengine_us/tools/variables.py | 6 ++++-- .../variables/gov/hhs/medicaid/medicaid_take_up_seed.py | 2 +- .../gov/hhs/medicaid/takes_up_medicaid_if_eligible.py | 2 +- uv.lock | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/policyengine_us/tools/variables.py b/policyengine_us/tools/variables.py index 2ae0e45eb64..fe9805cec7d 100644 --- a/policyengine_us/tools/variables.py +++ b/policyengine_us/tools/variables.py @@ -13,7 +13,9 @@ def add_n(word): def print_variable_summary(variable_name: str): variable = variables.get(variable_name) - return Markdown(f""" + return Markdown( + f""" ## {variable.name} This variable models a{add_n(variable.entity.label)}**{variable.entity.label}**'s **{variable.label}**. - """) + """ + ) diff --git a/policyengine_us/variables/gov/hhs/medicaid/medicaid_take_up_seed.py b/policyengine_us/variables/gov/hhs/medicaid/medicaid_take_up_seed.py index e81d43af0d2..f757d782d6d 100644 --- a/policyengine_us/variables/gov/hhs/medicaid/medicaid_take_up_seed.py +++ b/policyengine_us/variables/gov/hhs/medicaid/medicaid_take_up_seed.py @@ -4,5 +4,5 @@ class medicaid_take_up_seed(Variable): value_type = float entity = Person - label = "Randomly assigned seed for Medicaid take-up" + label = "Deterministic seed for Medicaid take-up" definition_period = YEAR diff --git a/policyengine_us/variables/gov/hhs/medicaid/takes_up_medicaid_if_eligible.py b/policyengine_us/variables/gov/hhs/medicaid/takes_up_medicaid_if_eligible.py index 2a11c49127f..fa37cb21418 100644 --- a/policyengine_us/variables/gov/hhs/medicaid/takes_up_medicaid_if_eligible.py +++ b/policyengine_us/variables/gov/hhs/medicaid/takes_up_medicaid_if_eligible.py @@ -4,7 +4,7 @@ class takes_up_medicaid_if_eligible(Variable): value_type = bool entity = Person - label = "Whether a random eligible person takes up Medicaid" + label = "Whether an eligible person takes up Medicaid" definition_period = YEAR def formula(person, period, parameters): diff --git a/uv.lock b/uv.lock index f11130ff8a4..b220855f8bd 100644 --- a/uv.lock +++ b/uv.lock @@ -1664,7 +1664,7 @@ wheels = [ [[package]] name = "policyengine-us" -version = "1.534.2" +version = "1.546.0" source = { editable = "." } dependencies = [ { name = "microdf-python" }, From 5ac3f4b13b246c0894efd32bbabea8fab2316b7a Mon Sep 17 00:00:00 2001 From: "baogorek@gmail.com" Date: Wed, 4 Feb 2026 08:50:52 -0500 Subject: [PATCH 5/9] lint --- policyengine_us/tools/variables.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/policyengine_us/tools/variables.py b/policyengine_us/tools/variables.py index fe9805cec7d..2ae0e45eb64 100644 --- a/policyengine_us/tools/variables.py +++ b/policyengine_us/tools/variables.py @@ -13,9 +13,7 @@ def add_n(word): def print_variable_summary(variable_name: str): variable = variables.get(variable_name) - return Markdown( - f""" + return Markdown(f""" ## {variable.name} This variable models a{add_n(variable.entity.label)}**{variable.entity.label}**'s **{variable.label}**. - """ - ) + """) From 8ec0e40bd0e4736d59345b63c08daf33623fff63 Mon Sep 17 00:00:00 2001 From: "baogorek@gmail.com" Date: Wed, 4 Feb 2026 16:50:23 -0500 Subject: [PATCH 6/9] Clean up PR: revert seed label, improve test, trim changelog Revert medicaid_take_up_seed label to original, make test explicit about state (CA) and use obvious seed values, remove redundant changelog entry. Co-Authored-By: Claude Opus 4.5 --- changelog_entry.yaml | 1 - .../gov/hhs/medicaid/takes_up_medicaid_if_eligible.yaml | 6 ++++-- .../variables/gov/hhs/medicaid/medicaid_take_up_seed.py | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/changelog_entry.yaml b/changelog_entry.yaml index 9672889fd38..77948dcca8b 100644 --- a/changelog_entry.yaml +++ b/changelog_entry.yaml @@ -6,4 +6,3 @@ - is_single_parent_household variable to determine if a person qualifies under Section 1931 deprivation rules. changed: - Medicaid parent eligibility (is_parent_for_medicaid_nfc) now checks deprivation requirement for non-expansion states, correctly excluding married parents who don't meet Section 1931 criteria. - - Refined takeup rates for Utah (53%) and Texas (76%) based on calibration to state enrollment targets. diff --git a/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/takes_up_medicaid_if_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/takes_up_medicaid_if_eligible.yaml index 857d8752bd8..4cfdeab1f8e 100644 --- a/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/takes_up_medicaid_if_eligible.yaml +++ b/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/takes_up_medicaid_if_eligible.yaml @@ -1,13 +1,15 @@ - name: Seed above takeup rate period: 2025 input: - medicaid_take_up_seed: 0.79 + state_code: CA + medicaid_take_up_seed: 1 output: takes_up_medicaid_if_eligible: false - name: Seed below takeup rate period: 2025 input: - medicaid_take_up_seed: 0.77 + state_code: CA + medicaid_take_up_seed: 0.5 output: takes_up_medicaid_if_eligible: true diff --git a/policyengine_us/variables/gov/hhs/medicaid/medicaid_take_up_seed.py b/policyengine_us/variables/gov/hhs/medicaid/medicaid_take_up_seed.py index f757d782d6d..e81d43af0d2 100644 --- a/policyengine_us/variables/gov/hhs/medicaid/medicaid_take_up_seed.py +++ b/policyengine_us/variables/gov/hhs/medicaid/medicaid_take_up_seed.py @@ -4,5 +4,5 @@ class medicaid_take_up_seed(Variable): value_type = float entity = Person - label = "Deterministic seed for Medicaid take-up" + label = "Randomly assigned seed for Medicaid take-up" definition_period = YEAR From 84bd1607b8c71939311009aaae26e98a4f599b32 Mon Sep 17 00:00:00 2001 From: "baogorek@gmail.com" Date: Wed, 4 Feb 2026 17:09:14 -0500 Subject: [PATCH 7/9] Update uv.lock version Co-Authored-By: Claude Opus 4.5 --- uv.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uv.lock b/uv.lock index c34400be9b8..8ca6e603efe 100644 --- a/uv.lock +++ b/uv.lock @@ -1664,7 +1664,7 @@ wheels = [ [[package]] name = "policyengine-us" -version = "1.550.0" +version = "1.550.1" source = { editable = "." } dependencies = [ { name = "microdf-python" }, From 2daebdc3c670182ff94bd0895f5157c913bf8d86 Mon Sep 17 00:00:00 2001 From: "baogorek@gmail.com" Date: Wed, 4 Feb 2026 17:10:32 -0500 Subject: [PATCH 8/9] Add ssi_resource_test_seed variable and use in meets_ssi_resource_test Replace random() call with deterministic seed from microdata, matching the convention used by other takeup seeds. Co-Authored-By: Claude Opus 4.5 --- .../ssi/eligibility/resources/meets_ssi_resource_test.py | 3 ++- .../ssi/eligibility/resources/ssi_resource_test_seed.py | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 policyengine_us/variables/gov/ssa/ssi/eligibility/resources/ssi_resource_test_seed.py diff --git a/policyengine_us/variables/gov/ssa/ssi/eligibility/resources/meets_ssi_resource_test.py b/policyengine_us/variables/gov/ssa/ssi/eligibility/resources/meets_ssi_resource_test.py index 3d25cfee08e..a5ef2745541 100644 --- a/policyengine_us/variables/gov/ssa/ssi/eligibility/resources/meets_ssi_resource_test.py +++ b/policyengine_us/variables/gov/ssa/ssi/eligibility/resources/meets_ssi_resource_test.py @@ -14,7 +14,8 @@ def formula(person, period, parameters): # Apply policy logic in individual simulation. p = parameters(period).gov.ssa.ssi if person.simulation.dataset is not None: - return random(person) < p.eligibility.resources.pass_rate + seed = person("ssi_resource_test_seed", period) + return seed < p.eligibility.resources.pass_rate joint_claim = person("ssi_claim_is_joint", period) personal_resources = person("ssi_countable_resources", period) countable_resources = where( diff --git a/policyengine_us/variables/gov/ssa/ssi/eligibility/resources/ssi_resource_test_seed.py b/policyengine_us/variables/gov/ssa/ssi/eligibility/resources/ssi_resource_test_seed.py new file mode 100644 index 00000000000..97212945639 --- /dev/null +++ b/policyengine_us/variables/gov/ssa/ssi/eligibility/resources/ssi_resource_test_seed.py @@ -0,0 +1,8 @@ +from policyengine_us.model_api import * + + +class ssi_resource_test_seed(Variable): + value_type = float + entity = Person + label = "Deterministic seed for SSI resource test" + definition_period = YEAR From 97b3d9a322a7c64cabc66163c4dc223900884ef4 Mon Sep 17 00:00:00 2001 From: "baogorek@gmail.com" Date: Wed, 4 Feb 2026 18:03:42 -0500 Subject: [PATCH 9/9] Add test for meets_ssi_resource_test microsimulation branch Covers the dataset-based probabilistic path (lines 17-18) that was causing codecov/patch coverage failure. Co-Authored-By: Claude Opus 4.5 --- .../test_meets_ssi_resource_test.py | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/test_meets_ssi_resource_test.py diff --git a/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/test_meets_ssi_resource_test.py b/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/test_meets_ssi_resource_test.py new file mode 100644 index 00000000000..03820515966 --- /dev/null +++ b/policyengine_us/tests/policy/baseline/gov/ssa/ssi/eligibility/test_meets_ssi_resource_test.py @@ -0,0 +1,25 @@ +from policyengine_us import Simulation + + +def test_meets_ssi_resource_test_microsim_branch(): + sim = Simulation( + situation={ + "people": { + "person1": { + "ssi_resource_test_seed": {"2024": 0.1}, + }, + "person2": { + "ssi_resource_test_seed": {"2024": 0.9}, + }, + }, + "households": { + "household1": { + "members": ["person1", "person2"], + }, + }, + } + ) + sim.dataset = "mock" + result = sim.calculate("meets_ssi_resource_test", "2024") + assert result[0] == True # 0.1 < 0.4 pass_rate + assert result[1] == False # 0.9 >= 0.4 pass_rate