Forecasting

Forecasting

Procedure

In the forecast step, we compute smoothed histories, forecast, compute shock decompositions, and compute impulse response functions (IRFs) for states, observables, shocks, and pseudo-observables. To run a forecast on one combination of input parameter type (e.g. modal parameters or full-distribution) and conditional type, call forecast_one.

Main Steps:

DSGE.forecast_oneFunction.
forecast_one(m, input_type, cond_type, output_vars; df = DataFrame(),
    subset_inds = 1:0, forecast_string = "", verbose = :low)

Compute and save output_vars for input draws given by input_type and conditional data case given by cond_type.

Inputs

  • m::AbstractModel: model object

  • input_type::Symbol: one of:

  - `:mode`: forecast using the modal parameters only
  - `:mean`: forecast using the mean parameters only
  - `:init`: forecast using the initial parameter values only
  - `:full`: forecast using all parameters (full distribution)
  - `:subset`: forecast using a well-defined user-specified subset of draws
  • cond_type::Symbol: one of:
  - `:none`: no conditional data
  - `:semi`: use "semiconditional data" - average of quarter-to-date
    observations for high frequency series
  - `:full`: use "conditional data" - semiconditional plus nowcasts for
    desired observables
  • output_vars::Vector{Symbol}: vector of desired output variables. See ?forecast_one_draw.

Keyword Arguments

  • df::DataFrame: Historical data. If cond_type in [:semi, :full], then the final row of df should be the period containing conditional data. If not provided, will be loaded using load_data with the appropriate cond_type
  • subset_inds::AbstractRange{Int64}: indices specifying the draws we want to use. If a more sophisticated selection criterion is desired, the user is responsible for determining the indices corresponding to that criterion. If input_type is not subset, subset_inds will be ignored
  • forecast_string::String: short string identifying the subset to be appended to the output filenames. If input_type = :subset and forecast_string is empty, an error is thrown.
  • verbose::Symbol: desired frequency of function progress messages printed to standard out. One of :none, :low, or :high.

Outputs

None. Output is saved to files returned by get_forecast_output_files(m, input_type, cond_type, output_vars).

source

For example, to do an unconditional forecast of states and observables using the modal parameters, call:

m = AnSchorfheide()
forecast_one(m, :mode, :none, [:forecaststates, forecastobs])

Full-Distribution Forecasts:

Full-distribution forecasts are computed in blocks. The size of each block defaults to 5000 draws (before thinning by get_setting(m, :forecast_jstep)), but can be set using the :forecast_block_size Setting. For each block, draws are read in on the originator process, then computation proceeds in parallel using pmap. When all draws in the block are finished, the forecast outputs are reassembled on the originator process and appended to the HDF5 dataset in their respective output files.

To fully take advantage of the parallelization, the user is responsible for adding processes before calling forecast_one, either by calling addprocs or using one of the functions defined in ClusterManagers.jl. For example, to run a full-distribution unconditional forecast using 10 processes:

my_procs = addprocs(10)
@everywhere using DSGE

m = AnSchorfheide()
forecast_one(m, :full, :none, [:forecaststates, forecastobs])

rmprocs(my_procs)

Notice that it is necessary to load DSGE on all processes using @everywhere using DSGE before calling forecast_one.

By default, full-distribution forecasts start from the first block. However, if you want to start the forecast from a later block, you can also do so. For example:

m <= Setting(:forecast_start_block, 2,
    "Block at which to resume forecasting (possibly null)")

Forecast Outputs

A forecast output (i.e. an output_var) is a combination of what we call a "product" and a "class". The possible classes are states (:states), observables (:obs), pseudo-observables (:pseudo), and standardized (:stdshocks) and unstandardized shocks (:shocks). The possible forecast products are:

An output_var is then just a Symbol with a product and class concatenated, e.g. :histstates for smoothed historical states.

It is not necessary to compute all forecast outputs in one call to forecast_one. Which steps are run depends on which output_vars are passed in.

Preparing Forecast Inputs

Adding Required output_vars:

This step is done by add_requisite_output_vars:

Loading Data:

This is done the usual way, using load_data with the appropriate cond_type.

Loading Draws:

By default, the draws are loaded from the file whose path is given by get_forecast_input_file. However, you can override the default input file for a given input type by adding entries to the Dict{Symbol, ASCIIString} returned from forecast_input_file_overrides(m). For example:

overrides = forecast_input_file_overrides(m)
overrides[:mode] = "path/to/input/file.h5"

Note that load_draws expects an HDF5 dataset called either params (for input_type in [:mode, :mean]) or mhparams (for input_type in [:full, :subset]).

Computing Forecast Outputs

Smoothing:

Smoothing is necessary if either:

It is not necessary to keep track of these cases, however - forecast_one will deduce from the specified output_vars whether or not it is necessary to filter and smooth in order to produce your output_vars.

Forecasting:

Forecasting begins from the last filtered historical state, which is obtained from the Kalman filter. forecast accepts a keyword argument enforce_zlb, which indicates whether to enforce the zero lower bound. If enforce_zlb = true, then if in a given period, the forecasted interest rate goes below forecast_zlb_value(m), we solve for the interest rate shock necessary to push it up to the ZLB. A forecast in which the ZLB is enforced corresponds to the product :bddforecast.

Shock Decompositions, Deterministic Trends, and Trends:

Since shock decompositions have an additional dimension (e.g. nstates x nperiods x nshocks for a single draw of state shock decompositions, compared to nstates x nperiods for a single draw of forecasted states), we usually wish to truncate some periods before returning. This behavior is governed by the Settings :shockdec_starttdate and :shockdec_enddate, which are of type Nullable{Date}.

Deterministic trends are also saved only for date_shockdec_start(m) and date_shockdec_end(m). Trends are not time-dependent.

Impulse Response Functions:

Like shock decompositions, IRFs have three dimensions (e.g. nstates x nperiods x nshocks) for each draw.

Saving Forecast Outputs

Forecast outputs are saved in the location specified by get_forecast_output_files(m), which is typically a subdirectory of saveroot(m). Each output_var is saved in its own JLD file, which contains the following datasets:

Some helpful functions for getting file names, as well as reading and writing forecast outputs, include: