-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic pension contributions imputation
- Loading branch information
1 parent
482e4be
commit 007cce6
Showing
2 changed files
with
28 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from survey_enhance import Imputation | ||
from policyengine_us import Microsimulation | ||
from tax_microdata_benchmarking.datasets.cps import CPS_2021 | ||
|
||
|
||
def impute_pension_contributions_to_puf(puf_df): | ||
|
||
cps = Microsimulation(dataset=CPS_2021) | ||
cps_df = cps.calculate_dataframe( | ||
["employment_income", "household_weight", "pre_tax_contributions"] | ||
) | ||
|
||
pension_contributions = Imputation() | ||
pension_contributions.train( | ||
X=cps_df[["employment_income"]], | ||
Y=cps_df[["pre_tax_contributions"]], | ||
sample_weight=cps_df["household_weight"], | ||
) | ||
return pension_contributions.predict(X=puf_df[["employment_income"]]) |