| 1 |
// --+ options: json=compute nostrict +-- |
| 2 |
|
| 3 |
/* REMARK |
| 4 |
** ------ |
| 5 |
** |
| 6 |
** You need to have the first line on top of the mod file. The options defined on this line are passed |
| 7 |
** to the dynare command (you can add other options, separated by spaces or commas). The option defined |
| 8 |
** here is mandatory for the decomposition. It forces Dynare to output another representation of the |
| 9 |
** model in a json file (additionaly to the matlab files) which is used here to manipulate the equation |
| 10 |
** of interest. |
| 11 |
*/ |
| 12 |
|
| 13 |
// Declaration of the endogenous variables |
| 14 |
var ffr, unrate, cpi; |
| 15 |
|
| 16 |
// Declaration of the exogenous variables |
| 17 |
varexo e_ffr, e_unrate, e_cpi; |
| 18 |
|
| 19 |
|
| 20 |
parameters p_ffr_ffr_lag_1 p_ffr_ffr_lag_2 p_ffr_ffr_lag_3 p_ffr_unrate_lag_1 p_ffr_unrate_lag_2 p_ffr_unrate_lag_4 p_ffr_unrate_lag_5 p_ffr_cpi_lag_4 p_unrate_cpi_lag_1 p_unrate_cpi_lag_2 p_unrate_cpi_lag_3 p_unrate_cpi_lag_4 p_unrate_cpi_lag_5 p_unrate_cpi_lag_6 p_cpi_ffr_lag_1 p_cpi_ffr_lag_2 p_cpi_cpi_lag_2; |
| 21 |
|
| 22 |
// Declaration of the model. Note that you must associate a name to the equations. This is mandatory to |
| 23 |
// select the equation for which you need to perform the decomposition. |
| 24 |
model; |
| 25 |
|
| 26 |
[name='ffr'] |
| 27 |
ffr = ffr(-1)*p_ffr_ffr_lag_1 + ffr(-2)*p_ffr_ffr_lag_2 + ffr(-3)*p_ffr_ffr_lag_3 + unrate(-1)*p_ffr_unrate_lag_1 + cpi(-4)*p_ffr_cpi_lag_4; |
| 28 |
|
| 29 |
[name='unrate'] |
| 30 |
unrate = unrate(-4)*p_ffr_unrate_lag_4 + unrate(-2)*p_ffr_unrate_lag_2 + unrate(-5)*p_ffr_unrate_lag_5 + cpi(-1)*p_unrate_cpi_lag_1 + cpi(-2)*p_unrate_cpi_lag_2 + cpi(-3)*p_unrate_cpi_lag_3 + cpi(-4)*p_unrate_cpi_lag_4 + cpi(-5)*p_unrate_cpi_lag_5 + cpi(-6)*p_unrate_cpi_lag_6; |
| 31 |
|
| 32 |
[name='cpi'] |
| 33 |
cpi = ffr(-1)*p_cpi_ffr_lag_1 + ffr(-2)*p_cpi_ffr_lag_2 + cpi(-2)*p_cpi_cpi_lag_2; |
| 34 |
|
| 35 |
end; |
| 36 |
|
| 37 |
// Implicit parameters associated to the adl command must be calibrated after the model block. |
| 38 |
p_ffr_ffr_lag_1 = 1; |
| 39 |
p_ffr_ffr_lag_2 = p_ffr_ffr_lag_1*.5; |
| 40 |
p_ffr_ffr_lag_3 = p_ffr_ffr_lag_2*.5; |
| 41 |
p_ffr_unrate_lag_1 = 2; |
| 42 |
p_ffr_cpi_lag_4 = 3; |
| 43 |
|
| 44 |
// Actual paths for the variables. You migth instead do a stochastic simulation of the model |
| 45 |
// to define these paths. |
| 46 |
ds1 = dseries(randn(30, 3), 1990Q1, {'ffr', 'unrate', 'cpi'}); |
| 47 |
|
| 48 |
// Baseline paths for the variables. |
| 49 |
ds0 = dseries(zeros(30, 3), 1990Q1, {'ffr', 'unrate', 'cpi'}); |
| 50 |
|
| 51 |
/* Trigger the decomposition in levels of an equation |
| 52 |
** |
| 53 |
** - First argument (ffr) is the name of the equation to be decomposed. |
| 54 |
** - Second argument (ds1) is a dseries object containing the actual paths of the endogenous and exogenous variables. |
| 55 |
** - Third argument (ds0) is a dseries object containing the baseline paths of the endogenous and exogenous variables. |
| 56 |
** |
| 57 |
** If there is no error (missing variables, undefined equations, ...) a figure will pop up with displaying the |
| 58 |
** contributions of the variables appearing on the right hand side of equation `ffr`. Note that the overall contribution |
| 59 |
** of each variable (at all lags) is reported. If you want to decompose these aggregates, you need to rewrite the |
| 60 |
** model as shown in the other mod file in the same folder (contrib2.mod). |
| 61 |
*/ |
| 62 |
|
| 63 |
plot_contributions ffr ds1 ds0 ; |