Skip to content

Commit 74dd912

Browse files
committed
Anchor QRF Social Security split by age
1 parent 9ee3589 commit 74dd912

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

policyengine_us_data/calibration/puf_impute.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,29 @@ def _qrf_ss_shares(
325325
for sub in shares:
326326
shares[sub] = np.where(total > 0, shares[sub] / total, 0.0)
327327

328+
if (
329+
"age" in data
330+
and "social_security_retirement" in shares
331+
and "social_security_disability" in shares
332+
):
333+
# Preserve QRF survivor/dependent predictions, but anchor the
334+
# retirement-vs-disability split to the same age rule as the fallback.
335+
age = data["age"][time_period][:n_cps][puf_has_ss]
336+
is_old = age >= MINIMUM_RETIREMENT_AGE
337+
retirement_or_disability = (
338+
shares["social_security_retirement"] + shares["social_security_disability"]
339+
)
340+
shares["social_security_retirement"] = np.where(
341+
is_old,
342+
retirement_or_disability,
343+
0.0,
344+
)
345+
shares["social_security_disability"] = np.where(
346+
is_old,
347+
0.0,
348+
retirement_or_disability,
349+
)
350+
328351
del fitted, predictions
329352
gc.collect()
330353

0 commit comments

Comments
 (0)