PolicyEngine / policyengine-api

PolicyEngine's REST API for computing policy impacts.
GNU Affero General Public License v3.0
7 stars 19 forks source link

Add relative LSR changes to single_economy controller #1540

Closed anth-volk closed 1 month ago

anth-volk commented 1 month ago

Fixes #1539. Fixes #1542. This PR alters the single_economy controller (or more specifically, the labour_supply_response function within endpoints/economy/compare.py) in order to respond with relative society-wide income, substitution, and total labor supply effects. This also calculates the relative overall and decile LSR impacts against total_net_income instead of household_market_income. In this, I'm hoping for confirmation that this does, in fact, represent earnings; it is my understanding that it does, but hoping for a double-check.

These change are required to enable https://github.com/PolicyEngine/policyengine-app/issues/1787

anth-volk commented 1 month ago

Thanks for linking #1542, I'll prioritize these changes today, as well as some of the simpler changes to the front end, then hopefully bring https://github.com/PolicyEngine/policyengine-app/issues/1787 in line either late today or early tomorrow.

anth-volk commented 1 month ago

Have updated. Nikhil had indicated that this code better fit your desire for code that was more parallel in terms of calculation.

MaxGhenis commented 1 month ago

OK but this doesn't fix #1542 as it divides by net income rather than baseline earnings. Would you like to tackle that in a separate PR?

MaxGhenis commented 1 month ago

If easier to remove relative income and substitution effects entirely for now we can do that. But we should not display them until they express the percent change in earnings.

anth-volk commented 1 month ago

I'm sorry, I'm having difficulty understanding. Looking at the definition of total_net_income in the API, I now understand that it is not baseline earnings, as it includes benefits. However, household_market_income's definition, per policyengine-us, is the following:

    adds = [
        "employment_income",
        "self_employment_income",
        "pension_income",
        "dividend_income",
        "interest_income",
        "gi_cash_assistance",
        "capital_gains",
        "rental_income",
        "illicit_income",
        "farm_income",
        "miscellaneous_income",
    ]

with no subtracts. I'm surprised that this isn't essentially just a more exhaustive baseline earnings, as defined by your comment earlier. Is baseline earnings essentially household_market_income, but without the various extra income categories?

If it is something different, I'd need to look into further changes, either somewhere else in the API or potentially to core, as the API does not currently return any baseline earnings value. It may be advantageous to tackle in a separate issue, but what your confirmation on household_market_income first.

MaxGhenis commented 1 month ago

Yes, earnings is only employment_income + self_employment_income. Those are the only income sources that we model behavioral responses over (see labor_supply_response.py in policyengine-us). Households cannot adjust other income sources like pensions in the same way in response to policy changes, and partial equilibrium models like ours generally assume they cannot at all. Households can adjust capital gains significantly (elasticities are higher), but we haven't modeled that yet. In general, earnings are defined as employment + self-employment income in US and UK programs, such as the Earned Income Tax Credit and the SSI Earned Income Exclusion.

anth-volk commented 1 month ago

Thanks for the explanation, it's much appreciated. In that case, early tomorrow (somewhere between 5 and 7am US Eastern) I'll disable the relative outputs in the app and ask Nikhil for review.

Then, I'll work on adjusting the API to actually calculate baseline earnings - I'd imagine that's as simple as requesting it from the computed household somewhere, but don't know well enough to give any guarantees in terms of time requirements. If that ends up being simple, I'll edit the API to actually use it and display and re-enable relative outputs. If not, I'll leave it disabled, pending getting it working.

anth-volk commented 1 month ago

As an update: #1836 has been merged, temporarily disabling the relative impacts. Looking through the code, I think fixing this may actually require changes to the country packages for a couple of reasons that I'm hoping to discuss with Nikhil today to set up a plan of action. That said, it's unlikely that this will be done in time for today's presentation.

anth-volk commented 1 month ago

While working on #1542 using Nikhil's template from #1547, I ran into a strange configuration issue on this PR and could never successfully run the code. Closing in light of that. Will redo #1539 following the merging of that.