ogeth 0.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
ogeth-0.0.0/LICENSE ADDED
@@ -0,0 +1,121 @@
1
+ Creative Commons Legal Code
2
+
3
+ CC0 1.0 Universal
4
+
5
+ CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
6
+ LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
7
+ ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
8
+ INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
9
+ REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
10
+ PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
11
+ THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
12
+ HEREUNDER.
13
+
14
+ Statement of Purpose
15
+
16
+ The laws of most jurisdictions throughout the world automatically confer
17
+ exclusive Copyright and Related Rights (defined below) upon the creator
18
+ and subsequent owner(s) (each and all, an "owner") of an original work of
19
+ authorship and/or a database (each, a "Work").
20
+
21
+ Certain owners wish to permanently relinquish those rights to a Work for
22
+ the purpose of contributing to a commons of creative, cultural and
23
+ scientific works ("Commons") that the public can reliably and without fear
24
+ of later claims of infringement build upon, modify, incorporate in other
25
+ works, reuse and redistribute as freely as possible in any form whatsoever
26
+ and for any purposes, including without limitation commercial purposes.
27
+ These owners may contribute to the Commons to promote the ideal of a free
28
+ culture and the further production of creative, cultural and scientific
29
+ works, or to gain reputation or greater distribution for their Work in
30
+ part through the use and efforts of others.
31
+
32
+ For these and/or other purposes and motivations, and without any
33
+ expectation of additional consideration or compensation, the person
34
+ associating CC0 with a Work (the "Affirmer"), to the extent that he or she
35
+ is an owner of Copyright and Related Rights in the Work, voluntarily
36
+ elects to apply CC0 to the Work and publicly distribute the Work under its
37
+ terms, with knowledge of his or her Copyright and Related Rights in the
38
+ Work and the meaning and intended legal effect of CC0 on those rights.
39
+
40
+ 1. Copyright and Related Rights. A Work made available under CC0 may be
41
+ protected by copyright and related or neighboring rights ("Copyright and
42
+ Related Rights"). Copyright and Related Rights include, but are not
43
+ limited to, the following:
44
+
45
+ i. the right to reproduce, adapt, distribute, perform, display,
46
+ communicate, and translate a Work;
47
+ ii. moral rights retained by the original author(s) and/or performer(s);
48
+ iii. publicity and privacy rights pertaining to a person's image or
49
+ likeness depicted in a Work;
50
+ iv. rights protecting against unfair competition in regards to a Work,
51
+ subject to the limitations in paragraph 4(a), below;
52
+ v. rights protecting the extraction, dissemination, use and reuse of data
53
+ in a Work;
54
+ vi. database rights (such as those arising under Directive 96/9/EC of the
55
+ European Parliament and of the Council of 11 March 1996 on the legal
56
+ protection of databases, and under any national implementation
57
+ thereof, including any amended or successor version of such
58
+ directive); and
59
+ vii. other similar, equivalent or corresponding rights throughout the
60
+ world based on applicable law or treaty, and any national
61
+ implementations thereof.
62
+
63
+ 2. Waiver. To the greatest extent permitted by, but not in contravention
64
+ of, applicable law, Affirmer hereby overtly, fully, permanently,
65
+ irrevocably and unconditionally waives, abandons, and surrenders all of
66
+ Affirmer's Copyright and Related Rights and associated claims and causes
67
+ of action, whether now known or unknown (including existing as well as
68
+ future claims and causes of action), in the Work (i) in all territories
69
+ worldwide, (ii) for the maximum duration provided by applicable law or
70
+ treaty (including future time extensions), (iii) in any current or future
71
+ medium and for any number of copies, and (iv) for any purpose whatsoever,
72
+ including without limitation commercial, advertising or promotional
73
+ purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
74
+ member of the public at large and to the detriment of Affirmer's heirs and
75
+ successors, fully intending that such Waiver shall not be subject to
76
+ revocation, rescission, cancellation, termination, or any other legal or
77
+ equitable action to disrupt the quiet enjoyment of the Work by the public
78
+ as contemplated by Affirmer's express Statement of Purpose.
79
+
80
+ 3. Public License Fallback. Should any part of the Waiver for any reason
81
+ be judged legally invalid or ineffective under applicable law, then the
82
+ Waiver shall be preserved to the maximum extent permitted taking into
83
+ account Affirmer's express Statement of Purpose. In addition, to the
84
+ extent the Waiver is so judged Affirmer hereby grants to each affected
85
+ person a royalty-free, non transferable, non sublicensable, non exclusive,
86
+ irrevocable and unconditional license to exercise Affirmer's Copyright and
87
+ Related Rights in the Work (i) in all territories worldwide, (ii) for the
88
+ maximum duration provided by applicable law or treaty (including future
89
+ time extensions), (iii) in any current or future medium and for any number
90
+ of copies, and (iv) for any purpose whatsoever, including without
91
+ limitation commercial, advertising or promotional purposes (the
92
+ "License"). The License shall be deemed effective as of the date CC0 was
93
+ applied by Affirmer to the Work. Should any part of the License for any
94
+ reason be judged legally invalid or ineffective under applicable law, such
95
+ partial invalidity or ineffectiveness shall not invalidate the remainder
96
+ of the License, and in such case Affirmer hereby affirms that he or she
97
+ will not (i) exercise any of his or her remaining Copyright and Related
98
+ Rights in the Work or (ii) assert any associated claims and causes of
99
+ action with respect to the Work, in either case contrary to Affirmer's
100
+ express Statement of Purpose.
101
+
102
+ 4. Limitations and Disclaimers.
103
+
104
+ a. No trademark or patent rights held by Affirmer are waived, abandoned,
105
+ surrendered, licensed or otherwise affected by this document.
106
+ b. Affirmer offers the Work as-is and makes no representations or
107
+ warranties of any kind concerning the Work, express, implied,
108
+ statutory or otherwise, including without limitation warranties of
109
+ title, merchantability, fitness for a particular purpose, non
110
+ infringement, or the absence of latent or other defects, accuracy, or
111
+ the present or absence of errors, whether or not discoverable, all to
112
+ the greatest extent permissible under applicable law.
113
+ c. Affirmer disclaims responsibility for clearing rights of other persons
114
+ that may apply to the Work or any use thereof, including without
115
+ limitation any person's Copyright and Related Rights in the Work.
116
+ Further, Affirmer disclaims responsibility for obtaining any necessary
117
+ consents, permissions or other rights required for any use of the
118
+ Work.
119
+ d. Affirmer understands and acknowledges that Creative Commons is not a
120
+ party to this document and has no duty or obligation with respect to
121
+ this CC0 or use of the Work.
@@ -0,0 +1 @@
1
+ include ogeth/ogeth_default_parameters.json
ogeth-0.0.0/PKG-INFO ADDED
@@ -0,0 +1,126 @@
1
+ Metadata-Version: 2.4
2
+ Name: ogeth
3
+ Version: 0.0.0
4
+ Summary: Ethiopia Calibration for OG-Core
5
+ Home-page: https://github.com/EAPD-DRB/OG-ETH/
6
+ Download-URL: https://github.com/EAPD-DRB/OG-ETH/
7
+ Author: Marcelo LaFleur, Richard W. Evans, and Jason DeBacker
8
+ License: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
9
+ Project-URL: Issue Tracker, https://github.com/EAPD-DRB/OG-ETH/issues
10
+ Keywords: ETH Ethiopia calibration of large scale overlapping generations model of fiscal policy
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Natural Language :: English
14
+ Classifier: License :: OSI Approved :: Common Public License
15
+ Classifier: Operating System :: POSIX
16
+ Classifier: Programming Language :: Python
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Requires-Python: >3.11, <3.14
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: numpy
25
+ Requires-Dist: psutil
26
+ Requires-Dist: scipy>=1.7.1
27
+ Requires-Dist: pandas>=1.2.5
28
+ Requires-Dist: matplotlib
29
+ Requires-Dist: dask>=2.30.0
30
+ Requires-Dist: distributed>=2.30.1
31
+ Requires-Dist: paramtools>=0.20.0
32
+ Requires-Dist: requests
33
+ Requires-Dist: pandas-datareader
34
+ Requires-Dist: xlwt
35
+ Requires-Dist: openpyxl>=3.1.2
36
+ Requires-Dist: statsmodels
37
+ Requires-Dist: linearmodels
38
+ Requires-Dist: wheel
39
+ Requires-Dist: black
40
+ Requires-Dist: linecheck
41
+ Requires-Dist: ogcore
42
+ Dynamic: author
43
+ Dynamic: classifier
44
+ Dynamic: description
45
+ Dynamic: description-content-type
46
+ Dynamic: download-url
47
+ Dynamic: home-page
48
+ Dynamic: keywords
49
+ Dynamic: license
50
+ Dynamic: license-file
51
+ Dynamic: project-url
52
+ Dynamic: requires-dist
53
+ Dynamic: requires-python
54
+ Dynamic: summary
55
+
56
+ # OG-ETH
57
+
58
+ | | |
59
+ | --- | --- |
60
+ | Org | [![United Nations DESA](https://img.shields.io/badge/United%20Nations%20DESA-blue)](https://www.un.org/en/desa) [![PSL cataloged](https://img.shields.io/badge/PSL-cataloged-a0a0a0.svg)](https://www.PSLmodels.org) [![OS License: CC0-1.0](https://img.shields.io/badge/OS%20License-CC0%201.0-yellow)](https://github.com/EAPD-DRB/OG-ETH/blob/main/LICENSE) [![Jupyter Book Badge](https://raw.githubusercontent.com/jupyter-book/jupyter-book/next/docs/media/images/badge.svg)](https://eapd-drb.github.io/OG-ETH) |
61
+ | Package | [![Python 3.12](https://img.shields.io/badge/python-3.12-blue.svg)](https://www.python.org/downloads/release/python-3129/) [![Python 3.13](https://img.shields.io/badge/python-3.13-blue.svg)](https://www.python.org/downloads/release/python-3137/) [![PyPI Latest Release](https://img.shields.io/pypi/v/ogeth.svg)](https://pypi.org/project/ogeth/) [![PyPI Downloads](https://img.shields.io/pypi/dm/ogeth.svg?label=PyPI%20downloads)](https://pypi.org/project/ogeth/) |
62
+ | Testing | ![example event parameter](https://github.com/EAPD-DRB/OG-ETH/actions/workflows/build_and_test.yml/badge.svg?branch=main) ![example event parameter](https://github.com/EAPD-DRB/OG-ETH/actions/workflows/deploy_docs.yml/badge.svg?branch=main) ![example event parameter](https://github.com/EAPD-DRB/OG-ETH/actions/workflows/check_format.yml/badge.svg?branch=main) [![Codecov](https://codecov.io/gh/EAPD-DRB/OG-ETH/branch/main/graph/badge.svg)](https://codecov.io/gh/EAPD-DRB/OG-ETH) |
63
+
64
+ OG-ETH is an overlapping-generations (OG) model that allows for dynamic general equilibrium analysis of fiscal policy for Ethiopia. OG-ETH 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 Ethiopian calibration of the model is available at https://eapd-drb.github.io/OG-ETH.
65
+
66
+
67
+ ## Using and contributing to OG-ETH
68
+
69
+ * If you are installing on a Mac computer, install XCode Tools. In Terminal: `xcode-select —install`
70
+ * Download and install the appropriate [Anaconda distribution](https://www.anaconda.com/products/distribution#Downloads) of Python. Select the correct version for you platform (Windows, Intel Mac, or M1 Mac).
71
+ * In Terminal:
72
+ * Make sure the `conda` package manager is up-to-date: `conda update conda`.
73
+ * Make sure the Anaconda distribution of Python is up-to-date: `conda update anaconda`.
74
+ * Fork this repository and clone your fork of this repository to a directory on your computer.
75
+ * From the terminal (or Anaconda 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 `ogeth-dev` conda environment should not take more than five minutes.
76
+ * Then, `conda activate ogeth-dev`
77
+ * Then install by `pip install -e .`
78
+ ### Run an example of the model
79
+ * Navigate to `./examples`
80
+ * Run the model with an example reform from terminal/command prompt by typing `python run_og_eth.py`
81
+ * You can adjust the `./examples/run_og_eth.py` by modifying model parameters specified in the dictionary passed to the `p.update_specifications()` calls.
82
+ * Model outputs will be saved in the following files:
83
+ * `./examples/OG-ETH_example_plots`
84
+ * This folder will contain a number of plots generated from OG-Core to help you visualize the output from your run
85
+ * `./examples/ogeth_example_output.csv`
86
+ * This is a summary of the percentage changes in macro variables over the first ten years and in the steady-state.
87
+ * `./examples/OG-ETH-Example/OUTPUT_BASELINE/model_params.pkl`
88
+ * Model parameters used in the baseline run
89
+ * See [`ogcore.execute.py`](https://github.com/PSLmodels/OG-Core/blob/master/ogcore/execute.py) for items in the dictionary object in this pickle file
90
+ * `./examples/OG-ETH-Example/OUTPUT_BASELINE/SS/SS_vars.pkl`
91
+ * Outputs from the model steady state solution under the baseline policy
92
+ * See [`ogcore.SS.py`](https://github.com/PSLmodels/OG-Core/blob/master/ogcore/SS.py) for what is in the dictionary object in this pickle file
93
+ * `./examples/OG-ETH-Example/OUTPUT_BASELINE/TPI/TPI_vars.pkl`
94
+ * Outputs from the model timepath solution under the baseline policy
95
+ * See [`ogcore.TPI.py`](https://github.com/PSLmodels/OG-Core/blob/master/ogcore/TPI.py) for what is in the dictionary object in this pickle file
96
+ * An analogous set of files in the `./examples/OUTPUT_REFORM` directory, which represent objects from the simulation of the reform policy
97
+
98
+ 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 from 35 minutes to more than two hours of compute time.
99
+
100
+ If you run into errors running the example script, please open a new issue in the OG-ETH repo with a description of the issue and any relevant tracebacks you receive.
101
+
102
+ Once the package is installed, one can adjust parameters in the OG-Core `Specifications` object using the `Calibration` class as follows:
103
+
104
+ ```
105
+ from ogcore.parameters import Specifications
106
+ from ogeth.calibrate import Calibration
107
+ p = Specifications()
108
+ c = Calibration(p)
109
+ updated_params = c.get_dict()
110
+ p.update_specifications({'initial_debt_ratio': updated_params['initial_debt_ratio']})
111
+ ```
112
+
113
+ ## Disclaimer
114
+ The organization of this repository will be changing rapidly, but the `OG-ETH/examples/run_og_eth.py` script will be kept up to date to run with the master branch of this repo.
115
+
116
+ ## Core Maintainers
117
+
118
+ The core maintainers of the OG-ETH repository are:
119
+
120
+ * Marcelo LaFleur (GitHub handle: [@SeaCelo](https://github.com/SeaCelo)), Senior Economist, Department of Economic and Social Affairs (DESA), United Nations
121
+ * [Richard W. Evans](https://sites.google.com/site/rickecon/) (GitHub handle: [@rickecon](https://github.com/rickecon)), Senior Economist, Abundance Institute; President, Open Research Group, Inc.
122
+ * [Jason DeBacker](https://jasondebacker.com) (GitHub handle: [@jdebacker](https://github.com/jdebacker)), Associate Professor, University of South Carolina; Vice President of Research, Open Research Group, Inc.
123
+
124
+ ## Citing OG-ETH
125
+
126
+ OG-ETH (Version #.#.#)[Source code], https://github.com/EAPD-DRB/OG-ETH.
ogeth-0.0.0/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # OG-ETH
2
+
3
+ | | |
4
+ | --- | --- |
5
+ | Org | [![United Nations DESA](https://img.shields.io/badge/United%20Nations%20DESA-blue)](https://www.un.org/en/desa) [![PSL cataloged](https://img.shields.io/badge/PSL-cataloged-a0a0a0.svg)](https://www.PSLmodels.org) [![OS License: CC0-1.0](https://img.shields.io/badge/OS%20License-CC0%201.0-yellow)](https://github.com/EAPD-DRB/OG-ETH/blob/main/LICENSE) [![Jupyter Book Badge](https://raw.githubusercontent.com/jupyter-book/jupyter-book/next/docs/media/images/badge.svg)](https://eapd-drb.github.io/OG-ETH) |
6
+ | Package | [![Python 3.12](https://img.shields.io/badge/python-3.12-blue.svg)](https://www.python.org/downloads/release/python-3129/) [![Python 3.13](https://img.shields.io/badge/python-3.13-blue.svg)](https://www.python.org/downloads/release/python-3137/) [![PyPI Latest Release](https://img.shields.io/pypi/v/ogeth.svg)](https://pypi.org/project/ogeth/) [![PyPI Downloads](https://img.shields.io/pypi/dm/ogeth.svg?label=PyPI%20downloads)](https://pypi.org/project/ogeth/) |
7
+ | Testing | ![example event parameter](https://github.com/EAPD-DRB/OG-ETH/actions/workflows/build_and_test.yml/badge.svg?branch=main) ![example event parameter](https://github.com/EAPD-DRB/OG-ETH/actions/workflows/deploy_docs.yml/badge.svg?branch=main) ![example event parameter](https://github.com/EAPD-DRB/OG-ETH/actions/workflows/check_format.yml/badge.svg?branch=main) [![Codecov](https://codecov.io/gh/EAPD-DRB/OG-ETH/branch/main/graph/badge.svg)](https://codecov.io/gh/EAPD-DRB/OG-ETH) |
8
+
9
+ OG-ETH is an overlapping-generations (OG) model that allows for dynamic general equilibrium analysis of fiscal policy for Ethiopia. OG-ETH 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 Ethiopian calibration of the model is available at https://eapd-drb.github.io/OG-ETH.
10
+
11
+
12
+ ## Using and contributing to OG-ETH
13
+
14
+ * If you are installing on a Mac computer, install XCode Tools. In Terminal: `xcode-select —install`
15
+ * Download and install the appropriate [Anaconda distribution](https://www.anaconda.com/products/distribution#Downloads) of Python. Select the correct version for you platform (Windows, Intel Mac, or M1 Mac).
16
+ * In Terminal:
17
+ * Make sure the `conda` package manager is up-to-date: `conda update conda`.
18
+ * Make sure the Anaconda distribution of Python is up-to-date: `conda update anaconda`.
19
+ * Fork this repository and clone your fork of this repository to a directory on your computer.
20
+ * From the terminal (or Anaconda 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 `ogeth-dev` conda environment should not take more than five minutes.
21
+ * Then, `conda activate ogeth-dev`
22
+ * Then install by `pip install -e .`
23
+ ### Run an example of the model
24
+ * Navigate to `./examples`
25
+ * Run the model with an example reform from terminal/command prompt by typing `python run_og_eth.py`
26
+ * You can adjust the `./examples/run_og_eth.py` by modifying model parameters specified in the dictionary passed to the `p.update_specifications()` calls.
27
+ * Model outputs will be saved in the following files:
28
+ * `./examples/OG-ETH_example_plots`
29
+ * This folder will contain a number of plots generated from OG-Core to help you visualize the output from your run
30
+ * `./examples/ogeth_example_output.csv`
31
+ * This is a summary of the percentage changes in macro variables over the first ten years and in the steady-state.
32
+ * `./examples/OG-ETH-Example/OUTPUT_BASELINE/model_params.pkl`
33
+ * Model parameters used in the baseline run
34
+ * See [`ogcore.execute.py`](https://github.com/PSLmodels/OG-Core/blob/master/ogcore/execute.py) for items in the dictionary object in this pickle file
35
+ * `./examples/OG-ETH-Example/OUTPUT_BASELINE/SS/SS_vars.pkl`
36
+ * Outputs from the model steady state solution under the baseline policy
37
+ * See [`ogcore.SS.py`](https://github.com/PSLmodels/OG-Core/blob/master/ogcore/SS.py) for what is in the dictionary object in this pickle file
38
+ * `./examples/OG-ETH-Example/OUTPUT_BASELINE/TPI/TPI_vars.pkl`
39
+ * Outputs from the model timepath solution under the baseline policy
40
+ * See [`ogcore.TPI.py`](https://github.com/PSLmodels/OG-Core/blob/master/ogcore/TPI.py) for what is in the dictionary object in this pickle file
41
+ * An analogous set of files in the `./examples/OUTPUT_REFORM` directory, which represent objects from the simulation of the reform policy
42
+
43
+ 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 from 35 minutes to more than two hours of compute time.
44
+
45
+ If you run into errors running the example script, please open a new issue in the OG-ETH repo with a description of the issue and any relevant tracebacks you receive.
46
+
47
+ Once the package is installed, one can adjust parameters in the OG-Core `Specifications` object using the `Calibration` class as follows:
48
+
49
+ ```
50
+ from ogcore.parameters import Specifications
51
+ from ogeth.calibrate import Calibration
52
+ p = Specifications()
53
+ c = Calibration(p)
54
+ updated_params = c.get_dict()
55
+ p.update_specifications({'initial_debt_ratio': updated_params['initial_debt_ratio']})
56
+ ```
57
+
58
+ ## Disclaimer
59
+ The organization of this repository will be changing rapidly, but the `OG-ETH/examples/run_og_eth.py` script will be kept up to date to run with the master branch of this repo.
60
+
61
+ ## Core Maintainers
62
+
63
+ The core maintainers of the OG-ETH repository are:
64
+
65
+ * Marcelo LaFleur (GitHub handle: [@SeaCelo](https://github.com/SeaCelo)), Senior Economist, Department of Economic and Social Affairs (DESA), United Nations
66
+ * [Richard W. Evans](https://sites.google.com/site/rickecon/) (GitHub handle: [@rickecon](https://github.com/rickecon)), Senior Economist, Abundance Institute; President, Open Research Group, Inc.
67
+ * [Jason DeBacker](https://jasondebacker.com) (GitHub handle: [@jdebacker](https://github.com/jdebacker)), Associate Professor, University of South Carolina; Vice President of Research, Open Research Group, Inc.
68
+
69
+ ## Citing OG-ETH
70
+
71
+ OG-ETH (Version #.#.#)[Source code], https://github.com/EAPD-DRB/OG-ETH.
@@ -0,0 +1,11 @@
1
+ """
2
+ Specify what is available to import from the ogeth package.
3
+ """
4
+
5
+ from ogeth.calibrate import *
6
+ from ogeth.income import *
7
+ from ogeth.input_output import *
8
+ from ogeth.macro_params import *
9
+ from ogeth.utils import *
10
+
11
+ __version__ = "0.0.0"
@@ -0,0 +1,108 @@
1
+ from ogeth import macro_params, income
2
+ from ogeth import input_output as io
3
+ import os
4
+ import numpy as np
5
+ import datetime
6
+ from ogcore import demographics
7
+
8
+
9
+ class Calibration:
10
+ """OG-ETH calibration class"""
11
+
12
+ def __init__(
13
+ self,
14
+ p,
15
+ macro_data_start_year=datetime.datetime(1947, 1, 1),
16
+ macro_data_end_year=datetime.datetime(2024, 12, 31),
17
+ demographic_data_path=None,
18
+ output_path=None,
19
+ update_from_api=False, # Set True to update from World Bank and UN APIs
20
+ ):
21
+ """
22
+ Constructor for the Calibration class.
23
+
24
+ Args:
25
+ p (OG-Core Specifications object): model parameters
26
+ demographic_data_path (str): path to save demographic data
27
+ output_path (str): path to save output to
28
+ update_from_api (bool): Set True if you want to pull updated macro data
29
+ from World Bank and UN APIs
30
+
31
+ Returns:
32
+ None
33
+
34
+ """
35
+ # Create output_path if it doesn't exist
36
+ if output_path is not None:
37
+ if not os.path.exists(output_path):
38
+ os.makedirs(output_path)
39
+
40
+ # Macro estimation
41
+ self.macro_params = macro_params.get_macro_params(
42
+ macro_data_start_year,
43
+ macro_data_end_year,
44
+ update_from_api=update_from_api,
45
+ )
46
+
47
+ # io matrix and alpha_c
48
+ if p.I > 1: # no need if just one consumption good
49
+ alpha_c_dict = io.get_alpha_c()
50
+ # check that model dimensions are consistent with alpha_c
51
+ assert p.I == len(list(alpha_c_dict.keys()))
52
+ self.alpha_c = np.array(list(alpha_c_dict.values()))
53
+ else:
54
+ self.alpha_c = np.array([1.0])
55
+ if p.M > 1: # no need if just one production good
56
+ io_df = io.get_io_matrix()
57
+ # check that model dimensions are consistent with io_matrix
58
+ assert p.M == len(list(io_df.keys()))
59
+ self.io_matrix = io_df.values
60
+ else:
61
+ self.io_matrix = np.array([[1.0]])
62
+
63
+ # demographics
64
+ self.demographic_params = demographics.get_pop_objs(
65
+ p.E,
66
+ p.S,
67
+ p.T,
68
+ 0,
69
+ 99,
70
+ country_id="710",
71
+ initial_data_year=p.start_year - 1,
72
+ final_data_year=p.start_year + 1,
73
+ GraphDiag=False,
74
+ download_path=demographic_data_path,
75
+ )
76
+
77
+ # demographics for 80 period lives (needed for getting e below)
78
+ demog80 = demographics.get_pop_objs(
79
+ 20,
80
+ 80,
81
+ p.T,
82
+ 0,
83
+ 99,
84
+ country_id="710",
85
+ initial_data_year=p.start_year - 1,
86
+ final_data_year=p.start_year + 1,
87
+ GraphDiag=False,
88
+ )
89
+
90
+ # earnings profiles
91
+ self.e = income.get_e_interp(
92
+ p.S,
93
+ self.demographic_params["omega_SS"],
94
+ demog80["omega_SS"],
95
+ p.lambdas,
96
+ plot_path=output_path,
97
+ )
98
+
99
+ # method to return all newly calibrated parameters in a dictionary
100
+ def get_dict(self):
101
+ dict = {}
102
+ dict.update(self.macro_params)
103
+ dict["e"] = self.e
104
+ dict["alpha_c"] = self.alpha_c
105
+ dict["io_matrix"] = self.io_matrix
106
+ dict.update(self.demographic_params)
107
+
108
+ return dict