Dolo is a Python package to describe and solve economic models. It provides a simple classification scheme to describe many types of models, lets you write models as simple text (YAML) files, and compiles these files into efficient Python objects representing them. It provides many reference solution algorithms to find the solution of these models under rational expectations: local perturbations up to third order, perfect foresight solutions, policy iteration, value iteration, and time iteration. Most algorithms are either parallelized or vectorized, and are written in pure Python, so they can easily be inspected or adapted.
Documentation: https://econforge.github.io/dolo.py/
Dolo is distributed as a conda package on the econforge channel on
prefix.dev. With pixi, in a new or existing project:
pixi init my-project && cd my-project # skip for an existing project
pixi workspace channel add --prepend https://prefix.dev/econforge
pixi add dolo--prepend gives the econforge channel priority over conda-forge, so you
get the latest Dolo release. Dolo can of course also be installed from PyPI
with pip install dolo.
Write a model in rbc.yaml:
name: Real Business Cycle
symbols:
exogenous: [e_z]
states: [z, k]
controls: [n, i]
parameters: [beta, sigma, eta, chi, delta, alpha, rho, zbar, sig_z]
definitions: |
y[t] = exp(z[t])*k[t]^alpha*n[t]^(1-alpha)
c[t] = y[t] - i[t]
equations:
arbitrage: |
chi*n[t]^eta*c[t]^sigma - w[t] ⟂ 0.0 <= n[t] <= inf
1 - beta*(c[t]/c[t+1])^(sigma)*(1-delta+rk[t+1]) ⟂ -inf <= i[t] <= infThen import it, solve it, and simulate:
from dolo import yaml_import, time_iteration, simulate
model = yaml_import("rbc.yaml")
dr = time_iteration(model)
sim = simulate(model, dr)
print(dr)Contributors work from a clone of this repository. The sections below describe the development setup.
pixi can be installed on a *nix system using the following command:
curl -fsSL https://pixi.sh/install.sh | shThe dev environment brings together the test, lint, docs, and release
features:
pixi install -e devTo run unit and coverage tests:
pixi run -e dev test
pixi run -e dev covTo format the code and check the types:
pixi run -e dev black
pixi run -e dev typecheckTo build and serve the documentation locally with zensical:
pixi run -e dev docsTo launch JupyterLab with the package installed in editable mode:
pixi run -e dev jlab