Skip to main content

Solve and estimate linearized DSGE models

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dsgepy-1.1.tar.gz (33.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dsgepy-1.1-py3-none-any.whl (33.0 kB view details)

Uploaded Python 3

File details

Details for the file dsgepy-1.1.tar.gz.

File metadata

  • Download URL: dsgepy-1.1.tar.gz
  • Upload date:
  • Size: 33.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for dsgepy-1.1.tar.gz
Algorithm Hash digest
SHA256 934aaf36657a701e20de1b353c2e97391c1f0dfc58527719dc962dadc71712f7
MD5 848531dfe7ef114bc2637bef87bb5335
BLAKE2b-256 dd8ff1de043dbd4595866f557b7ab69bf5f4ad520fe46739b6d690b86de79923

See more details on using hashes here.

Provenance

The following attestation bundles were made for dsgepy-1.1.tar.gz:

Publisher: publish.yml on gusamarante/dsgepy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dsgepy-1.1-py3-none-any.whl.

File metadata

  • Download URL: dsgepy-1.1-py3-none-any.whl
  • Upload date:
  • Size: 33.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for dsgepy-1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0e0de3509b514e1758e8af39a86a11b962bf02b5f5a48dff9b410fbe938576db
MD5 2f34e4b2cfe07823fd6bc7b89202eb1d
BLAKE2b-256 c6c4fba709cf8152ece6601566266daab4104a96fe60b9f03f0874c06d1e021f

See more details on using hashes here.

Provenance

The following attestation bundles were made for dsgepy-1.1-py3-none-any.whl:

Publisher: publish.yml on gusamarante/dsgepy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page