PSLmodels / OG-UK

An overlapping generations model to simulate fiscal policy the United Kingdom.
https://pslmodels.github.io/OG-UK
Other
6 stars 7 forks source link

Update calibration handling of tax function parameters #56

Closed jdebacker closed 3 months ago

jdebacker commented 1 year ago

This PR addresses Issue #55, but updating calibrate.py to handle tax function parameters stored in lists, as is done in the most recent version of OG-Core.

This PR also updates a dependency from openfisca_uk to policyengine_uk (Issue #54).

jdebacker commented 1 year ago

Working through API changes for PolicyEngine. Latest traceback:

Traceback (most recent call last):
  File "/Users/jason.debacker/repos/OG-UK/examples/run_oguk.py", line 199, in <module>
    main(reform=reform)
  File "/Users/jason.debacker/repos/OG-UK/examples/run_oguk.py", line 78, in main
    c = Calibration(p, estimate_tax_functions=True, client=client)
  File "/Users/jason.debacker/repos/OG-UK/oguk/calibrate.py", line 33, in __init__
    self.tax_function_params = self.get_tax_function_parameters(
  File "/Users/jason.debacker/repos/OG-UK/oguk/calibrate.py", line 113, in get_tax_function_parameters
    micro_data, taxcalc_version = get_micro_data.get_data(
  File "/Users/jason.debacker/repos/OG-UK/oguk/get_micro_data.py", line 210, in get_data
    results = client.gather(futures)
  File "/Users/jason.debacker/anaconda3/envs/oguk-dev/lib/python3.9/site-packages/distributed/client.py", line 2294, in gather
    return self.sync(
  File "/Users/jason.debacker/anaconda3/envs/oguk-dev/lib/python3.9/site-packages/distributed/utils.py", line 339, in sync
    return sync(
  File "/Users/jason.debacker/anaconda3/envs/oguk-dev/lib/python3.9/site-packages/distributed/utils.py", line 406, in sync
    raise exc.with_traceback(tb)
  File "/Users/jason.debacker/anaconda3/envs/oguk-dev/lib/python3.9/site-packages/distributed/utils.py", line 379, in f
    result = yield future
  File "/Users/jason.debacker/anaconda3/envs/oguk-dev/lib/python3.9/site-packages/tornado/gen.py", line 769, in run
    value = future.result()
  File "/Users/jason.debacker/anaconda3/envs/oguk-dev/lib/python3.9/site-packages/distributed/client.py", line 2157, in _gather
    raise exception.with_traceback(traceback)
  File "/Users/jason.debacker/repos/OG-UK/oguk/get_micro_data.py", line 126, in get_calculator_output
    "mtr_labinc": get_household_mtrs(
  File "/Users/jason.debacker/repos/OG-UK/oguk/get_micro_data.py", line 65, in get_household_mtrs
    reformed = Microsimulation(reform, **kwargs)
  File "/Users/jason.debacker/anaconda3/envs/oguk-dev/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py", line 131, in __init__
    self.build_from_dataset()
  File "/Users/jason.debacker/anaconda3/envs/oguk-dev/lib/python3.9/site-packages/policyengine_core/simulations/simulation.py", line 172, in build_from_dataset
    self.tax_benefit_system.instantiate_entities()
AttributeError: 'tuple' object has no attribute 'instantiate_entities'

cc @nikhilwoodruff

jdebacker commented 10 months ago

Note, this PR is waiting on some appropriate data to be available for public consumption from PolicyEngine-UK

cc @nikhilwoodruff @rickecon

jdebacker commented 3 months ago

Tests are failing bc there still is not a usable dataset for PolicyEngine-UK.

But merging anyway to get in some of the other work in this PR.