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

Conditional formulas #1135

Open
nikhilwoodruff opened this issue Jul 15, 2022 · 0 comments
Open

Conditional formulas #1135

nikhilwoodruff opened this issue Jul 15, 2022 · 0 comments

Comments

@nikhilwoodruff
Copy link
Contributor

Often variables have a formula applying to a population, but will only ever be calculated for a subset of that population. For example, in the US, we have State tax variables for every State (relevant only to tax units in that State). Or, in all systems, we have benefit variables relevant only to entities which meet qualification criteria.

Right now, because of how OpenFisca is implemented using vectorised functions, we carry out all computations on the entire population for which a variable is defined. This creates unnecessary computation, and I think there's a way to avoid that without changing anything fundamental about the OpenFisca interface, and without stopping to use vectorised functions.

I'm envisioning something like:

class some_variable(Variable):
  entity = Person
  label = "Some variable"
  definition_period = YEAR
  value_type = float
  default_value = 1
  calculate_if = "meets_qualification_criteria"

  def formula(person, period, parameters):
    return 2

This is of importance to us in the US system, so I'm going to begin developing a solution using monkey-patching in OpenFisca-Tools. But it'd be much cleaner (and more accessible to other countries) to implement in OpenFisca-Core. Would Core be open to this feature?

cc @benjello @MattiSG @sandcha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant