# Forecast Decomposition

Separate from the standard Forecasting routines, we have also implemented a function `decompose_forecast`

for explaining why a forecast changes as new data becomes available and new estimations are run. Please note that this function **does not** decompose a forecast into the shocks that produce it. For example, if you want to understand whether TFP or financial shocks are driving a forecast, then you should be calculating the shock decomposition output variable (see Calculating Shock Decompositions).

`DSGE.decompose_forecast`

— Function```
decompose_forecast(m_new, m_old, df_new, df_old, input_type, cond_new, cond_old,
classes; verbose = :low, kwargs...)
decompose_forecast(m_new, m_old, df_new, df_old, params_new, params_old,
cond_new, cond_old, classes; check = false)
```

explains the differences between an old forecast and a new forecast by decomposing the differences into three sources:

(1) Data revisions, (2) News (e.g. new data that has become available since the old forecast), (3) Re-estimation (i.e. changes in model parameters).

This function **does not** compute which shocks explain a forecast. For example, if you want to know whether TFP or financial shocks drive a given forecast, then you want to compute the shock decomposition output variable (see `?shock_decompositions`

, `forecast_one`

, and `compute_meansbands`

).

Note that this function currently does not work for a model in which there are changes in the degree of "regime-switching" in the `TTT`

, `RRR`

, `CCC`

, `ZZ`

, and `DD`

matrices, e.g. decomposing the changes in the forecast when the monetary policy rule changes or if a temporary policy is implemented that did not occur in the old forecast.

**Inputs**

`m_new::M`

and`m_old::M`

where`M<:AbstractDSGEModel`

`df_new::DataFrame`

and`df_old::DataFrame`

`cond_new::Symbol`

and`cond_old::Symbol`

`classes::Vector{Symbol}`

: some subset of`[:states, :obs, :pseudo]`

**Method 1 only:**

`input_type::Symbol`

: estimation type to use. Parameters will be loaded using`load_draws(m_new, input_type)`

and`load_draws(m_old, input_type)`

in this method

**Method 2 only:**

`params_new::Vector{Float64}`

and`params_old::Vector{Float64}`

: single parameter draws to use

**Keyword Arguments**

`check::Bool`

: whether to check that the individual components add up to the correct total difference in forecasts. This roughly doubles the runtime

**Method 1 only:**

`verbose::Symbol`

**Outputs**

The first method returns nothing. The second method returns `decomp::Dict{Symbol, Matrix{Float64}}`

, which has keys of the form `:decomp<component><class>`

and values of size `Ny`

x `Nh`

, where

`Ny`

is the number of variables in the given class`Nh`

is the number of common forecast periods, i.e. periods between`date_forecast_start(m_new)`

and`date_forecast_end(m_old)`

For an example of how to use this functionality, see decompose_forecast.jl on the Github page (or directly inside the directory where DSGE.jl has been downloaded).