PolicyEngine / policyengine-app

PolicyEngine's free web app for computing the impact of public policy.
GNU Affero General Public License v3.0
36 stars 99 forks source link

The parameter editing model is ill-defined in some cases #1240

Closed abhcs closed 7 months ago

abhcs commented 7 months ago

Any parameter is a step function from Date -> Value. A canonical representation of a parameter is provided below:

{
    "2013-01-01": 1000,
    "2018-01-01": 1400,
    "2022-01-01": 1500,
    "2023-01-01": 1600,
    "2024-01-01": 1700,
    "2026-01-01": 1000
}

The interpretation of the representation is that the parameter equals

In the parameter editor, we allow the user to modify a parameter by specifying a new value for a chosen interval. For the parameter in our example, such an edit is ok if the interval intersects ["2013-01-01", inf). However, let's say that the user specifies the value 500 for ["2010-01-01", "2011-12-31"]. Now the parameter must be defined for ["2010-01-01", "2011-12-31"], then undefined for ["2012-01-01", "2013-01-01"), and then defined for ["2013-01-01", inf). This new parameter cannot be represented in the canonical form. Currently, we ignore the right endpoint of the user-specified interval, i.e., "2011-12-31", and decide that the new parameter is given by:

{
    "2010-01-01": 500,
    "2013-01-01": 1000,
    "2018-01-01": 1400,
    "2022-01-01": 1500,
    "2023-01-01": 1600,
    "2024-01-01": 1700,
    "2026-01-01": 1000
}

There are two possible fixes for this error:

  1. Enforce that each parameter is defined from (-inf, inf) at all times, perhaps by adding a mandatory entry of the form "-inf": value in each parameter.
  2. Do not allow an edit to modify a region before the earliest point of definition, "2013-01-01" in the example.
MaxGhenis commented 7 months ago

I'd favor the second option. For example, we don't define the ACTC amount (the example parameter) prior to 2013 because we don't calculate the ACTC prior to then. We actually don't even calculate it prior to 2018 I think, so we show it more for illustration.

To take the second option further: we could restrict parameter changes to years in which we offer microsimulation outputs--currently 2021-2025. There are some edge case policies that depend on parameter values prior to then even for computing current effects, but I think we can leave those off for now and treat pre-microsim parameter histories otherwise as illustrative.