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)
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.
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)
m <= Setting(:sampling_method, :SMC) #if you'd like to use SMC
# reoptimize parameter vector, compute Hessian at mode, and full posterior
# parameter sampling
estimate(m)
# produce LaTeX tables of parameter moments
compute_moments(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. (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 theModel990type. A model of typeSPECwill 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 Model Settings 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.
DSGE.inpath — Function.inpath(m::AbstractModel, in_type::T, file_name::T="") where T<:StringReturns path to specific input data file, creating containing directory as needed. If file_name not specified, creates and returns path to containing directory only. Valid in_type includes:
"raw": raw input series"data": transformed data in model units"cond": conditional data - nowcasts for the current forecast quarter, or related"user": user-supplied data for starting parameter vector, hessian, or related"scenarios": alternative scenarios
Path built as
<data root>/<in_type>/<file_name>DSGE.rawpath — Function.rawpath(m::AbstractModel, out_type::String, file_name::String="", filestring_addl::Vector{String}=Vector{String}())Returns path to specific raw output file, creating containing directory as needed. If file_name not specified, creates and returns path to containing directory only. Path built as
<output root>/output_data/<spec>/<subspec>/<out_type>/raw/<file_name>_<filestring>.<ext>DSGE.logpath — Function.logpath(m::AbstractModel, out_type::String, file_name::String="", filestring_addl::Vector{String}=Vector{String}())Returns path to specific log output file, creating containing directory as needed. If file_name not specified, creates and returns path to containing directory only. Path built as
<output root>/output_data/<spec>/<subspec>/<out_type>/log/<file_name>_<filestring>.<ext>DSGE.workpath — Function.workpath(m::AbstractModel, out_type::String, file_name::String="", filestring_addl::Vector{String}=Vector{String}())Returns path to specific work output file, creating containing directory as needed. If file_name not specified, creates and returns path to containing directory only. Path built as
<output root>/output_data/<spec>/<subspec>/<out_type>/work/<file_name>_<filestring>.<ext>DSGE.tablespath — Function.tablespath(m::AbstractModel, out_type::String, file_name::String="", filestring_addl::Vector{String}=Vector{String}())Returns path to specific tables output file, creating containing directory as needed. If file_name not specified, creates and returns path to containing directory only. Path built as
<output root>/output_data/<spec>/<subspec>/<out_type>/tables/<file_name>_<filestring>.<ext>DSGE.figurespath — Function.figurespath(m::AbstractModel, out_type::String, file_name::String="", filestring_addl::Vector{String}=Vector{String}())Returns path to specific figures output file, creating containing directory as needed. If file_name not specified, creates and returns path to containing directory only. Path built as
<output root>/output_data/<spec>/<subspec>/<out_type>/figures/<file_name>_<filestring>.<ext>