MacroModelling.jl

MacroModelling.jl: A Julia package for developing and solving dynamic stochastic general equilibrium models - Published in JOSS (2023)

https://github.com/thorek1/macromodelling.jl

Science Score: 98.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 11 DOI reference(s) in README and JOSS metadata
  • Academic publication links
    Links to: sciencedirect.com, wiley.com, joss.theoj.org, zenodo.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
    Published in Journal of Open Source Software

Keywords

difference-equations dsge dynamic-programming dynamical-systems implicit-differentiation macroeconomics optimal-control perturbation

Keywords from Contributors

pde meshing ode interpretability raytracer differential-equations ode-solver probabilistic-models probabilistic-numerics graphics

Scientific Fields

Earth and Environmental Sciences Physical Sciences - 40% confidence
Last synced: 4 months ago · JSON representation ·

Repository

Macros and functions to work with DSGE models.

Basic Info
Statistics
  • Stars: 122
  • Watchers: 7
  • Forks: 17
  • Open Issues: 15
  • Releases: 49
Topics
difference-equations dsge dynamic-programming dynamical-systems implicit-differentiation macroeconomics optimal-control perturbation
Created about 3 years ago · Last pushed 4 months ago
Metadata Files
Readme Contributing License Code of conduct Citation Agents

README.md

MacroModelling.jl

Documentation: Documentation

codecov CI DOI Package Downloads <!-- Downloads --> <!-- DOI --> <!-- -->

Author: Thore Kockerols (@thorek1)

MacroModelling.jl is a Julia package for developing and solving dynamic stochastic general equilibrium (DSGE) models.

These kinds of models describe the behaviour of a macroeconomy and are particularly suited for counterfactual analysis (economic policy evaluation) and exploring / quantifying specific mechanisms (academic research). Due to the complexity of these models, efficient numerical tools are required, as analytical solutions are often unavailable. MacroModelling.jl serves as a tool for handling the complexities involved, such as forward-looking expectations, nonlinearity, and high dimensionality.

The goal of this package is to reduce coding time and speed up model development by providing functions for working with discrete-time DSGE models. The user-friendly syntax, automatic variable declaration, and effective steady state solver facilitate fast prototyping of models. Furthermore, the package allows the user to work with nonlinear model solutions (up to third order (pruned) perturbation) and estimate the model using gradient based samplers (e.g. NUTS, or HMC). Currently, DifferentiableStateSpaceModels.jl is the only other package providing functionality to estimate using gradient based samplers but they use the start-of-period timing convention instead of the end-of-period timing convention used in most other packages. The target audience for the package includes central bankers, regulators, graduate students, and others working in academia with an interest in DSGE modelling.

As of now the package can:

  • parse a model written with user friendly syntax (variables are followed by time indices ...[2], [1], [0], [-1], [-2]..., or [x] for shocks)
  • (tries to) solve the model only knowing the model equations and parameter values (no steady state file needed)
  • calculate first, second, and third order (pruned) perturbation solutions using symbolic derivatives
  • handle occasionally binding constraints for linear and nonlinear solutions
  • calculate (generalised) impulse response functions, simulate the model, or do conditional forecasts for linear and nonlinear solutions
  • calibrate parameters using (non-stochastic) steady state relationships
  • match model moments (also for pruned higher order solutions)
  • estimate the model on data (Kalman filter using first order perturbation) with gradient based samplers (e.g. NUTS, HMC) or estimate nonlinear models using the inversion filter
  • differentiate (forward AD) the model solution, Kalman filter loglikelihood (forward and reverse-mode AD), model moments, steady state, with respect to the parameters

The package is not:

  • guaranteed to find the non-stochastic steady state (solving systems of nonlinear equations is an active area of research)
  • the fastest package around if you already have a fast way to find the NSSS (time to first plot is long, time to second plot (with new parameters) is very short)

For more details have a look at the documentation.

Getting started

Installation

MacroModelling.jl requires julia version 1.10 or higher and an IDE is recommended (e.g. VS Code with the julia extension).

Once set up you can install MacroModelling.jl (and StatsPlots in order to plot) by typing the following in the Julia REPL:

julia using Pkg; Pkg.add(["MacroModelling", "StatsPlots"])

Example

See below an implementation of a simple RBC model. You can find more detailed tutorials in the documentation.

```julia using MacroModelling import StatsPlots

@model RBC begin 1 / c[0] = (β / c[1]) * (α * exp(z[1]) * k[0]^(α - 1) + (1 - δ)) c[0] + k[0] = (1 - δ) * k[-1] + q[0] q[0] = exp(z[0]) * k[-1]^α z[0] = ρ * z[-1] + stdz * epsz[x] end;

@parameters RBC begin std_z = 0.01 ρ = 0.2 δ = 0.02 α = 0.5 β = 0.95 end;

plot_irf(RBC) ```

RBC IRF

The package contains the following models in the models folder:

Comparison with other packages

||MacroModelling.jl|dynare|DSGE.jl|dolo.py|SolveDSGE.jl|DifferentiableStateSpaceModels.jl|StateSpaceEcon.jl|IRIS|RISE|NBTOOLBOX|gEcon|GDSGE|Taylor Projection| |---|---|---|---|---|---|---|---|---|---|---|---|---|---| Host language|julia|MATLAB|julia|Python|julia|julia|julia|MATLAB|MATLAB|MATLAB|R|MATLAB|MATLAB| Non-stochastic steady state solver|symbolic or numerical solver of independent blocks; symbolic removal of variables redundant in steady state; inclusion of calibration equations in problem|numerical solver of independent blocks or user-supplied values/functions||numerical solver of independent blocks or user-supplied values/functions|numerical solver|numerical solver or user supplied values/equations|numerical solver of independent blocks or user-supplied values/functions|numerical solver of independent blocks or user-supplied values/functions|numerical solver of independent blocks or user-supplied values/functions|user-supplied steady state file or numerical solver|numerical solver; inclusion of calibration equations in problem||| Automatic declaration of variables and parameters|yes||||||||||||| Derivatives wrt parameters|yes|||||yes||||||| Perturbation solution order|1, 2, 3|k|1|1, 2, 3|1, 2, 3|1, 2|1|1|1 to 5|1|1||1 to 5| Pruning|yes|yes||||yes|||yes||||| Automatic derivation of first order conditions|||||||||||yes|| Occasionally binding constraints|yes|yes|yes|yes|yes||||yes|||yes|| Global solution||||yes|yes|||||||yes|| Estimation|yes|yes|yes|||yes||yes|yes|yes|yes||| Balanced growth path||yes|yes||||yes|yes|yes|yes||||| Model input|macro (julia)|text file|text file|text file|text file|macro (julia)|module (julia)|text file|text file|text file|text file|text file|text file| Timing convention|end-of-period|end-of-period||end-of-period|start-of-period|start-of-period|end-of-period|end-of-period|end-of-period|end-of-period|end-of-period|start-of-period|start-of-period|

Bibliography

Andreasen, M. M., Fernández-Villaverde, J., and Rubio-Ramírez, J. F. (2018), "The pruned state-space system for non-linear DSGE models: Theory and empirical applications.", The Review of Economic Studies, 85.1, p. 1-49.

Durbin, J, and Koopman, S. J. (2012), "Time Series Analysis by State Space Methods, 2nd edn", Oxford University Press.

Levintal, O., (2017), "Fifth-Order Perturbation Solution to DSGE models", Journal of Economic Dynamics and Control, 80, p. 1---16.

Villemot, S., (2011), "Solving rational expectations models at first order: what Dynare does", Dynare Working Papers 2, CEPREMAP.

Questions and Contributions

If you have questions regarding the usage or encounter unexpected behaviour please file an issue.

Contributions are very welcome, as are feature requests and suggestions. Please open an issue or even better become a contributor and create a pull request.

Owner

  • Name: Thore Kockerols
  • Login: thorek1
  • Kind: user
  • Location: Frankfurt, Germany

Economist interestested in macroeconomics, and modelling

JOSS Publication

MacroModelling.jl: A Julia package for developing and solving dynamic stochastic general equilibrium models
Published
September 25, 2023
Volume 8, Issue 89, Page 5598
Authors
Thore Kockerols ORCID
Norges Bank, Norway
Editor
Mehmet Hakan Satman ORCID
Tags
DSGE macroeconomics perturbation difference equations dynamical systems

Citation (CITATION.bib)

@article{Kockerols2023, 
	doi = {10.21105/joss.05598}, 
	url = {https://doi.org/10.21105/joss.05598}, 
	year = {2023}, 
	publisher = {The Open Journal}, 
	volume = {8}, 
	number = {89}, 
	pages = {5598}, 
	author = {Thore Kockerols}, 
	title = {MacroModelling.jl: A Julia package for developing and solving dynamic stochastic general equilibrium models}, 
	journal = {Journal of Open Source Software} 
}

GitHub Events

Total
  • Create event: 42
  • Commit comment event: 104
  • Release event: 6
  • Issues event: 7
  • Watch event: 21
  • Delete event: 19
  • Issue comment event: 52
  • Push event: 872
  • Pull request event: 59
  • Fork event: 4
Last Year
  • Create event: 42
  • Commit comment event: 104
  • Release event: 6
  • Issues event: 7
  • Watch event: 21
  • Delete event: 19
  • Issue comment event: 52
  • Push event: 872
  • Pull request event: 59
  • Fork event: 4

Committers

Last synced: 5 months ago

All Time
  • Total Commits: 1,747
  • Total Committers: 8
  • Avg Commits per committer: 218.375
  • Development Distribution Score (DDS): 0.023
Past Year
  • Commits: 128
  • Committers: 3
  • Avg Commits per committer: 42.667
  • Development Distribution Score (DDS): 0.141
Top Committers
Name Email Commits
thorek1 t****1 1,707
Thore Kockerols T****s@e****u 17
Thore Kockerols t****s@n****o 11
CompatHelper Julia c****y@j****g 5
dependabot[bot] 4****] 3
Thore Kockerols t****s@e****u 2
Tim Holy t****y@g****m 1
Luca Mingarelli l****i@m****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 26
  • Total pull requests: 135
  • Average time to close issues: 2 months
  • Average time to close pull requests: about 1 month
  • Total issue authors: 11
  • Total pull request authors: 9
  • Average comments per issue: 6.0
  • Average comments per pull request: 0.79
  • Merged pull requests: 63
  • Bot issues: 0
  • Bot pull requests: 44
Past Year
  • Issues: 3
  • Pull requests: 67
  • Average time to close issues: 1 day
  • Average time to close pull requests: 20 days
  • Issue authors: 3
  • Pull request authors: 4
  • Average comments per issue: 3.0
  • Average comments per pull request: 0.75
  • Merged pull requests: 17
  • Bot issues: 0
  • Bot pull requests: 21
Top Authors
Issue Authors
  • gdalle (8)
  • Aceampoma (4)
  • duzaichuan (4)
  • gpetrini (2)
  • eloualiche (2)
  • yguill1 (1)
  • azev77 (1)
  • laurencejj (1)
  • LucaMingarelli (1)
  • torein184 (1)
  • JuliaTagBot (1)
  • gionikola (1)
Pull Request Authors
  • thorek1 (87)
  • github-actions[bot] (42)
  • dependabot[bot] (8)
  • matyasfarkas (3)
  • jbytecode (3)
  • LucaMingarelli (3)
  • timholy (1)
  • azev77 (1)
  • gdalle (1)
Top Labels
Issue Labels
bug (1) linux (1) enhancement (1)
Pull Request Labels
codex (27) dependencies (8) github_actions (2)

Packages

  • Total packages: 1
  • Total downloads:
    • julia 19 total
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 42
juliahub.com: MacroModelling

Macros and functions to work with DSGE models.

  • Versions: 42
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 19 Total
Rankings
Dependent repos count: 9.9%
Stargazers count: 29.1%
Average: 29.6%
Dependent packages count: 38.9%
Forks count: 40.4%
Last synced: 4 months ago

Dependencies

.github/workflows/CompatHelper.yml actions
  • julia-actions/setup-julia latest composite
.github/workflows/TagBot.yml actions
  • JuliaRegistries/TagBot v1 composite
.github/workflows/ci.yml actions
  • actions/cache v3 composite
  • actions/checkout v4 composite
  • codecov/codecov-action v3 composite
  • julia-actions/julia-buildpkg v1 composite
  • julia-actions/julia-processcoverage v1 composite
  • julia-actions/julia-runtest v1 composite
  • julia-actions/setup-julia v1 composite
.github/workflows/documentation.yml actions
  • actions/checkout v3 composite
  • codecov/codecov-action v3 composite
  • julia-actions/julia-processcoverage latest composite
  • julia-actions/setup-julia latest composite
.github/workflows/Downgrade.yml actions
  • actions/checkout v4 composite
  • cjdoris/julia-downgrade-compat-action v1 composite
  • julia-actions/julia-buildpkg v1 composite
  • julia-actions/julia-runtest v1 composite
  • julia-actions/setup-julia v1 composite