Code Monkey home page Code Monkey logo

og-usa's Introduction

OG-USA

Org PSL cataloged OS License: CC0-1.0 Jupyter Book Badge
Package Python 3.9 Python 3.10 Python 3.11 PyPI Latest Release PyPI Downloads Code style: black
Testing example event parameter example event parameter example event parameter Codecov

OG-USA is an overlapping-generations (OG) model that allows for dynamic general equilibrium analysis of fiscal policy for the United States. OG-USA is built on the OG-Core framework. The model output includes changes in macroeconomic aggregates (GDP, investment, consumption), wages, interest rates, and the stream of tax revenues over time. Regularly updated documentation of the model theory--its output, and solution method--and the Python API is available at https://pslmodels.github.io/OG-Core and documentation of the specific United States calibration of the model is available at https://pslmodels.github.io/OG-USA.

Disclaimer

The model is constantly under development, and model components could change significantly. The package will have released versions, which will be checked against existing code prior to release. Stay tuned for an upcoming release!

Using/contributing to OG-USA

  • Install the Anaconda distribution of Python
  • Clone this repository to a directory on your computer
  • From the terminal (or Conda command prompt), navigate to the directory to which you cloned this repository and run conda env create -f environment.yml. The process of creating the ogusa-dev conda environment can take more than 20 minutes. The pip install of the OG-Core dependency from GitHub takes most of the time.
  • Then, conda activate ogusa-dev
  • Then install by pip install -e .
  • Navigate to ./examples
  • Run the model with an example reform from terminal/command prompt by typing python run_og_usa.py
  • You can adjust the ./examples/run_og_usa.py by modifying model parameters specified in the dictionary passed to the p.update_specifications() calls.
  • Model outputs will be saved in the following files:
    • ./examples/OG-USA_example_plots
      • This folder will contain a number of plots generated from OG-Core to help you visualize the output from your run
    • ./examples/ogusa_example_output.csv
      • This is a summary of the percentage changes in macro variables over the first ten years and in the steady-state.
    • ./examples/OG-USA-Example/OUTPUT_BASELINE/model_params.pkl
      • Model parameters used in the baseline run
      • See ogcore.execute.py for items in the dictionary object in this pickle file
    • ./examples/OG-USA-Example/OUTPUT_BASELINE/SS/SS_vars.pkl
      • Outputs from the model steady state solution under the baseline policy
      • See ogcore.SS.py for what is in the dictionary object in this pickle file
    • ./examples/OG-USA-Example/OUTPUT_BASELINE/TPI/TPI_vars.pkl
      • Outputs from the model timepath solution under the baseline policy
      • See ogcore.TPI.py for what is in the dictionary object in this pickle file
    • An analogous set of files in the ./examples/OUTPUT_REFORM directory, which represent objects from the simulation of the reform policy

Note that, depending on your machine, a full model run (solving for the full time path equilibrium for the baseline and reform policies) can take more than two hours of compute time.

If you run into errors running the example script, please open a new issue in the OG-USA repo with a description of the issue and any relevant tracebacks you receive.

Once the package is installed, one can adjust parameters in the OG-Core Specifications object using the Calibration class as follows:

from ogcore.parameters import Specifications
from ogusa.calibrate import Calibration
p = Specifications()
c = Calibration(p)
updated_params = c.get_dict()
p.update_specifications({'initial_debt_ratio': updated_params['initial_debt_ratio']})

Core Maintainers

The core maintainers of the OG-Core repository are:

  • Jason DeBacker (GitHub handle: jdebacker), Associate Professor, Department of Economics, Darla Moore School of Business, University of South Carolina; President, PSL Foundation; Vice President of Research and Co-founder, Open Research Group, Inc.
  • Richard W. Evans (GitHub handle: rickecon), Senior Research Fellow and Director of Open Policy, Center for Growth and Opportunity at Utah State University; President, Open Research Group, Inc.; Director, Open Source Economics Laboratory.

Citing OG-USA

OG-USA (Version #.#.#)[Source code], https://github.com/PSLmodels/OG-USA.

og-usa's People

Contributors

jdebacker avatar kcreekdev avatar maxghenis avatar prrathi avatar rickecon avatar talumbau avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

og-usa's Issues

Calibrating the IO matrix

To calibrate the IO matrix, which maps the fixed coefficient relationship between producer goods and consumer goods, we need information from a make-use table.

UNU Wider has some SAM files that work well for this, but does not cover the US (see how one of these is used in OG-ZAF here.

For US data on this, we can try:

Install ogcore from pip

If we install ogcore via pip in environment.yml (rather than from GH), the installation process will go much faster.

Several instances have head_age = 999

From the data info, this is for head ages that are unknown. If I'm grouping the instances by head age and income, should these instances with head_age = 999 be dropped?

Get ogusa package name on PyPI available and updated

We would like to post the ogusa package in the Python Package Index (PyPI.org) so that it can be pip installed. However, the package name is currently taken (see https://pypi.org/project/ogusa/). But this is an old version of OG-USA that was last updated 7 years ago. The maintainers of the old OG-USA package on PyPI.org are Matt Jensen, Peter Steinberg, and TJ Alumbaugh. We should get one of those maintainers to do one of the following three options (in order of preference):

  1. Have the current maintainers give @rickecon and @jdebacker control of the ogusa PyPI package. Then we can remove Matt Jensen, Peter Steinberg, and TJ Alumbaugh as maintainers and update the package.
  2. Have the current maintainers delete the old ogusa PyPI package. Then we should be able to use that package name and add the new package to PyPI.
  3. Contact PyPI to get control of a package that is out of use.

cc: @jdebacker

Use OG-USA package on compute studio

The OG-USA Compute Studio app is currently using an old version of the model from the OG-Core repo. We should resolve Issue #46 (updating default parameters) and then update the cs_config files to work with the new OG-USA api. After that, we can update C/S to run this new version of the model.

Household structure variables from the PSID

@MaxGhenis and @prrathi are working on an estimate of the number of children per household. The current version of the psid_download.R script in this repo pulls a few related variables:

                        # Demographics
                        head_age="ER17013",
                        spouse_age="ER47319",
                        head_gender="ER47318",
                        head_num_children="V10977",
                        num_children="ER37724",
                        num_children_away_from_home="V561",
                        num_children_under18="ER47320",

Are there additional variables you two would like pulled? FYI, PSID variable search is here.

Add units tests

Begin to add unit tests for functions. Some of these (e.g., for income.py, demographics.py, get_micro_data.py, and txfunc.py can be taken directly from the OG-USA repo.

Getting a crash on Wayland/display issues when running run_og_usa.py example

Not really sure what's going on but I'm getting a crash when running the example with a recently synced version of OG-USA + OG-Core. I'm running in a Linux terminal through tmux which can have odd behavior if you are running a program that has any sort of GUI feature. I didn't anticipate that such a thing would happen with OG-USA, but it appears that the program is attempting to do something with a windowing component. Here is the crash message:

Finished tax function loop through 11 years and 80 ages per year.                                                                                         
Tax function estimation time: 55.551 sec                                                                                                                  
ETR :  0  observations tagged as outliers.                                                                                                                
MTRx :  6  observations tagged as outliers.                                                                                                               
MTRx :  After second round,  7  observations tagged as outliers (cumulative).                                                                             
MTRy :  1  observations tagged as outliers.                                                                                                               
MTRy :  After second round,  2  observations tagged as outliers (cumulative).                                                                             
Big S:  80                                                                                                                                                
max age, min age:  100 21                                                                                                                                 
/usr/local/google/home/talumbau/src/OG-USA/ogusa/macro_params.py:110: FutureWarning: The default fill_method='pad' in Series.pct_change is deprecated and 
will be removed in a future version. Either fill in any non-leading NA values prior to calling pct_change or specify 'fill_method=None' to not fill NA val
ues.                                                                                                                                                      
  fred_data_q["GDP Per Capita"].pct_change(periods=4, freq="QE").mean()                                                                                   
Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.                                                
qt.qpa.xcb: could not connect to display                                                                                                                  
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.                                                                
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.                   
                                                                                                                                                          
Available platform plugins are: eglfs, minimal, minimalegl, offscreen, vnc, webgl, xcb.                                                                   
                                                                                                                                                          
Aborted                                                   

I'm wondering if something has recently changed in OG-USA to, for example, bring in some matplotlib command automatically. Anything with automatic plot generation or drawing to a component that would need a GUI library like Qt. Is this familiar to you @jdebacker or @rickecon ?

Calibrate number of people age {0-17, 18-64, 65+} per tax unit by s,j

Implementing UBI directly in OG-USA (https://github.com/PSLmodels/OG-USA/issues/626) requires calibrating the number of people per tax unit by s,j, split for each of the age groups that could have different UBI amounts, currently 0-17, 18-64, and 65+. We'll want to calculate the value per s,j and then apply kernel density smoothing.

@prrathi and I calculated unsmoothed values using CPS tax units in this notebook. Next step is to do it with PSID instead.

Seems like we can use psid_data_setup.py for this. Our first try crashed Colab but @prrathi will try it again.

@jdebacker, is psid_lifetime_income.pkl, produced in that script, too big for GitHub?

Or will we have to hold onto the columns listed in #6 and aggregate them along the way anyway, requiring modification to psid_data_setup.py?

Deleted dependency detected

I'm a Cyber Security researcher and developer of PackjGuard [1] to address open-source software supply chain attacks.

Issue

During my research, I found that this repo is vulnerable to attack due to deleted dependency from the public PyPI registry.

Details

Specifically, file https://github.com/PSLmodels/OG-USA/blob/9da4947cacf412e4930d17365e5419bed5d17df6/setup.py lists xcalc as one of the dependencies. However, it has been deleted from public PyPI. As such, an external bad actor can claim that name and register a malicious package, which will be then installed with pip install command, resulting in arbitrary remote code execution.

Impact

Not only your apps/services using https://github.com/PSLmodels/OG-USA repo code are vulnerable to this attack, but the users of your open-source Github repo could also fall victim.

You could read more about such attacks here: https://medium.com/@alex.birsan/dependency-confusion-4a5d60fec610

Remediation

Please manually register a placeholder xcalc package on PyPI immediately or remove xcalc dependency from https://github.com/PSLmodels/OG-USA/blob/9da4947cacf412e4930d17365e5419bed5d17df6/setup.py to fix this vulnerability.

To automatically fix such issues in future, please install PackjGuard Github app [1].

Thanks!

  1. PackjGuard is a Github app that monitors your repos 24x7, detects vulnerable/malicious/risky open-source dependencies, and creates pull requests for auto remediation: https://github.com/marketplace/packjguard

Tax function estimation

Beginning with PR #73, which updated the default calibration of OG-USA, we have observed some odd results related to the estimated tax functions. This issue will document what we've noticed in the hopes that we can address any issues with the tax function estimation routines or with the microsimulation model used to calibrate OG-USA (or both).

Things that haven't seemed quite right:

  • In PR #73, I noted that using DEP tax functions estimated using the most recent Tax-Calculator at the time (v 3.4.1) resulted in tax function parameters that, when used in OG-USA, resulted in an inability for the model SS to solve.
  • Also, noted in PR #73, when trying to estimate the mono and mono2D functional form for the tax functions, there were failures in the estimation (e.g., no minimum found) (again, using Tax-Calculator 3.4.1)
  • In OG-USA simulations since October 2023, we've used GS functional forms for the tax functions (with these, the model solve), but we've noticed significant garbage collection and reductions in computational performance when solving the model (noted in OG-USA Discussions #83). Times to solve the model SS have gone up from about 45 seconds to 15 minutes. Note that when using the tax functions parameters in ogusa_default_parameters.json, the warnings and performance reductions pretty much disappear.

Add a JSON file with default parameters

This repo should contain a JSON file with the default parameters for OG-USA. This file should be updated periodically using the scripts in this repo (or other documented sources/methods).

Remaining Jupyter Book documentation warnings

Currently when I build the Jupyter Book documentation for OG-USA (v. 0.7.0), we get the following 18 warnings plus two repeating .mplstyle-type warnings. We need to fix these.

build succeeded, 18 warnings

Summary of warnings

  • 3 warnings: "jupyter_client.kernelspec.NoSuchKernel: No such kernel named ogusa-dev": demographics.md, exogenous_parameters.md, earnings.md
  • 4 warnings: "Definition list ends without a blank line; unexpected unindent." ogusa.calibrate.Calibration.read_tax_func_estimate:12, ogusa.demographics.get_mort:20, ogusa.demographics.get_pop_objs:30, ogusa.get_micro_data.get_data:29
  • 3 warnings: "Missing matching underline for section title overline." ogusa.demographics:1, ogusa.get_micro_data:1, ogusa.income:1
  • 1 warnings: "Unexpected indentation". ogusa.demographics.get_pop_objs:32
  • 1 warnings: "Block quote ends without a blank line; unexpected unindent." ogusa.demographics.get_pop_objs:33
  • 1 warnings: "toctree directive not expected with external-toc [etoc.toctree]". public_api.rst:11,
  • 2 warnings: "Document or section may net begin with a transition". UBI.md, contributor_guide.md
  • 3 warnings: "Couldn't find cache key for notebook file [file path and name]". demographics.md, earnings.md, exogenous_parameters.md

Terminal warning output

WARNING: /Users/richardevans/Documents/Economics/OSE/OG-USA/docs/book/content/calibration/demographics.md
Traceback (most recent call last):
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/jupyter_cache/executors/basic.py", line 141, in execute
    yield self.execute_single(
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/jupyter_cache/executors/basic.py", line 154, in execute_single
    result = single_nb_execution(
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 51, in single_nb_execution
    executenb(
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/nbclient/client.py", line 1117, in execute
    return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/nbclient/util.py", line 78, in wrapped
    return just_run(coro(*args, **kwargs))
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/nbclient/util.py", line 57, in just_run
    return loop.run_until_complete(coro)
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/nbclient/client.py", line 542, in async_execute
    async with self.async_setup_kernel(**kwargs):
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/contextlib.py", line 175, in __aenter__
    return await self.gen.__anext__()
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/nbclient/client.py", line 500, in async_setup_kernel
    await self.async_start_new_kernel(**kwargs)
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/nbclient/client.py", line 412, in async_start_new_kernel
    await ensure_async(self.km.start_kernel(extra_arguments=self.extra_arguments, **kwargs))
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/nbclient/util.py", line 89, in ensure_async
    result = await obj
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/jupyter_client/manager.py", line 331, in _async_start_kernel
    kernel_cmd, kw = await ensure_async(self.pre_start_kernel(**kw))
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/jupyter_client/utils.py", line 33, in ensure_async
    return await obj
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/jupyter_client/manager.py", line 295, in _async_pre_start_kernel
    self.kernel_spec,
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/jupyter_client/manager.py", line 131, in kernel_spec
    self._kernel_spec = self.kernel_spec_manager.get_kernel_spec(self.kernel_name)
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/jupyter_client/kernelspec.py", line 292, in get_kernel_spec
    raise NoSuchKernel(kernel_name)
jupyter_client.kernelspec.NoSuchKernel: No such kernel named ogusa-dev
WARNING: /Users/richardevans/Documents/Economics/OSE/OG-USA/docs/book/content/calibration/exogenous_parameters.md
Traceback (most recent call last):
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/jupyter_cache/executors/basic.py", line 141, in execute
    yield self.execute_single(
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/jupyter_cache/executors/basic.py", line 154, in execute_single
    result = single_nb_execution(
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 51, in single_nb_execution
    executenb(
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/nbclient/client.py", line 1117, in execute
    return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/nbclient/util.py", line 78, in wrapped
    return just_run(coro(*args, **kwargs))
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/nbclient/util.py", line 57, in just_run
    return loop.run_until_complete(coro)
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/nbclient/client.py", line 542, in async_execute
    async with self.async_setup_kernel(**kwargs):
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/contextlib.py", line 175, in __aenter__
    return await self.gen.__anext__()
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/nbclient/client.py", line 500, in async_setup_kernel
    await self.async_start_new_kernel(**kwargs)
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/nbclient/client.py", line 412, in async_start_new_kernel
    await ensure_async(self.km.start_kernel(extra_arguments=self.extra_arguments, **kwargs))
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/nbclient/util.py", line 89, in ensure_async
    result = await obj
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/jupyter_client/manager.py", line 331, in _async_start_kernel
    kernel_cmd, kw = await ensure_async(self.pre_start_kernel(**kw))
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/jupyter_client/utils.py", line 33, in ensure_async
    return await obj
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/jupyter_client/manager.py", line 295, in _async_pre_start_kernel
    self.kernel_spec,
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/jupyter_client/manager.py", line 131, in kernel_spec
    self._kernel_spec = self.kernel_spec_manager.get_kernel_spec(self.kernel_name)
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/jupyter_client/kernelspec.py", line 292, in get_kernel_spec
    raise NoSuchKernel(kernel_name)
jupyter_client.kernelspec.NoSuchKernel: No such kernel named ogusa-dev
WARNING: /Users/richardevans/Documents/Economics/OSE/OG-USA/docs/book/content/calibration/earnings.md
Traceback (most recent call last):
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/jupyter_cache/executors/basic.py", line 141, in execute
    yield self.execute_single(
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/jupyter_cache/executors/basic.py", line 154, in execute_single
    result = single_nb_execution(
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/jupyter_cache/executors/utils.py", line 51, in single_nb_execution
    executenb(
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/nbclient/client.py", line 1117, in execute
    return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/nbclient/util.py", line 78, in wrapped
    return just_run(coro(*args, **kwargs))
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/nbclient/util.py", line 57, in just_run
    return loop.run_until_complete(coro)
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/nbclient/client.py", line 542, in async_execute
    async with self.async_setup_kernel(**kwargs):
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/contextlib.py", line 175, in __aenter__
    return await self.gen.__anext__()
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/nbclient/client.py", line 500, in async_setup_kernel
    await self.async_start_new_kernel(**kwargs)
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/nbclient/client.py", line 412, in async_start_new_kernel
    await ensure_async(self.km.start_kernel(extra_arguments=self.extra_arguments, **kwargs))
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/nbclient/util.py", line 89, in ensure_async
    result = await obj
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/jupyter_client/manager.py", line 331, in _async_start_kernel
    kernel_cmd, kw = await ensure_async(self.pre_start_kernel(**kw))
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/jupyter_client/utils.py", line 33, in ensure_async
    return await obj
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/jupyter_client/manager.py", line 295, in _async_pre_start_kernel
    self.kernel_spec,
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/jupyter_client/manager.py", line 131, in kernel_spec
    self._kernel_spec = self.kernel_spec_manager.get_kernel_spec(self.kernel_name)
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/jupyter_client/kernelspec.py", line 292, in get_kernel_spec
    raise NoSuchKernel(kernel_name)
jupyter_client.kernelspec.NoSuchKernel: No such kernel named ogusa-dev
/Users/richardevans/Documents/Economics/OSE/OG-USA/ogusa/calibrate.py:docstring of ogusa.calibrate.Calibration.read_tax_func_estimate:12: WARNING: Definition list ends without a blank line; unexpected unindent.
/Users/richardevans/Documents/Economics/OSE/OG-USA/ogusa/demographics.py:docstring of ogusa.demographics:1: WARNING: Missing matching underline for section title overline.

------------------------------------------------------------------------
Functions for generating demographic objects necessary for the OG-USA
model
/Users/richardevans/Documents/Economics/OSE/OG-USA/ogusa/demographics.py:docstring of ogusa.demographics.get_mort:20: WARNING: Definition list ends without a blank line; unexpected unindent.
/Users/richardevans/Documents/Economics/OSE/OG-USA/ogusa/demographics.py:docstring of ogusa.demographics.get_pop_objs:30: WARNING: Definition list ends without a blank line; unexpected unindent.
/Users/richardevans/Documents/Economics/OSE/OG-USA/ogusa/demographics.py:docstring of ogusa.demographics.get_pop_objs:32: WARNING: Unexpected indentation.
/Users/richardevans/Documents/Economics/OSE/OG-USA/ogusa/demographics.py:docstring of ogusa.demographics.get_pop_objs:33: WARNING: Block quote ends without a blank line; unexpected unindent.
/Users/richardevans/Documents/Economics/OSE/OG-USA/ogusa/get_micro_data.py:docstring of ogusa.get_micro_data:1: WARNING: Missing matching underline for section title overline.

------------------------------------------------------------------------
This program extracts tax rate and income data from the microsimulation
model (Tax-Calculator).
/Users/richardevans/Documents/Economics/OSE/OG-USA/ogusa/get_micro_data.py:docstring of ogusa.get_micro_data.get_data:29: WARNING: Definition list ends without a blank line; unexpected unindent.
/Users/richardevans/Documents/Economics/OSE/OG-USA/ogusa/income.py:docstring of ogusa.income:1: WARNING: Missing matching underline for section title overline.

-----------------------------------------------------------------
Functions for created the matrix of ability levels, e.  This can
only be used for looking at the 25, 50, 70, 80, 90, 99, and 100th
/Users/richardevans/Documents/Economics/OSE/OG-USA/docs/book/content/api/public_api.rst:11: WARNING: toctree directive not expected with external-toc [etoc.toctree]
/Users/richardevans/Documents/Economics/OSE/OG-USA/docs/book/content/calibration/UBI.md:43: WARNING: Document or section may not begin with a transition.
WARNING: Couldn't find cache key for notebook file docs/book/content/calibration/demographics.md. Outputs will not be inserted.
WARNING: Couldn't find cache key for notebook file docs/book/content/calibration/earnings.md. Outputs will not be inserted.
WARNING: Couldn't find cache key for notebook file docs/book/content/calibration/exogenous_parameters.md. Outputs will not be inserted.
/Users/richardevans/Documents/Economics/OSE/OG-USA/docs/book/content/contributing/contributor_guide.md:0: WARNING: Document or section may not begin with a transition.

OGcorePlots.mplstyle matplotlibrc warnings
In addition, the compilation log output has many "Bad key" notes associated with the OGcorePlots.mplstyle file that have the following format. The main suggestion is "You probably need to get an updated matplotlibrc file from https://github.com/matplotlib/matplotlib/blob/v3.4.3/matplotlibrc.template or from the matplotlib source distribution."

Bad key <li><a data-ga-click="Footer, go to about, text in file https://github.com/PSLmodels/OG-Core/blob/master/ogcore/OGcorePlots.mplstyle, line 1384 ('        <li><a data-ga-click="Footer, go to about, text:about" href="https://github.com/about">About</a></li>')
You probably need to get an updated matplotlibrc file from
https://github.com/matplotlib/matplotlib/blob/v3.4.3/matplotlibrc.template
or from the matplotlib source distribution

The compilation log output also has many "Missing colon" notes also associated with the OGcorePlots.mplstyle file.

Missing colon in file 'https://github.com/PSLmodels/OG-Core/blob/master/ogcore/OGcorePlots.mplstyle', line 1371 ('    </ul>')

@jdebacker

Values of dataframe in psid_data_setup.py

The final dataframe panel_liof psid_data_setup.py seems to have issues with the values in its columns. Couple that I noticed while working with some (through the pickle file that the code stores) were:

  • many of the values in column num_children were null
  • the values in column spouse_age were 0

I suspect this is the case for several other columns as well. These columns also weren't manipulated in psid_data_setup.py, so @MaxGhenis suggested looking back at the psidR package.

Add Forbes 400 to SCF for calibrating initial wealth distribution (moved from OG-Core repo)

In OG-Core Issue #638, @MaxGhenis notes the following:

The SCF codebook states:

By design, the SCF sample excludes people who are included in the Forbes Magazine list of the 400 wealthiest people in the U.S. (see references in "SAMPLE DESIGN" above). However, there are several reasons why respondents with wealth at this level could appear in the sample anyway. In the 2010 survey, there were 10 observations that had net worth at least equal to the minimum level needed to qualify for the Forbes list. Because it would be very difficult to obscure sufficiently the identity of such people without rendering their data virtually useless, it was decided to remove them from the public version of the data set. Thus, the public version of the data set contains 6,482 of the 6,492 observations in the full data set.

From PWBM (2019):

PWBM’s wealth tax model uses data from the Survey of Consumer Finances (SCF), a high-quality survey of American households’ assets and liability holdings. The SCF oversamples high net worth households to ensure adequate detail on the top of the wealth distribution. The SCF is conducted every three years, so the most recently available survey is from 2016. The survey excludes the 400 richest Americans for confidentiality reasons, making it necessary to augment the survey with net worth data from the Forbes 400 in order to reflect total wealth in the economy.

CBO (2016) also added the Forbes 400 to the SCF, and several other academic studies do the same.

The 2019 Forbes list looks pretty easy to extract into a spreadsheet, and it also has each person's age.

Documentation: add use cases

OG-USA use cases aren't showing up in the docs at pslmodels.github.io/OG-USA

Uses cases in 2021 (e.g., TPC papers) should be added.

Can't access `calibrate` module from `ogusa` package installed via pip

In an fresh environment, I did:

pip install ogusa

Then:

(base) jason.debacker@JDEBACKER-7 Downloads % ipython
Python 3.7.16 (default, Jan 17 2023, 09:28:58)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.31.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import ogusa.calibrate as calib
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-4517818ef156> in <module>
----> 1 import ogusa.calibrate as calib

ModuleNotFoundError: No module named 'ogusa.calibrate'

Other modules seem to be accessible, but not calibrate.py.

The problem do not exist if one builds the package from source. Thus the error seems to be in the packages pushed to PyPI.

Calibration object cannot retrieve previous tax function estimates

@jdebacker. Because estimating tax functions by age (in the DEP case) takes about an hour, it is often nice to just do that once, save the TxFuncEst_policy.pkl file, and then just pass the path in to the Calibration object. In the old OG-USA API, we would use code like the following, where run_micro=False and the tax_func_path is passed in.

kwargs = {'output_base': base_dir, 'baseline_dir': base_dir,
            'test': False, 'time_path': True, 'baseline': True,
            'og_spec': og_spec_base, 'guid': '',
            'run_micro': False, 'tax_func_path': base_tax_func_path,
            'data': 'cps', 'client': client,
            'num_workers': num_workers}
runner(**kwargs)

In the new OG-USA API, the Calibration class in calibrate.py takes the boolean argument estimate_tax_functions instead of the old run_micro argument. The old run_micro argument is still used in the Calibration class sub method get_tax_function_parameters, but it can no longer be passed by calling the Calibration class. That is, there is no connection between the estimate_tax_functions argument of the Calibration class object and the run_micro argument of the get_tax_function_parameters method. As such, there is no way to instantiate a Calibration class object with estimated tax functions from a path without re-running the tax function estimation.

Code I have tried that does NOT successfully get the estimated tax function information from the TxFuncEst_policy.pkl path is the following. If I set estimate_tax_functions=True with the tax_func_path, it still reruns the tax function estimation.

c2 = Calibration(
    p2, iit_reform=iit_reform, estimate_tax_functions=False,
    tax_func_path=tax_func_path, client=client, guid='T040'
)

Windows GH Action tests not running

For the last three PR's (PR #73 #74 #75 #76), the Windows operating system tests in build_and_test.yml are not running on GitHub Actions. The Checkout, Setup Miniconda, and Build sections all run, but it stalls out at the test section. PR #76 temporarily removes the Windows tests from the build_and_test.yml GH Action. But we need to get those tests back in.

We should watch closely if the implementation of the OG-ZAF testing suite has the same issues. If not, we should look at the differences between OG-USA and OGZAF and OG-Core. In the latter two, the GH Actions on all three operating systems work. We suspect that the issue might be some dependencies in OG-USA that are not in those other two repositories.

cc: @jdebacker

Update default parameterization

The ogusa_default_parameters.py file should be updated to reflect the most recent calibration efforts for beta and e done by @rickecon and @jdebacker. Other parameters should also be updated to reflect those produced using the modules in this package (to the extent possible). Default year should be 2022.

Demographics plotting issues and documentation

Since updating the mortality rates rho object to allow for time varying mortality rates in PR #73, the plotting functions in demographics.py functions get_fert(), get_mort(), and get_imm_rates() have stopped working. This has caused the documentation to stop building because much of the executable code in the calibration: demographics section depends on those plotting functions. We need to fix those plotting functions.

cc: @jdebacker

Missing file: psid_lifetime_income.pkl

@jdebacker. I am running a reform in OG-USA that increases PIT marginal income tax rates in Tax-Calculator, estimates new tax functions, and runs the reform. My run gets through the estimation of tax functions, which is part of the Calibration class of the calibrate.py module. In the run of my reform, I call the Calibration class using the following code:

c2 = Calibration(
    p2, iit_reform=iit_reform, estimate_tax_functions=True, client=client
)

My run finishes the DEP tax function estimation on my reform, then I get the following error traceback.

Traceback (most recent call last):
  File "/Users/richardevans/Documents/Economics/OSE/OG-USA/./examples/run_ogusa_T040.py", line 125, in <module>
    main()
  File "/Users/richardevans/Documents/Economics/OSE/OG-USA/./examples/run_ogusa_T040.py", line 67, in main
    c2 = Calibration(
  File "/Users/richardevans/Documents/Economics/OSE/OG-USA/ogusa/calibrate.py", line 60, in __init__
    self.eta = transfer_distribution.get_transfer_matrix()
  File "/Users/richardevans/Documents/Economics/OSE/OG-USA/ogusa/transfer_distribution.py", line 100, in get_transfer_matrix
    df = ogcore.utils.safe_read_pickle(
  File "/Users/richardevans/opt/anaconda3/envs/ogusa-dev/lib/python3.9/site-packages/ogcore/utils.py", line 357, in safe_read_pickle
    with open(file_path, 'rb') as f:
FileNotFoundError: [Errno 2] No such file or directory: '/Users/richardevans/Documents/Economics/OSE/OG-USA/ogusa/data/PSID/psid_lifetime_income.pkl'

In fact, this file psid_lifetime_income.pkl does not exist in the ogcore/data/PSID/ folder. Let me know if you have this file and if we need to add this to the repo. Or do we just need to update the code in line 100 of transfer_distribution.py to point to the default eta object in ogusa_default_parameters.json?

Suppress plots

When running the calibration, many plots are created.

We should have a boolean argument that turns these off by default.

Can we have `ogusa_default_parameters.json` file available from `pip` install?

I'm wondering if there is any way to package ``ogusa_default_parameters.jsonwith the PyPI distribution and allow users of that package to access this JSON file directly from the package. e.g., something likeogusa.ogusa_default_parameters.json`

Is this possible?

In general, I want to best think through how users who don't want to clone the repo to bring down files locally can use the OG-USA default calibration from this package.

A possible solution is to have them install the package and then read the JSON file directly from the github URL. But wondering if there are other options.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.