Skip to content
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

Add Admin Costs #287

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file modified cps_data/cps.csv.gz
Binary file not shown.
22 changes: 22 additions & 0 deletions cps_data/finalprep.py
Expand Up @@ -348,6 +348,18 @@ def benefits(data, other_ben):
benefits variable.
Replaces Medicare and Medicaid values with set amounts
"""
def administrative_cost(data, program, cost):
"""
Distribute administrative costs for a given program to all particpants
"""
cols = program + '_VAL' + pd.Series((np.arange(15) + 1).astype(str))
count = data[cols].astype(bool).sum(axis=1)
weighted_count = (count * data['s006']).sum()
admin_cost = cost * 1e9 / weighted_count
# Assign the admin cost to each person in the unit receiving benefit
unit_admin_cost = count * admin_cost
return unit_admin_cost

# Replace Medicare and Medicaid
medicare_cols = 'MCARE_VAL' + pd.Series((np.arange(15) + 1).astype(str))
medicaid_cols = 'MCAID_VAL' + pd.Series((np.arange(15) + 1).astype(str))
Expand All @@ -364,6 +376,16 @@ def benefits(data, other_ben):
data['mcare_ben'] = data[medicare_cols].sum(axis=1)
data['mcaid_ben'] = data[medicaid_cols].sum(axis=1)

# Add administrative cost of programs
data['mcaid_ben'] += administrative_cost(data, 'MCAID', 24.4)
data['mcare_ben'] += administrative_cost(data, 'MCARE', 8.8)
data['ssi_ben'] += administrative_cost(data, 'SSI', 3.0)
data['snap_ben'] += administrative_cost(data, 'SNAP', 4.2)
data['vet_ben'] += administrative_cost(data, 'VB', 7.6)
data['tanf_ben'] += administrative_cost(data, 'TANF', 2.3)
data['wic_ben'] += administrative_cost(data, 'WIC', 1.9)
data['housing_ben'] += administrative_cost(data, 'HOUSING', 1.4)

other_ben['2014_cost'] *= 1e6

# Distribute other benefits
Expand Down
18 changes: 9 additions & 9 deletions tests/cps_agg_expected.txt
Expand Up @@ -50,21 +50,21 @@ ffpos 498582 1 11
filer 437439 0 1
fips 12469516 1 56
h_seq 22850538907 1 99461
housing_ben 60379435 0 53253
mcaid_ben 888211102 0 98440
mcare_ben 1778073024 0 92976
housing_ben 89771413 0 59894
mcaid_ben 946994065 0 104957
mcare_ben 1805193353 0 94396
n1820 36555 0 6
n21 711316 0 11
n24 226097 0 10
nu05 45400 0 4
nu13 163487 0 10
nu18 281400 0 12
other_ben 462782071 0 40211
other_ben 453725095 0 39531
pencon_p 0 0 0
pencon_s 0 0 0
s006 16296813000 100 561900
snap_ben 141713659 0 26569
ssi_ben 103019670 0 64378
tanf_ben 92081596 0 159407
vet_ben 469788696 0 169920
wic_ben 7644480 0 4972
snap_ben 148968569 0 26959
ssi_ben 108719418 0 65570
tanf_ben 99235445 0 161573
vet_ben 493902364 0 172969
wic_ben 11674205 0 6830
56 changes: 28 additions & 28 deletions tests/test_data.py
Expand Up @@ -187,39 +187,39 @@ def check_cps_benefits(data):
expect_ben_stat = dict()
# .. maximum value per filing unit for benefit
expect_ben_stat['max'] = {
'mcare': 92976, # <--- implies a filing unit with 8 beneficiaries
'mcaid': 98440, # <--- implies a filing unit with 14 beneficiaries
'ssi': 64378,
'snap': 26569,
'wic': 4972,
'tanf': 159407, # <--- SEEMS ABSURD ($13,284/month)
'housing': 53253,
'vet': 169920, # <--- HIGH ($14,160/month) military pension or what?
'other': 40211
'mcare': 94396, # <--- implies a filing unit with 8 beneficiaries
'mcaid': 104957, # <--- implies a filing unit with 14 beneficiaries
'ssi': 65570,
'snap': 26959,
'wic': 6830,
'tanf': 161573, # <--- SEEMS ABSURD ($13,284/month)
'housing': 59894,
'vet': 172969, # <--- HIGH ($14,160/month) military pension or what?
'other': 39531
}
# .. minimum value per filing unit for positive benefit
expect_ben_stat['min'] = {
'mcare': 11622, # <--- the actuarial value of Medicare insurance
'mcaid': 7031, # <--- the actuarial value of Medicaid insurance
'ssi': 1, # <--- SEEMS LOW
'snap': 9, # <--- SEEMS LOW
'wic': 241,
'tanf': 1, # <--- SEEMS LOW
'housing': 1265,
'vet': 9890, # <--- is this actuarial value of VA hospital costs?
'other': 3
'mcare': 11799, # <--- the actuarial value of Medicare insurance
'mcaid': 7496, # <--- the actuarial value of Medicaid insurance
'ssi': 398, # <--- SEEMS LOW
'snap': 107, # <--- SEEMS LOW
'wic': 507,
'tanf': 541, # <--- SEEMS LOW
'housing': 4585,
'vet': 11414, # <--- is this actuarial value of VA hospital costs?
'other': 40
}
# .. mean value per filing unit of positive benefit
expect_ben_stat['avg'] = {
'mcare': 14928,
'mcaid': 13192,
'ssi': 7913,
'snap': 2907,
'wic': 748,
'tanf': 9117,
'housing': 7048,
'vet': 29912,
'other': 4706
'mcare': 15156,
'mcaid': 14065,
'ssi': 8350,
'snap': 3055,
'wic': 1142,
'tanf': 9790,
'housing': 10676,
'vet': 31460,
'other': 4610
}
# compare actual and expected benefit statistics
error_msg = ''
Expand Down Expand Up @@ -252,7 +252,7 @@ def check_cps_benefits(data):
if bname == 'mcare' or bname == 'mcaid':
ratio = float(maxben) / minpben
expect_ratio = round(ratio)
if not np.allclose([ratio], [expect_ratio], rtol=0, atol=0.001):
if not np.allclose([ratio], [expect_ratio], rtol=0, atol=0.002):
msg = '\nCPS {}_ben ratio={:.6f} != {:.0f}'
error_msg += msg.format(bname, ratio, expect_ratio)
if error_msg:
Expand Down