Skip to main content

dsgepy

This is a Python library to specify, calibrate, solve, simulate, estimate and analyze linearized DSGE models. The specification interface is inpired by dynare, which allows for symbolic declarations of parameters, variables and equations. Once a model is calbrated or estimated, it is solved using Sims (2002) methodology. Simulated trajectories can be generated from a calibrated model. Estimation uses bayesian methods, specifically markov chain monte carlo (MCMC), to simulate the posterior distributions of the parameters. Analysis tools include impulse-response functions, historical decompostion and extraction of latent variables.

This library is an effort to bring the DSGE toolset into the open-source world in a full python implementation, which allows to embrace the advantages of this programming language when working with DSGEs.


Installation

You can install this development version using:

pip install dsgepy

Example

A full example on how to use this library with a small New Keynesian model is available in this Jupyter notebook. The model used in the example is descibred briefly by the following equations:

$$\tilde{y}_{t}=E_{t}\left(\tilde{y}_{t+1}\right)-\frac{1}{\sigma}\left[\hat{i}_{t}-E_{t}\left(\pi_{t+1}\right)\right]+\psi_{ya}^{n}\left(\rho_{a}-1\right)a_{t}$$

$$\pi_{t}=\beta E_{t}\left(\pi_{t+1}\right)+\kappa\tilde{y}_{t}+\sigma_{\pi}\varepsilon_{t}^{\pi}$$

$$\hat{i}_{t}=\phi_{\pi}\pi_{t}+\phi_{y}\tilde{y}_{t}+v_{t}$$

$$a_{t}=\rho_{a}a_{t-1}+\sigma_{a}\varepsilon_{t}^{a}$$

$$v_{t}=\rho_{v}v_{t-1}+\sigma_{v}\varepsilon_{t}^{v}$$

Model Especification

For now, the model equations have to be linearized around its steady-state. Soon, there will be a functionality that allows for declaration with non-linearized equilibrium conditions.

Model Solution

The solution method used is based on the implementation of Christopher A. Sims' gensys function. You can find the author's original matlab code here. The paper explaining the solution method is this one.

Model Estimation

The models are estimated using Bayesian methdos, specifically, by simulating the posterior distribution using MCMC sampling. This process is slow, so there is a functionality that allows you to stop a simulation and continue it later from where it stoped.

Analysis

There are functionalities for computing Impulse-Response funcions for both state variables and observed variables. Historical decomposition is also available, but only when the number of exogenous shocks matches the number of observed variables.


Drawbacks

Since there is symbolic declaration of variables and equations, methdos involving them are slow. Also, MCMC methods for macroeconomic models require many iterations to achieve convergence. Clearly, there is room for improvement on the efficiency of these estimation algorithms. Contributions are welcome. Speaking of contributions...


Contributing

If you would like to contribute to this repository, plese check the contributing guidelines here. A list of feature suggestions is available on the projects page of this repository.


More Information and Help

If you need more information and help, specially about contributing, you can contact Gustavo Amarante on developer@dsgepy.com

Release files for dsgepy 1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dsgepy 1.1
File Size Uploaded
dsgepy-1.1.tar.gz 33.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dsgepy 1.1
File Interpreter ABI Platform
dsgepy-1.1-py3-none-any.whl Python 3 none any Details

Total release size:66.2 kB

Release files / dsgepy-1.1.tar.gz

Download URL dsgepy-1.1.tar.gz
Size 33.2 kB
Tags Source
SHA-256 checksum
How to use checksums
934aaf36657a701e20de1b353c2e97391c1f0dfc58527719dc962dadc71712f7
BLAKE2b-256 checksum
How to use checksums
dd8ff1de043dbd4595866f557b7ab69bf5f4ad520fe46739b6d690b86de79923
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 10, 2025.

Transparency log

Release files / dsgepy-1.1-py3-none-any.whl

Download URL dsgepy-1.1-py3-none-any.whl
Size 33.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0e0de3509b514e1758e8af39a86a11b962bf02b5f5a48dff9b410fbe938576db
BLAKE2b-256 checksum
How to use checksums
c6c4fba709cf8152ece6601566266daab4104a96fe60b9f03f0874c06d1e021f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 10, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

1.1 This release

2 release files

1.0

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page