Running an Existing Model
The DSGE.jl package provides several example models:
- A simple three-equation DSGE model from An and Schorfheide (2006)
- The well-known Smets and Wouters (2007) model
- The New York Fed DSGE model (version 990.2), which was introduced in this blog post
- The New York Fed DSGE model (version 1002.9), which is documented here
- The New York Fed DSGE model (version 1010.18)
- Several methods for model averaging over two models from Del Negro et al. (2016) through the concrete type
PoolModel
.
You can run these models using the description provided here. If you were to implement another model using DSGE.jl, these procedures can also be used to estimate those models.
Please see examples/ on the GitHub or the equivalent folder inside your Julia packages directory for example scripts we have created.
For getting started, see these two scripts.
run_default.jl
: a simple example of the standard workflow with DSGE.jlmake_packet.jl
: auto-generate a packet of plots and figures which help the user analyze estimation, forecast, and impulse response results. This script also provides an example of how we recommend structuring "main" files that launch a forecast and generate results with one "click."
For more advanced usage, see
test_smc.jl
: use SMC to estimate DSGE models.decompose_forecast.jl
: understand why a forecast has changed by running a forecast decompositionregime_switching.jl
: set up a forecast with regime-switching in the history and forecast horizonuncertain_altpolicy_zlb.jl
: set up a forecast with a temporary ZLB and imperfect awareness about the credibility of a policy switch to flexible AIT.tvis_system.jl
: set up a state space system and forecast with time-varying information setsrun_dsgevar.jl
: estimate and analyze impulse responses for aDSGEVAR
.run_dsgevecm.jl
: analyze impulse response for DSGE-VECMs.
Running with Default Settings
To estimate and forecast in Julia, simply create an instance of the model object and call estimate
and forecast_all
. A minimal example is reproduced below.
# estimate as of 2015-Q3 using the default data vintage from 2015 Nov 27
custom_settings = Dict{Symbol, Setting}(
:data_vintage => Setting(:data_vintage, "151127"),
:date_forecast_start => Setting(:date_forecast_start, quartertodate("2015-Q4")))
# construct a model object
m = Model990(custom_settings = custom_settings)
# reoptimize parameter vector, compute Hessian at mode, and full posterior
# parameter sampling
estimate(m)
# produce LaTeX tables of parameter moments
moment_tables(m)
# forecast and compute means and bands using 10 processes
my_procs = addprocs(10)
@everywhere using DSGE
forecast_one(m, :full, :none, [:forecaststates, :forecastobs])
compute_meansbands(m, :full, :none, [:forecaststates, :forecastobs])
rmprocs(my_procs)
For more details on changing the model's default settings, parameters, equilibrium conditions, etc., see Advanced Usage.
By default, the estimate
routine loads the dataset, reoptimizes the initial parameter vector, computes the Hessian at the mode, and conducts full posterior parameter sampling using Metropolis-Hastings. (The initial parameter vector used is specified in the model's constructor.) Further options for estimation are described in Estimation:
- To use updated data or alternative user-specified datasets, see Input Data.
- The user may want to avoid reoptimizing the parameter vector and calculating the Hessian matrix at this new vector. Please see Reoptimizing.
For more information on the many types of forecasts that can be run on an existing or user-defined model, see Forecasting.
Input/Output Directory Structure
The DSGE.jl estimation uses data files as input and produces large data files as outputs. One estimation saves several GB of parameter draws and related outputs. It is useful to understand how these files are loaded/saved and how to control this behavior.
Directory Tree
The following subdirectory tree indicates the default locations of these input and outputs. Square brackets indicate directories in the tree that will become relevant as future features are implemented.
Note that this directory tree is not linked, although it appears to be.
<dataroot>/
: Root data directory.data/
: Macroeconomic input data series.cond/
: Conditional data, i.e.user/
: User-created or sample model input files.<saveroot>/
: Root save directory.output_data/
m990/
: Input/output files for theModel990
type. A model of typeSPEC
will create its own save directorySPEC/
at this level in the directory tree.ss0/
: Subdirectory for subspec 0. A model of a different subspec will have similar directories at this level of the tree.estimate/
figures/
: Plots and other figurestables/
: LaTeX tablesraw/
: Raw output data from estimation stepwork/
: Derived data files created usingraw/
files as input- [
xxx/
]: Other model outputs, such as forecasts, impulse response functions, and shock decompositions; subdirectory structure mirrors that ofestimate
.
Directory Paths
By default, input/output directories are located in the DSGE.jl package, along with the source code. Default values of the input/output directory roots:
saveroot(m)
:"$(Pkg.dir())/DSGE/save"
dataroot(m)
:"$(Pkg.dir())/DSGE/save/input_data"
Note these locations can be overridden as desired. See Advanced Usage for more details.
m <= Setting(:saveroot, "path/to/my/save/root")
m <= Setting(:dataroot, "path/to/my/data/root")
Utility functions are provided to create paths to input/output files. These should be used for best results.
Missing docstring for DSGE.inpath
. Check Documenter's build log for details.
Missing docstring for DSGE.rawpath
. Check Documenter's build log for details.
Missing docstring for DSGE.logpath
. Check Documenter's build log for details.
Missing docstring for DSGE.workpath
. Check Documenter's build log for details.
Missing docstring for DSGE.tablespath
. Check Documenter's build log for details.
Missing docstring for DSGE.figurespath
. Check Documenter's build log for details.