ogeth 0.0.8__tar.gz → 0.2.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.2.0/MANIFEST.in +3 -0
- ogeth-0.2.0/PKG-INFO +210 -0
- ogeth-0.2.0/README.md +153 -0
- ogeth-0.2.0/ogeth/__init__.py +11 -0
- {ogeth-0.0.8 → ogeth-0.2.0}/ogeth/calibrate.py +7 -4
- {ogeth-0.0.8 → ogeth-0.2.0}/ogeth/income.py +5 -15
- {ogeth-0.0.8 → ogeth-0.2.0}/ogeth/labor.py +1 -4
- {ogeth-0.0.8 → ogeth-0.2.0}/ogeth/macro_params.py +49 -131
- ogeth-0.2.0/ogeth/ogeth_default_parameters.json +874546 -0
- ogeth-0.2.0/ogeth/ogeth_multi_industry_parameters.json +9 -0
- {ogeth-0.0.8 → ogeth-0.2.0}/ogeth/utils.py +11 -4
- ogeth-0.2.0/ogeth.egg-info/PKG-INFO +210 -0
- {ogeth-0.0.8 → ogeth-0.2.0}/ogeth.egg-info/SOURCES.txt +1 -1
- ogeth-0.2.0/ogeth.egg-info/requires.txt +34 -0
- ogeth-0.2.0/pyproject.toml +119 -0
- {ogeth-0.0.8 → ogeth-0.2.0}/tests/test_calibrate.py +3 -4
- {ogeth-0.0.8 → ogeth-0.2.0}/tests/test_macro_params.py +4 -47
- ogeth-0.0.8/MANIFEST.in +0 -1
- ogeth-0.0.8/PKG-INFO +0 -125
- ogeth-0.0.8/README.md +0 -71
- ogeth-0.0.8/ogeth/__init__.py +0 -11
- ogeth-0.0.8/ogeth/ogeth_default_parameters.json +0 -103789
- ogeth-0.0.8/ogeth.egg-info/PKG-INFO +0 -125
- ogeth-0.0.8/ogeth.egg-info/requires.txt +0 -17
- ogeth-0.0.8/pyproject.toml +0 -15
- ogeth-0.0.8/setup.py +0 -61
- {ogeth-0.0.8 → ogeth-0.2.0}/LICENSE +0 -0
- {ogeth-0.0.8 → ogeth-0.2.0}/ogeth/constants.py +0 -0
- {ogeth-0.0.8 → ogeth-0.2.0}/ogeth/data/IFPRI_SAM_ETH_2022_SAM.csv +0 -0
- {ogeth-0.0.8 → ogeth-0.2.0}/ogeth/input_output.py +0 -0
- {ogeth-0.0.8 → ogeth-0.2.0}/ogeth/test_est_chi_n.py +0 -0
- {ogeth-0.0.8 → ogeth-0.2.0}/ogeth/update_baseline.py +0 -0
- {ogeth-0.0.8 → ogeth-0.2.0}/ogeth.egg-info/dependency_links.txt +0 -0
- {ogeth-0.0.8 → ogeth-0.2.0}/ogeth.egg-info/top_level.txt +0 -0
- {ogeth-0.0.8 → ogeth-0.2.0}/setup.cfg +0 -0
- {ogeth-0.0.8 → ogeth-0.2.0}/tests/test_import_smoke.py +0 -0
- {ogeth-0.0.8 → ogeth-0.2.0}/tests/test_input_output.py +0 -0
- {ogeth-0.0.8 → ogeth-0.2.0}/tests/test_run_example.py +0 -0
- {ogeth-0.0.8 → ogeth-0.2.0}/tests/test_update_baseline.py +0 -0
ogeth-0.2.0/MANIFEST.in
ADDED
ogeth-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ogeth
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Ethiopia Calibration for OG-Core
|
|
5
|
+
Author: Marcelo LaFleur, Richard W. Evans, and Jason DeBacker
|
|
6
|
+
License: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
|
|
7
|
+
Project-URL: Homepage, https://github.com/EAPD-DRB/OG-ETH/
|
|
8
|
+
Project-URL: Issue Tracker, https://github.com/EAPD-DRB/OG-ETH/issues
|
|
9
|
+
Keywords: ETH,Ethiopia,calibration,overlapping generations,fiscal policy
|
|
10
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Natural Language :: English
|
|
13
|
+
Classifier: License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
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.14,>=3.12
|
|
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: xlwt
|
|
34
|
+
Requires-Dist: openpyxl>=3.1.2
|
|
35
|
+
Requires-Dist: statsmodels
|
|
36
|
+
Requires-Dist: linearmodels
|
|
37
|
+
Requires-Dist: linecheck
|
|
38
|
+
Requires-Dist: ogcore>=0.14.11
|
|
39
|
+
Provides-Extra: dev
|
|
40
|
+
Requires-Dist: pytest>=6.0; extra == "dev"
|
|
41
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
42
|
+
Requires-Dist: pytest-xdist; extra == "dev"
|
|
43
|
+
Requires-Dist: coverage; extra == "dev"
|
|
44
|
+
Requires-Dist: ruff; extra == "dev"
|
|
45
|
+
Requires-Dist: ipython; extra == "dev"
|
|
46
|
+
Requires-Dist: ipykernel; extra == "dev"
|
|
47
|
+
Requires-Dist: jupyter; extra == "dev"
|
|
48
|
+
Provides-Extra: docs
|
|
49
|
+
Requires-Dist: jupyter-book<2.0,>=1.0; extra == "docs"
|
|
50
|
+
Requires-Dist: sphinx>=3.5.4; extra == "docs"
|
|
51
|
+
Requires-Dist: sphinx-book-theme>=0.1.3; extra == "docs"
|
|
52
|
+
Requires-Dist: sphinx-argparse; extra == "docs"
|
|
53
|
+
Requires-Dist: sphinx-exercise; extra == "docs"
|
|
54
|
+
Requires-Dist: sphinx-proof; extra == "docs"
|
|
55
|
+
Requires-Dist: sphinxcontrib-bibtex>=2.0.0; extra == "docs"
|
|
56
|
+
Dynamic: license-file
|
|
57
|
+
|
|
58
|
+
# OG-ETH
|
|
59
|
+
|
|
60
|
+
| | |
|
|
61
|
+
| --- | --- |
|
|
62
|
+
| Org | [](https://www.un.org/en/desa) [](https://www.PSLmodels.org) [](https://github.com/EAPD-DRB/OG-ETH/blob/main/LICENSE) [](https://eapd-drb.github.io/OG-ETH) |
|
|
63
|
+
| Package | [](https://www.python.org/downloads/release/python-3129/) [](https://www.python.org/downloads/release/python-3137/) [](https://pypi.org/project/ogeth/) [](https://pypi.org/project/ogeth/) [](https://github.com/astral-sh/ruff) |
|
|
64
|
+
| Testing |    [](https://codecov.io/gh/EAPD-DRB/OG-ETH) |
|
|
65
|
+
|
|
66
|
+
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.
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
## Using and contributing to OG-ETH
|
|
70
|
+
|
|
71
|
+
Install and run OG-ETH by cloning this GitHub repository and installing the `ogeth` package with its dependencies using [`uv`](https://docs.astral.sh/uv/), as detailed below. (Installing the `ogeth` package from [PyPI](https://pypi.org/project/ogeth/) with `pip` is no longer the recommended path: on the Python versions many machines ship, `pip` either refuses the current release outright — as on the Python 3.9 built into macOS — or silently pairs it with an older `ogcore` than the model is tested against, and even on a supported Python the PyPI route does not pin the `ogcore` version the repository is tested against. The `uv` workflow installs the exact tested versions of every dependency, including a compatible Python interpreter.)
|
|
72
|
+
|
|
73
|
+
### Installation
|
|
74
|
+
|
|
75
|
+
There are two ways to install OG-ETH: the easy way, using the OG model family's universal installer, and a manual install that runs the same steps one command at a time. Both start from a terminal, put the model in a new OG-ETH folder inside your current directory (a freshly opened terminal starts in your home folder), and need git.
|
|
76
|
+
|
|
77
|
+
#### Before you start: git
|
|
78
|
+
|
|
79
|
+
On a Mac where you have never used git before, run this line first and accept the dialog that appears:
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
xcode-select --install
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
On Windows, install Git first (skip this if you already have it):
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
winget install --id Git.Git -e --source winget
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
#### The easy way: the universal installer
|
|
92
|
+
|
|
93
|
+
The OG model family has a [universal installer](https://github.com/PSLmodels/OG-Core/blob/master/scripts/QUICK_INSTALL.md) that installs the uv tool, downloads the model, builds its environment, and verifies it — for OG-ETH or any of its sibling country models.
|
|
94
|
+
|
|
95
|
+
On macOS and Linux, paste:
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
curl -fsSL https://raw.githubusercontent.com/PSLmodels/OG-Core/master/scripts/install.sh -o og-install.sh
|
|
99
|
+
bash og-install.sh --repo og-eth --yes
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
On Windows (PowerShell), paste:
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
$f = "$env:TEMP\og-install.ps1"; irm https://raw.githubusercontent.com/PSLmodels/OG-Core/master/scripts/install.ps1 -OutFile $f; powershell -ExecutionPolicy Bypass -File $f -Repo og-eth -Yes
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
When the installer finishes, run the example. On macOS and Linux, paste:
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
source $HOME/.local/bin/env
|
|
112
|
+
cd OG-ETH
|
|
113
|
+
uv run python examples/run_og_eth.py
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
On Windows, open a new PowerShell window (so the just-installed tools are found) and paste:
|
|
117
|
+
|
|
118
|
+
```
|
|
119
|
+
cd OG-ETH
|
|
120
|
+
uv run python examples/run_og_eth.py
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
#### Manual install
|
|
124
|
+
|
|
125
|
+
The same setup as individual commands. On macOS and Linux, paste:
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
129
|
+
source $HOME/.local/bin/env
|
|
130
|
+
git clone https://github.com/EAPD-DRB/OG-ETH.git
|
|
131
|
+
cd OG-ETH
|
|
132
|
+
uv run python examples/run_og_eth.py
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
The second line makes the just-installed uv available in the current terminal; from your next terminal session it is available automatically.
|
|
136
|
+
|
|
137
|
+
On Windows (PowerShell), install uv:
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Then open a new PowerShell window (so the just-installed tools are found) and paste:
|
|
144
|
+
|
|
145
|
+
```
|
|
146
|
+
git clone https://github.com/EAPD-DRB/OG-ETH.git
|
|
147
|
+
cd OG-ETH
|
|
148
|
+
uv run python examples/run_og_eth.py
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
#### What happens
|
|
152
|
+
|
|
153
|
+
The first `uv run` creates the project environment if it does not exist yet — downloading a compatible Python interpreter if needed and installing the exact locked dependencies — and then runs the example. Early in the run you may be asked for a UN API token; just press return, and the model reads the same population data from a public mirror and continues. A full baseline-plus-reform run takes from 35 minutes to more than two hours; when it finishes, its plots and tables are saved under `./examples/OG-ETH-Example/` (see the list of outputs below).
|
|
154
|
+
|
|
155
|
+
### Installing for development or contributing
|
|
156
|
+
|
|
157
|
+
* Fork this repository and clone your fork to a directory on your computer.
|
|
158
|
+
* From the terminal, navigate to the cloned directory and run `uv sync --extra dev` to create a local `.venv` and install OG-ETH with its development dependencies (`uv` downloads a compatible Python if you don't already have one).
|
|
159
|
+
* For docs/Jupyter Book work, also run `uv sync --extra dev --extra docs`.
|
|
160
|
+
* Run commands in the environment with `uv run <command>`, or activate it first with `source .venv/bin/activate` (macOS/Linux) or `.\.venv\Scripts\Activate.ps1` (Windows).
|
|
161
|
+
|
|
162
|
+
### Run an example of the model
|
|
163
|
+
|
|
164
|
+
* From the repository root, run the model with an example reform: `uv run python examples/run_og_eth.py`.
|
|
165
|
+
* You can adjust the `./examples/run_og_eth.py` by modifying model parameters specified in the dictionary passed to the `p.update_specifications()` calls.
|
|
166
|
+
* Model outputs will be saved in the following files:
|
|
167
|
+
* `./examples/OG-ETH-Example/OG-ETH_example_plots`
|
|
168
|
+
* This folder will contain a number of plots generated from OG-Core to help you visualize the output from your run
|
|
169
|
+
* `./examples/OG-ETH-Example/OG-ETH_example_output.csv`
|
|
170
|
+
* This is a summary of the percentage changes in macro variables over the first ten years and in the steady-state.
|
|
171
|
+
* `./examples/OG-ETH-Example/OUTPUT_BASELINE/model_params.pkl`
|
|
172
|
+
* Model parameters used in the baseline run
|
|
173
|
+
* 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
|
|
174
|
+
* `./examples/OG-ETH-Example/OUTPUT_BASELINE/SS/SS_vars.pkl`
|
|
175
|
+
* Outputs from the model steady state solution under the baseline policy
|
|
176
|
+
* 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
|
|
177
|
+
* `./examples/OG-ETH-Example/OUTPUT_BASELINE/TPI/TPI_vars.pkl`
|
|
178
|
+
* Outputs from the model timepath solution under the baseline policy
|
|
179
|
+
* 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
|
|
180
|
+
* An analogous set of files in the `./examples/OG-ETH-Example/OUTPUT_REFORM` directory, which represent objects from the simulation of the reform policy
|
|
181
|
+
|
|
182
|
+
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.
|
|
183
|
+
|
|
184
|
+
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.
|
|
185
|
+
|
|
186
|
+
Once the package is installed, one can adjust parameters in the OG-Core `Specifications` object using the `Calibration` class as follows:
|
|
187
|
+
|
|
188
|
+
```
|
|
189
|
+
from ogcore.parameters import Specifications
|
|
190
|
+
from ogeth.calibrate import Calibration
|
|
191
|
+
p = Specifications()
|
|
192
|
+
c = Calibration(p)
|
|
193
|
+
updated_params = c.get_dict()
|
|
194
|
+
p.update_specifications({'initial_debt_ratio': updated_params['initial_debt_ratio']})
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## Disclaimer
|
|
198
|
+
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 `main` branch of this repo.
|
|
199
|
+
|
|
200
|
+
## Core Maintainers
|
|
201
|
+
|
|
202
|
+
The core maintainers of the OG-ETH repository are:
|
|
203
|
+
|
|
204
|
+
* Marcelo LaFleur (GitHub handle: [@SeaCelo](https://github.com/SeaCelo)), Senior Economist, Department of Economic and Social Affairs (DESA), United Nations
|
|
205
|
+
* [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.
|
|
206
|
+
* [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.
|
|
207
|
+
|
|
208
|
+
## Citing OG-ETH
|
|
209
|
+
|
|
210
|
+
OG-ETH (Version #.#.#)[Source code], https://github.com/EAPD-DRB/OG-ETH.
|
ogeth-0.2.0/README.md
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# OG-ETH
|
|
2
|
+
|
|
3
|
+
| | |
|
|
4
|
+
| --- | --- |
|
|
5
|
+
| Org | [](https://www.un.org/en/desa) [](https://www.PSLmodels.org) [](https://github.com/EAPD-DRB/OG-ETH/blob/main/LICENSE) [](https://eapd-drb.github.io/OG-ETH) |
|
|
6
|
+
| Package | [](https://www.python.org/downloads/release/python-3129/) [](https://www.python.org/downloads/release/python-3137/) [](https://pypi.org/project/ogeth/) [](https://pypi.org/project/ogeth/) [](https://github.com/astral-sh/ruff) |
|
|
7
|
+
| Testing |    [](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
|
+
Install and run OG-ETH by cloning this GitHub repository and installing the `ogeth` package with its dependencies using [`uv`](https://docs.astral.sh/uv/), as detailed below. (Installing the `ogeth` package from [PyPI](https://pypi.org/project/ogeth/) with `pip` is no longer the recommended path: on the Python versions many machines ship, `pip` either refuses the current release outright — as on the Python 3.9 built into macOS — or silently pairs it with an older `ogcore` than the model is tested against, and even on a supported Python the PyPI route does not pin the `ogcore` version the repository is tested against. The `uv` workflow installs the exact tested versions of every dependency, including a compatible Python interpreter.)
|
|
15
|
+
|
|
16
|
+
### Installation
|
|
17
|
+
|
|
18
|
+
There are two ways to install OG-ETH: the easy way, using the OG model family's universal installer, and a manual install that runs the same steps one command at a time. Both start from a terminal, put the model in a new OG-ETH folder inside your current directory (a freshly opened terminal starts in your home folder), and need git.
|
|
19
|
+
|
|
20
|
+
#### Before you start: git
|
|
21
|
+
|
|
22
|
+
On a Mac where you have never used git before, run this line first and accept the dialog that appears:
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
xcode-select --install
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
On Windows, install Git first (skip this if you already have it):
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
winget install --id Git.Git -e --source winget
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
#### The easy way: the universal installer
|
|
35
|
+
|
|
36
|
+
The OG model family has a [universal installer](https://github.com/PSLmodels/OG-Core/blob/master/scripts/QUICK_INSTALL.md) that installs the uv tool, downloads the model, builds its environment, and verifies it — for OG-ETH or any of its sibling country models.
|
|
37
|
+
|
|
38
|
+
On macOS and Linux, paste:
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
curl -fsSL https://raw.githubusercontent.com/PSLmodels/OG-Core/master/scripts/install.sh -o og-install.sh
|
|
42
|
+
bash og-install.sh --repo og-eth --yes
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
On Windows (PowerShell), paste:
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
$f = "$env:TEMP\og-install.ps1"; irm https://raw.githubusercontent.com/PSLmodels/OG-Core/master/scripts/install.ps1 -OutFile $f; powershell -ExecutionPolicy Bypass -File $f -Repo og-eth -Yes
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
When the installer finishes, run the example. On macOS and Linux, paste:
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
source $HOME/.local/bin/env
|
|
55
|
+
cd OG-ETH
|
|
56
|
+
uv run python examples/run_og_eth.py
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
On Windows, open a new PowerShell window (so the just-installed tools are found) and paste:
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
cd OG-ETH
|
|
63
|
+
uv run python examples/run_og_eth.py
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
#### Manual install
|
|
67
|
+
|
|
68
|
+
The same setup as individual commands. On macOS and Linux, paste:
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
72
|
+
source $HOME/.local/bin/env
|
|
73
|
+
git clone https://github.com/EAPD-DRB/OG-ETH.git
|
|
74
|
+
cd OG-ETH
|
|
75
|
+
uv run python examples/run_og_eth.py
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
The second line makes the just-installed uv available in the current terminal; from your next terminal session it is available automatically.
|
|
79
|
+
|
|
80
|
+
On Windows (PowerShell), install uv:
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Then open a new PowerShell window (so the just-installed tools are found) and paste:
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
git clone https://github.com/EAPD-DRB/OG-ETH.git
|
|
90
|
+
cd OG-ETH
|
|
91
|
+
uv run python examples/run_og_eth.py
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
#### What happens
|
|
95
|
+
|
|
96
|
+
The first `uv run` creates the project environment if it does not exist yet — downloading a compatible Python interpreter if needed and installing the exact locked dependencies — and then runs the example. Early in the run you may be asked for a UN API token; just press return, and the model reads the same population data from a public mirror and continues. A full baseline-plus-reform run takes from 35 minutes to more than two hours; when it finishes, its plots and tables are saved under `./examples/OG-ETH-Example/` (see the list of outputs below).
|
|
97
|
+
|
|
98
|
+
### Installing for development or contributing
|
|
99
|
+
|
|
100
|
+
* Fork this repository and clone your fork to a directory on your computer.
|
|
101
|
+
* From the terminal, navigate to the cloned directory and run `uv sync --extra dev` to create a local `.venv` and install OG-ETH with its development dependencies (`uv` downloads a compatible Python if you don't already have one).
|
|
102
|
+
* For docs/Jupyter Book work, also run `uv sync --extra dev --extra docs`.
|
|
103
|
+
* Run commands in the environment with `uv run <command>`, or activate it first with `source .venv/bin/activate` (macOS/Linux) or `.\.venv\Scripts\Activate.ps1` (Windows).
|
|
104
|
+
|
|
105
|
+
### Run an example of the model
|
|
106
|
+
|
|
107
|
+
* From the repository root, run the model with an example reform: `uv run python examples/run_og_eth.py`.
|
|
108
|
+
* You can adjust the `./examples/run_og_eth.py` by modifying model parameters specified in the dictionary passed to the `p.update_specifications()` calls.
|
|
109
|
+
* Model outputs will be saved in the following files:
|
|
110
|
+
* `./examples/OG-ETH-Example/OG-ETH_example_plots`
|
|
111
|
+
* This folder will contain a number of plots generated from OG-Core to help you visualize the output from your run
|
|
112
|
+
* `./examples/OG-ETH-Example/OG-ETH_example_output.csv`
|
|
113
|
+
* This is a summary of the percentage changes in macro variables over the first ten years and in the steady-state.
|
|
114
|
+
* `./examples/OG-ETH-Example/OUTPUT_BASELINE/model_params.pkl`
|
|
115
|
+
* Model parameters used in the baseline run
|
|
116
|
+
* 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
|
|
117
|
+
* `./examples/OG-ETH-Example/OUTPUT_BASELINE/SS/SS_vars.pkl`
|
|
118
|
+
* Outputs from the model steady state solution under the baseline policy
|
|
119
|
+
* 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
|
|
120
|
+
* `./examples/OG-ETH-Example/OUTPUT_BASELINE/TPI/TPI_vars.pkl`
|
|
121
|
+
* Outputs from the model timepath solution under the baseline policy
|
|
122
|
+
* 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
|
|
123
|
+
* An analogous set of files in the `./examples/OG-ETH-Example/OUTPUT_REFORM` directory, which represent objects from the simulation of the reform policy
|
|
124
|
+
|
|
125
|
+
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.
|
|
126
|
+
|
|
127
|
+
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.
|
|
128
|
+
|
|
129
|
+
Once the package is installed, one can adjust parameters in the OG-Core `Specifications` object using the `Calibration` class as follows:
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
from ogcore.parameters import Specifications
|
|
133
|
+
from ogeth.calibrate import Calibration
|
|
134
|
+
p = Specifications()
|
|
135
|
+
c = Calibration(p)
|
|
136
|
+
updated_params = c.get_dict()
|
|
137
|
+
p.update_specifications({'initial_debt_ratio': updated_params['initial_debt_ratio']})
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Disclaimer
|
|
141
|
+
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 `main` branch of this repo.
|
|
142
|
+
|
|
143
|
+
## Core Maintainers
|
|
144
|
+
|
|
145
|
+
The core maintainers of the OG-ETH repository are:
|
|
146
|
+
|
|
147
|
+
* Marcelo LaFleur (GitHub handle: [@SeaCelo](https://github.com/SeaCelo)), Senior Economist, Department of Economic and Social Affairs (DESA), United Nations
|
|
148
|
+
* [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.
|
|
149
|
+
* [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.
|
|
150
|
+
|
|
151
|
+
## Citing OG-ETH
|
|
152
|
+
|
|
153
|
+
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 * # noqa: F403
|
|
6
|
+
from ogeth.income import * # noqa: F403
|
|
7
|
+
from ogeth.input_output import * # noqa: F403
|
|
8
|
+
from ogeth.macro_params import * # noqa: F403
|
|
9
|
+
from ogeth.utils import * # noqa: F403
|
|
10
|
+
|
|
11
|
+
__version__ = "0.2.0"
|
|
@@ -16,7 +16,8 @@ class Calibration:
|
|
|
16
16
|
macro_data_end_year=datetime.datetime(2024, 12, 31),
|
|
17
17
|
demographic_data_path=None,
|
|
18
18
|
output_path=None,
|
|
19
|
-
|
|
19
|
+
# Set True to update from World Bank and UN APIs
|
|
20
|
+
update_from_api=False,
|
|
20
21
|
):
|
|
21
22
|
"""
|
|
22
23
|
Constructor for the Calibration class.
|
|
@@ -25,7 +26,7 @@ class Calibration:
|
|
|
25
26
|
p (OG-Core Specifications object): model parameters
|
|
26
27
|
demographic_data_path (str): path to save demographic data
|
|
27
28
|
output_path (str): path to save output to
|
|
28
|
-
update_from_api (bool): Set True
|
|
29
|
+
update_from_api (bool): Set True to pull updated macro data
|
|
29
30
|
from World Bank and UN APIs
|
|
30
31
|
|
|
31
32
|
Returns:
|
|
@@ -85,9 +86,10 @@ class Calibration:
|
|
|
85
86
|
p.T,
|
|
86
87
|
0,
|
|
87
88
|
99,
|
|
88
|
-
country_id="
|
|
89
|
+
country_id="231",
|
|
89
90
|
initial_data_year=p.start_year - 1,
|
|
90
91
|
final_data_year=p.start_year + 1,
|
|
92
|
+
income_percentiles=p.lambdas.flatten(),
|
|
91
93
|
GraphDiag=False,
|
|
92
94
|
download_path=demographic_data_path,
|
|
93
95
|
)
|
|
@@ -99,9 +101,10 @@ class Calibration:
|
|
|
99
101
|
p.T,
|
|
100
102
|
0,
|
|
101
103
|
99,
|
|
102
|
-
country_id="
|
|
104
|
+
country_id="231",
|
|
103
105
|
initial_data_year=p.start_year - 1,
|
|
104
106
|
final_data_year=p.start_year + 1,
|
|
107
|
+
income_percentiles=p.lambdas.flatten(),
|
|
105
108
|
GraphDiag=False,
|
|
106
109
|
)
|
|
107
110
|
|
|
@@ -116,14 +116,7 @@ def get_e_interp(
|
|
|
116
116
|
)
|
|
117
117
|
a = x.root
|
|
118
118
|
e_new = usa_params.e[0, :, :] * np.exp(a * usa_params.e[0, :, :])
|
|
119
|
-
emat_new_scaled = (
|
|
120
|
-
e_new
|
|
121
|
-
/ (
|
|
122
|
-
e_new
|
|
123
|
-
* usa_params.omega_SS.reshape(usa_params.S, 1)
|
|
124
|
-
* usa_params.lambdas.reshape(1, usa_params.J)
|
|
125
|
-
).sum()
|
|
126
|
-
)
|
|
119
|
+
emat_new_scaled = e_new / (e_new * usa_params.omega_SS).sum()
|
|
127
120
|
# Now interpolate for the cases where S and/or J not the same in the
|
|
128
121
|
# country parameterization as in the default USA parameterization
|
|
129
122
|
if (
|
|
@@ -156,8 +149,8 @@ def get_e_interp(
|
|
|
156
149
|
1 - usa_params.lambdas[-1]
|
|
157
150
|
):
|
|
158
151
|
err = (
|
|
159
|
-
"One or more entries in abilities vector (lambdas)
|
|
160
|
-
|
|
152
|
+
"One or more entries in abilities vector (lambdas) "
|
|
153
|
+
"is outside the allowable bounds for interpolation."
|
|
161
154
|
)
|
|
162
155
|
raise RuntimeError(err)
|
|
163
156
|
usa_step = 80 / usa_params.S
|
|
@@ -182,17 +175,14 @@ def get_e_interp(
|
|
|
182
175
|
(new_s_mesh, new_j_mesh),
|
|
183
176
|
method="linear",
|
|
184
177
|
)
|
|
185
|
-
emat_new_scaled = (
|
|
186
|
-
emat_new
|
|
187
|
-
/ (emat_new * age_wgts.reshape(S, 1) * lambdas.reshape(1, J)).sum()
|
|
188
|
-
)
|
|
178
|
+
emat_new_scaled = emat_new / (emat_new * age_wgts).sum()
|
|
189
179
|
|
|
190
180
|
if plot_path is not None:
|
|
191
181
|
kwargs = {"path": plot_path, "filesuffix": "_intrp_scaled"}
|
|
192
182
|
pp.plot_income_data(
|
|
193
183
|
new_s_midp,
|
|
194
184
|
abil_midp,
|
|
195
|
-
abil_wgts,
|
|
185
|
+
abil_wgts, # noqa: F821
|
|
196
186
|
emat_new_scaled,
|
|
197
187
|
plot_path,
|
|
198
188
|
**kwargs,
|
|
@@ -7,11 +7,8 @@ Computes the average labor participation rate for each age cohort.
|
|
|
7
7
|
import os
|
|
8
8
|
import numpy as np
|
|
9
9
|
import pandas as pd
|
|
10
|
-
import scipy.ndimage.filters as filter
|
|
11
10
|
from scipy import interpolate
|
|
12
|
-
import matplotlib
|
|
13
11
|
import matplotlib.pyplot as plt
|
|
14
|
-
from mpl_toolkits.mplot3d import Axes3D
|
|
15
12
|
|
|
16
13
|
CUR_DIR = os.path.abspath(os.path.dirname(__file__))
|
|
17
14
|
|
|
@@ -83,7 +80,7 @@ def compute_labor_moments(df, S=80):
|
|
|
83
80
|
)
|
|
84
81
|
# give column name to hours
|
|
85
82
|
by_age.columns = ["hours"]
|
|
86
|
-
# drop
|
|
83
|
+
# drop indices in ['00-04', '05-09', '10-14', '14-Oct', '9-May']
|
|
87
84
|
by_age = by_age.drop(["00-04", "05-09", "10-14", "14-Oct", "9-May"])
|
|
88
85
|
# also drop age 15-19 since not in model
|
|
89
86
|
# by_age = by_age.drop('15-19')
|