## kstate

Hi,

I was wondering if somebody can explain to me the structure of kstate? I am aware that using this is depreciated, as this is a reminiscence of old dynare versions where we did not create auxiliary variables for leads and lags greater than one, but still I find it is used in several functions dealing with e.g. the perturbation solution or identification toolbox. In any case, I still have problems to get the hang of this. So maybe someone can help me out, given the following simple example:

```
var Y C K A;
varexo eps_A;
parameters alph betta rhoA sigA;
alph = 0.35; betta = 0.99; rhoA = 0.9; sigA = 0.6;
model;
C^(-1)=alph*betta*C(+1)^(-1)*A(+1)*K^(alph-1);
K=A*K(-1)^alph-C;
log(A)=rhoA*log(A(-1))+sigA*eps_A;
Y = A*K(-1)^alph;
end;
```

As I understand, my state variables are K and A, i.e.

- the declaration order is Y C K A
- the DR order is Y K A C
- lead_lag_incidence is equal to

Y | C | K | A | |
---|---|---|---|---|

t-1 | 0 | 0 | 1 | 2 |

t | 3 | 4 | 5 | 6 |

t+1 | 0 | 7 | 0 | 8 |

where the number corresponds to the corresponding column number in the dynamic files (i.e. derivative wrt the variable)

Now, the kstate variable is given by:

3 | 3 | 4 | 0 |

4 | 3 | 3 | 0 |

2 | 2 | 0 | 1 |

3 | 2 | 0 | 2 |

but I do not understand this. As far as I see, there is only one comment in set_state_space.m:

```
% composition of state vector
% col 1: variable; col 2: lead/lag in z(t+1);
% col 3: A cols for t+1 (D); col 4: A cols for t (E)
```

but what is the meaning of z(t+1), A, D and E or to which state space representation do these correspond to?

Thanks!