Giter Club home page Giter Club logo

pydsge's Introduction

pydsge

badge0 badge1


A package for solving, filtering and estimating linear DSGE models with the ZLB (or other occasionally binding constraints).

The set of methods is introduced in the paper Estimation of DSGE Models with the Effective Lower Bound (Gregor Boehl & Felix Strobel, 2023, JEDC), where we also estimate the medium-scale New Keynesian model to post-2008 US data.

Check out my Econpizza package if you are interested in simulating nonlinear DSGE models with (or without) heterogeneous agents.

A collection of models that can be (and were) used with this package can be found in another repo.

Installation

Installing the stable version is as simple as typing

pip install pydsge

in your terminal (Linux/MacOS) or Anaconda Prompt (Win).

Documentation

Documentation can be found on ReadTheDocs:

Citation

pydsge is developed by Gregor Boehl to simulate, filter, and estimate DSGE models with the zero lower bound on nominal interest rates in various applications (see my website for research papers using the package). Please cite it with

@TechReport{boehl2022meth,
  title = {{Estimation of DSGE Models with the Effective Lower Bound}},
  author = {Boehl, Gregor and Strobel, Felix},
  journal = {Journal of Economic Dynamics and Control},
  volume = {158},
  year = {2022},
  publisher = {Elsevier}
}
@techreport{boehl2022obc,
  title = Efficient solution and computation of models with occasionally binding constraints},
  author = {Boehl, Gregor},
  journal = {Journal of Economic Dynamics and Control},
  volume = {143},
  year = {2022},
  publisher = {Elsevier}
}

We appreciate citations for pydsge because it helps us to find out how people have been using the package and it motivates further work.

Parser

The parser originally was a fork of Ed Herbst's fork from Pablo Winant's (excellent) package dolo.

See https://github.com/EconForge/dolo and https://github.com/eph.

References

Boehl, Gregor (2022). Efficient Solution and Computation of Models with Occasionally Binding Constraints. Journal of Economic Dynamics and Control

pydsge's People

Contributors

florabudianto avatar gboehl avatar github-actions[bot] avatar husaiyin avatar pcschreiber1 avatar yuxinwang2020 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pydsge's Issues

DSGE Not Opening .npz file

I was following the documentation and under processing estimation results, the following line failed with the error below:
mod = DSGE.load(meta_data)


ValueError Traceback (most recent call last)
in
----> 1 mod = DSGE.load(meta_data)

~/opt/anaconda3/lib/python3.8/site-packages/pydsge/parser.py in load(cls, npzfile, force_parse, verbose)
485 st = time.time()
486
--> 487 fdict = dict(np.load(npzfile, allow_pickle=True))
488
489 mtxt = str(fdict["yaml_raw"])

~/opt/anaconda3/lib/python3.8/site-packages/numpy/lib/npyio.py in getitem(self, key)
241 if magic == format.MAGIC_PREFIX:
242 bytes = self.zip.open(key)
--> 243 return format.read_array(bytes,
244 allow_pickle=self.allow_pickle,
245 pickle_kwargs=self.pickle_kwargs)

~/opt/anaconda3/lib/python3.8/site-packages/numpy/lib/format.py in read_array(fp, allow_pickle, pickle_kwargs)
745 pickle_kwargs = {}
746 try:
--> 747 array = pickle.load(fp, **pickle_kwargs)
748 except UnicodeError as err:
749 # Friendlier error message

~/opt/anaconda3/lib/python3.8/site-packages/scipy/stats/_distn_infrastructure.py in setstate(self, state)
623
624 def setstate(self, state):
--> 625 ctor_param, r = state
626 self.init(**ctor_param)
627 self._random_state = r

ValueError: too many values to unpack (expected 2)

I am running numpy 1.22.4 and Python 3.8.

Forecasting

Hi Gregor, many thanks for an amazing package and all the great work!

Is there a way to use the models we estimate for out-of-sample forecasting (maybe some of the underlying filtering packages support that)? I haven't been able to figure anything out.

`from pydsge import *` generates an error

from pydsge import * generates the following error:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Input In [15], in <cell line: 1>()
----> 1 from pydsge import *

File ~/opt/anaconda3/envs/test/lib/python3.10/site-packages/pydsge/__init__.py:4, in <module>
      1 #!/bin/python
      2 # -*- coding: utf-8 -*-
----> 4 import logging
      5 import os
      6 import numpy as np

ImportError: cannot import name 'sort_nhd' from 'pydsge.stats' (/Users/.../opt/anaconda3/envs/test/lib/python3.10/site-packages/pydsge/stats.py)

I installed pydsge by running

pip install git+https://github.com/gboehl/grgrlib
pip install git+https://github.com/gboehl/econsieve
pip install git+https://github.com/gboehl/emcwrap
pip install git+https://github.com/gboehl/pydsge

Solving models and steady state

Hi, as a Python fan and econ grad student I'd like to use this package to do everything that one would do in matlab.

I see that in the getting started example file (dfi.yaml) there is no part where one sets the steady state. I'm trying to understand:
1.) What ss values are being used by default? If I interpret parser.py correctly, ss values are being set as 0
2.) Can I set the steady state manually, for example like it's being done in econpizza package (Using steady_state/ fixed_values/ init_guesses headers). I tried, didn't get an error, but don't know how to check whether this worked.
3.) How can I see the steady state values in the estimated model?
4.) (unrelated), why does policy reacts by loosening if you put in a policy shock (shock_list = ('e_r', 4.0, 0) ) in the example (dfi.yaml) model? And why does every line starts with ~ ?

Many thanks for a wonderful package!

Testing for 1 observable models.

im trying to run minimal dsge with inflation data for estimation and im getting a lot of errors, do you have some examples for that yaml? would be usefull!

ZLB in getting_started.ipynb

Hello everyone,
first of all thank you Gregor for this fatastic library. I have a doubt about the zero-lower-bound ZLB in the example getting_started.ipynb. I do not understand why after running the Transposed Ensemble Kalman Filter (TEnKF) I get (as in the example) R values that are less than zero when the model should not allow it (also because the historical data never goes below zero) .
Thanks in advance
ZLB

No module named 'grgrlib.la'

20200619060330

from pydsge import * # imports eg. DSGE, example, sort_nhd ...
yaml_file, data_file = example

————————————————————————————————
ModuleNotFoundError Traceback (most recent call last)
in
----> 1 from pydsge import * # imports eg. DSGE, example, sort_nhd ...
2 yaml_file, data_file = example

D:\Users\yuanxiaohui\anaconda3\lib\site-packages\pydsge_init_.py in
4 import logging
5 import os
----> 6 from .clsmethods import DSGE
7 from .plots import sort_nhd
8 from pandas.plotting import register_matplotlib_converters

D:\Users\yuanxiaohui\anaconda3\lib\site-packages\pydsge\clsmethods.py in
6 import pandas as pd
7 from .parser import DSGE
----> 8 from .stats import summary, gfevd, mbcs_index, nhd, mdd
9 from .plots import posteriorplot, traceplot
10 from .mcmc import mcmc, tmcmc

D:\Users\yuanxiaohui\anaconda3\lib\site-packages\pydsge\stats.py in
11 import scipy.optimize as so
12 from scipy.special import gammaln
---> 13 from grgrlib.core import timeprint
14 from grgrlib.stats import mode
15

D:\Users\yuanxiaohui\anaconda3\lib\site-packages\grgrlib_init_.py in
6 from .njitted import *
7 from .optimize import *
----> 8 from .la import *

ModuleNotFoundError: No module named 'grgrlib.la'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.