Manual creation of conditional forecast based on state space representation

Hi, I need to perform conditional forecast manually and I’m not allow to use dynare routines.

The idea is to write the model as

In order to use the dynare state space representation solution, I need to adjust matrix A below since it only multiplies a state variable vector and I need the full set of variables. I need to add static and purely forward variables. Then I add zeros in matrix A. In matrix B below looks like R above but I need to reorder (decision rule order)

Then I have the appropriate format of the augmented state space representation with variables stacked - control variables/static variables are already in the beginning of the vector

You can call dynare_resolve to achieve that. See line 174 in matlab/imcforecast.m · master · Dynare / dynare · GitLab
and the implementation in matlab/mcforecast3.m · master · Dynare / dynare · GitLab