Skip to content

Commit 786b18e

Browse files
Calibrate state populations (and under-5s) (#121)
* Add dataset comparisons to docs * Add inequality to book * Add population by state to calibration * Update uprating factors * Update versioning and dataset URLs
1 parent 2f0e8cf commit 786b18e

12 files changed

Lines changed: 115 additions & 6 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@
99
!eitc.csv
1010
!spm_threshold_agi.csv
1111
**/_build
12+
!population_by_state.csv

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ docker:
3131

3232
documentation:
3333
jb clean docs && jb build docs
34+
python docs/add_plotly_to_book.py docs
35+
3436

3537
data:
3638
python policyengine_us_data/datasets/acs/acs.py

changelog_entry.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
- bump: minor
2+
changes:
3+
added:
4+
- Metric comparisons by dataset to the documentation.
5+
- Calibration of state populations.

docs/add_plotly_to_book.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import argparse
2+
from pathlib import Path
3+
4+
# This command-line tools enables Plotly charts to show in the HTML files for the Jupyter Book documentation.
5+
6+
parser = argparse.ArgumentParser()
7+
parser.add_argument("book_path", help="Path to the Jupyter Book.")
8+
9+
args = parser.parse_args()
10+
11+
# Find every HTML file in the Jupyter Book. Then, add a script tag to the start of the <head> tag in each file, with the contents:
12+
# <script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script>
13+
14+
book_folder = Path(args.book_path)
15+
16+
for html_file in book_folder.glob("**/*.html"):
17+
with open(html_file, "r") as f:
18+
html = f.read()
19+
20+
# Add the script tag to the start of the <head> tag.
21+
html = html.replace(
22+
"<head>",
23+
'<head><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script>',
24+
)
25+
26+
with open(html_file, "w") as f:
27+
f.write(html)

docs/results.ipynb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@
310310
},
311311
{
312312
"cell_type": "code",
313-
"execution_count": 92,
313+
"execution_count": 94,
314314
"metadata": {},
315315
"outputs": [
316316
{
@@ -7270,7 +7270,8 @@
72707270
" title=\"Weight\",\n",
72717271
" type=\"log\",\n",
72727272
" ),\n",
7273-
")"
7273+
")\n",
7274+
"fig"
72747275
]
72757276
}
72767277
],

policyengine_us_data/datasets/acs/acs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class ACS_2022(ACS):
111111
time_period = 2022
112112
file_path = STORAGE_FOLDER / "acs_2022.h5"
113113
census_acs = CensusACS_2022
114-
url = "release://PolicyEngine/policyengine-us-data/1.11.0/acs_2022.h5"
114+
url = "release://PolicyEngine/policyengine-us-data/1.13.0/acs_2022.h5"
115115

116116

117117
if __name__ == "__main__":

policyengine_us_data/datasets/cps/cps.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ class CPS_2024(CPS):
648648
label = "CPS 2024 (2022-based)"
649649
file_path = STORAGE_FOLDER / "cps_2024.h5"
650650
time_period = 2024
651-
url = "release://policyengine/policyengine-us-data/1.11.0/cps_2024.h5"
651+
url = "release://policyengine/policyengine-us-data/1.13.0/cps_2024.h5"
652652

653653

654654
class PooledCPS(Dataset):
@@ -707,7 +707,7 @@ class Pooled_3_Year_CPS_2023(PooledCPS):
707707
CPS_2023,
708708
]
709709
time_period = 2023
710-
url = "release://PolicyEngine/policyengine-us-data/1.11.0/pooled_3_year_cps_2023.h5"
710+
url = "release://PolicyEngine/policyengine-us-data/1.13.0/pooled_3_year_cps_2023.h5"
711711

712712

713713
if __name__ == "__main__":

policyengine_us_data/datasets/cps/enhanced_cps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ class EnhancedCPS_2024(EnhancedCPS):
189189
name = "enhanced_cps_2024"
190190
label = "Enhanced CPS 2024"
191191
file_path = STORAGE_FOLDER / "enhanced_cps_2024.h5"
192-
url = "release://policyengine/policyengine-us-data/1.11.0/enhanced_cps_2024.h5"
192+
url = "release://policyengine/policyengine-us-data/1.13.0/enhanced_cps_2024.h5"
193193

194194

195195
if __name__ == "__main__":
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
state,population,population_under_5
2+
CA,38965193.00,2104120.00
3+
TX,30503301.00,1921708.00
4+
FL,22610726.00,1130536.00
5+
NY,19571216.00,1037274.00
6+
PA,12961683.00,661046.00
7+
IL,12549689.00,665134.00
8+
OH,11785935.00,660012.00
9+
GA,11029227.00,639695.00
10+
NC,10835491.00,606787.00
11+
MI,10037261.00,531975.00
12+
NJ,9290841.00,520287.00
13+
VA,8715698.00,488079.00
14+
WA,7812880.00,421896.00
15+
AZ,7431344.00,393861.00
16+
TN,7126489.00,413336.00
17+
MA,7001399.00,343069.00
18+
IN,6862199.00,404870.00
19+
MO,6196156.00,353181.00
20+
MD,6180253.00,352274.00
21+
WI,5910955.00,313281.00
22+
CO,5877610.00,311513.00
23+
MN,5737915.00,327061.00
24+
SC,5373555.00,290172.00
25+
AL,5108468.00,291183.00
26+
LA,4573749.00,278999.00
27+
KY,4526154.00,262517.00
28+
OR,4233358.00,203201.00
29+
OK,4053824.00,243229.00
30+
CT,3617176.00,180859.00
31+
UT,3417734.00,232406.00
32+
IA,3207004.00,186006.00
33+
PR,3205691.00,96171.00
34+
NV,3194176.00,172486.00
35+
AR,3067732.00,180996.00
36+
KS,2940546.00,176433.00
37+
MS,2939690.00,173442.00
38+
NM,2114371.00,107833.00
39+
NE,1978379.00,124638.00
40+
ID,1964726.00,113954.00
41+
WV,1770071.00,86733.00
42+
HI,1435138.00,77497.00
43+
NH,1402054.00,63092.00
44+
ME,1395722.00,61412.00
45+
MT,1132812.00,57773.00
46+
RI,1095962.00,52606.00
47+
DE,1031890.00,54690.00
48+
SD,919318.00,57917.00
49+
ND,783926.00,49387.00
50+
AK,733406.00,46205.00
51+
DC,678972.00,38701.00
52+
VT,647464.00,27193.00
53+
WY,584057.00,30955.00

policyengine_us_data/storage/uprating_factors.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ alimony_expense,1.0,1.166,1.148,1.215,1.28,1.318,1.35,1.389,1.428,1.467,1.513,1.
33
alimony_income,1.0,1.255,1.322,1.357,1.446,1.504,1.535,1.567,1.576,1.595,1.622,1.655,1.689,1.723,1.779
44
american_opportunity_credit,1.0,1.166,1.148,1.215,1.28,1.318,1.35,1.389,1.428,1.467,1.513,1.561,1.611,1.663,1.718
55
amt_foreign_tax_credit,1.0,1.166,1.148,1.215,1.28,1.318,1.35,1.389,1.428,1.467,1.513,1.561,1.611,1.663,1.718
6+
capital_gains_before_response,1.0,1.824,1.11,1.195,1.244,1.195,1.14,1.122,1.126,1.145,1.173,1.206,1.243,1.283,1.326
67
casualty_loss,1.0,1.166,1.148,1.215,1.28,1.318,1.35,1.389,1.428,1.467,1.513,1.561,1.611,1.663,1.718
78
cdcc_relevant_expenses,1.0,1.166,1.148,1.215,1.28,1.318,1.35,1.389,1.428,1.467,1.513,1.561,1.611,1.663,1.718
89
charitable_cash_donations,1.0,1.166,1.148,1.215,1.28,1.318,1.35,1.389,1.428,1.467,1.513,1.561,1.611,1.663,1.718

0 commit comments

Comments
 (0)