Hi.

How we can detect control variables in a DSGE model ?

I assume you are concerend with state-space modeling (i.e. a representation of the first-order perturbation approximation of the policy functions):

x_t = A x_{t-1} + B u_t\\
y_t = C x_{t-1} + D u_t

where x_t denote state variables and y_t are control variables.

So, the answer to your question depends on your definition of control variables:

- If control variables are “observable” variables, then they are declared by the user using the VAROBS statement
- If you think about control variables as being non-state variables then this might help you:

In Dynare there are four types of endogenous variables:- static variables: those that appear only at the current period, but not at the past or future period. Their number is in
`M_.nstatic`

. - purely backward (or predetermined) variables}: those that appear only at the past period, possibly at the current period, but not at the future period. Their number is
`M_.npred`

. - purely forward variables: those that appear only at the future period, possibly at the current period, but not at the past period. Their number is
`M_.nfwrd`

. - mixed variables: those that appear both at the past and future period, and possibly at the current period. Their number is
`M_.nboth`

.

Note that each variables falls into one category, and we thus have the following identity:`M_.endo_nbr = M_.nstatic + M_.npred + M_.nboth + M_.fwrd`

The**state variables**of the model are the predetermined and mixed variables. Their number is`M_.nspred = M_.npred + M_.nboth`

.

- static variables: those that appear only at the current period, but not at the past or future period. Their number is in
- Lastly, you can also define control variables as all endogenous variables. This is actually what you get when you look into
`oo_.dr.ghx`

and`oo_.dr.ghu`

for all endgenous variables, note that these are your C and D matrices in the above notation. If you also want the A and B matrix, then first create an index for states:

```
indx = [M_.nstatic+(1:M_.nspred)]';
A = oo_.dr.ghx(indx,:);
B = oo_.dr.ghu(indx,:);
```