Running An Existing Model

Running an Existing Model

The DSGE.jl package provides several example models:

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:

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.

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:

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.inpathFunction.
inpath(m::AbstractModel, in_type::T, file_name::T="") where T<:String

Returns 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>
source
DSGE.rawpathFunction.
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>
source
DSGE.logpathFunction.
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>
source
DSGE.workpathFunction.
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>
source
DSGE.tablespathFunction.
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>
source
DSGE.figurespathFunction.
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>
source