Hello all,

Greetings from Belo Horizonte, Brazil.

I’ve written here before about this topic but still struggling. I’m looking for the mapping between the decision rules output by Dynare and the state-space representation of a linear model’s solution. Dynare’s output oo_.dr.ghx comes in the format x_{t+1}=Ax_t where vector x_t includes also the forward-looking variables. At the same time, in the state-space representation of the model’s solution (I calculated on my own), the forward-looking variables are in the control/signal block (they do not “cause” future values). The IRFs are identical, naturally, as it is the same model. How do I calculate the state-space transition matrices knowing only oo_.dr.ghx ? I searched an answer in several places to no avail (eg. Dejong/Dave’s volume; Fernandez-Vilaverde/Rubio-Ramirez/Schorfeide’s chapter on the HoM by Uhlig/Taylor; Dynare’s dr.pdf by Villemot; Barthelemy/Marx chapter on solutions). I’m in no university or research institution so my only resource is to ask in this space.

Thanks for the attention.

Eduardo.

Any views on the problem above? I’d appreciate your help.

A state-space representation I use in form of `ssm(AA,BB,CC,DD)`

of MATLAB structure is given by:

```
% ---------------------------------------------------------------------------------------------------
% Retrieving State Space representation in Dynare to ssm(A,B,C,D) Matlab
nStates = M_.endo_nbr;
nInnovations = M_.exo_nbr;
vObsNames = options_.varobs;
vEndoNames = M_.endo_names;
nObs = length(vObsNames);
invDRorder = oo_.dr.inv_order_var;
CC = zeros(nObs,nStates);
for i = 1:nObs
CC(i,:) = ismember(vEndoNames,vObsNames(i))';
end
iSmin = M_.nstatic + 1;
iSmax = M_.nstatic + M_.nspred;
AA0 = zeros(nStates,nStates);
AA0(:,iSmin:iSmax) = oo_.dr.ghx;
AA = AA0(invDRorder,invDRorder);
BB0 = oo_.dr.ghu(invDRorder,:);
oSigma2 = M_.Sigma_e;
DD = 0;
BB = BB0*oSigma2*BB0';
```

The order of variables in this state-space is according to declared in `var`

of .mod.

You might also want to look at DSGE_mod/FV_et_al_2007/ABCD_test.m at master · JohannesPfeifer/DSGE_mod · GitHub

and the post at

Thanks a lot, Aldo and Johannes. I’m getting a curious result. Aldo’s code and both codes in Johannes’ links are crashing. Aldo’s code refers to a non-existing options_.varobs, the ABCD_test refers to a non-existing options_.varobs_id while the note refers to a non-existing object M_.state_var. It is unclear how Dynare transforms the original model to solve it. My model has 5 variables of which 2 are foward looking, jumpers (observable). But Dynare presents 7 eigenvalues, where 1 of them is close to zero (to the 17-th decimal). What is Dynare doing in terms of creating auxiliary variables? Here is the model: CM.mod (1.5 KB)

A state-space representation has two set of equations (As it is indicated in Matlab for `ssm(A,B,C,D)`

function):

- One describing how a latent process transitions in time (the state equation)
- Another describing how an observer measures the latent process at each period (the observation equation)

Symbolically,

x_{t} = Ax_{t-1}+Bu_{t}

y_{t} = Cx_{t} + De_{t}

- x_{t} is state vector
- y_{t} is observation vector
- u_{t} and e_{t} are white-noise, unit-variance vector

So, you will need to include `varobs`

in your .mod.

You could want to read section:`"Typology and ordering of variables"`

in Reference Manual Dynare, version 4.5.4 and `"Solving rational expectations models at first order: what Dynare does"`

There is explained the regroupation and solution Dynare does.

Hello Aldo,

Your code ran successfully after I introduced the the varobs command (although both the ABCD test and the other code indicated by Johannes crashed for the same reason).

I guess I’m having difficulty explaining my problem. I understand state-space representations and Dynare’s perturbation solution. But I dont understand how Dynare prepares the model before solving. The model has only 5 variables but Dynare calculates 7 eigenvalues: how is this possible? The model has 2 forward looking variables (which belong to the observation equation). However, Dynare outputs these variables in the state equations. How is this possible, how can jumpers “cause” the future?

I appreciate your attention.

Regards,

Eduardo

Dynare transforms the model into a generic state space form where each variable appears with only one lead or lag, introducing auxiliary variables if necessary. This is described in the references given by @Aldo

Hello Johannes and Aldo,

I read all the references indicated and the wiki page on auxiliary variables to no avail. Is it possible to find out what auxiliary variables were created for my model? My M_.aux_vars is empty. And the write_latex_dynamic_model command result is identical to the original model. In addition, I dont see why dynare would create 2 auxiliary variables for my model since it has only one variable with more than 1 lead or lag. I tried to create one additional variable and solve it with the BK method but then I got a matrix with a zero column and a zero eigenvalue although it is a very simple model…CM.mod (1.6 KB)

In your case, there are no auxiliary variables introduced. The fact that there are 7 eigenvalues comes from the fact that you have two variables that are both forward-looking and appear with lag. Those are split as documented in Villemot’s `Solving rational expectations models at first order: what Dynare does`

. See the equation between (7) and (8).

Many thanks (it took me 3 weeks to realize you had responded). I’ll read closely the equations you pointed out in Villemot’s note. It is non trivial and the notation seems convoluted. I hope it explains how dynare treats variables that are both forward-looking and predetermined. Many thanks.

Eduardo

Did you ever discover how Dynare accounts for mixed variables?

The notation in Villemot’s work (https://www.dynare.org/wp-repo/dynarewp002.pdf) is indeed non-trivial. **A worked example would be most of use.**

For anyone out there, what are the linear equations Dynare uses, with specific regard to mixed variables, in order to give rise to the linear rational expectations system from which the Blanchard and Kahn condition for a unique and stable solution is subsequently checked?

Normally:

Qx_{t}=Rx_{t-1}+S\varepsilon_{t},

where

x_{t}=[x_{1t} \; \mathbb{E}_{t}x_{2t+1}]^{\top}, \; x_{t-1}=[x_{1t-1} \; \mathbb{E}_{t-1}x_{2t}]^{\top}\in\mathbb{R}^{n_{x}=n_{x_{1}}+n_{x_{2}}}, \; \varepsilon_{t}\in\mathbb{R}^{n_{\varepsilon}}, \; Q, \; R\in\mathbb{R}^{n_{x}\times n_{x}}

and

S\in\mathbb{R}^{n_{x}\times n_{\varepsilon}}.

Specifically,

x_{1t}

are predetermined/backward looking/past/non-expectational variables and

\mathbb{E}_{t}x_{2t+1}

are non-predetermined/forward looking/future/expectational variables.

Mixed variables are variables appearing both as predetermined and non-predetermined variables (e.g. inflation in the hybrid New Keynesian Phillips curve, at Calvo (staggered) contracts - Wikipedia)

Now, matrices Q, R and S’ n_{x_{1}} rows are the model’s linear equations (i.e. laws of motion). If Dynare does not diverge from such a construction hitherto then what equations characterise matrices Q, R and S’ last n_{x_{2}} rows?

Thanks.

I had actually posted this before creating that thread, which I did in order to boost its visibility, being especially important in its own right. Thus, no double posting occurred, if not accidentally/*ex post/a posteriori.* Confident of your understanding, cheers.