# State Space Representation

**URL:** <https://forum.dynare.org/t/state-space-representation/5218>\
**Category:** Dynare help (legacy posts)\
**Created:** [13 January 2016 18:12 UTC](https://forum.dynare.org/t/state-space-representation/5218 "2016-01-13T18:12:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lorenzo](https://forum.dynare.org/letter_avatar_proxy/v4/letter/l/4da419/32.png) [@Lorenzo](https://forum.dynare.org/u/Lorenzo)\
**Post date:** [13 January 2016 18:12 UTC](https://forum.dynare.org/t/state-space-representation/5218/1 "2016-01-13T18:12:59Z")

</div>

Hi,  
I am trying to retrieve the following state-space representation from Dynare:

s\_t = A_s\_t-1 + B_epsilon\_t  
x\_t = C\*s\_t

where s\_t is a mx1 vector of states and x\_t is a nx1 vector of controls. A is a mxm matrix, epsilon\_t is wx1 and B is mxw. C is the policy funciton and is nxm.

However, to my knowledge, Dynare combines the two equations as one:

x\_t = C_A_s\_t-1 + C_B_epsilon\_t

My question: How can I retrieve the coefficients of A, B, and C using Dynare (up to third-order)?

Thanks so much

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [14 January 2016 09:28 UTC](https://forum.dynare.org/t/state-space-representation/5218/2 "2016-01-14T09:28:01Z")

</div>

At first order, this is straightforward. See [github.com/JohannesPfeifer/DSGE\_mod/tree/master/FV\_et\_al\_2007](https://github.com/JohannesPfeifer/DSGE_mod/tree/master/FV_et_al_2007) and the content of the ABCD\_test.m  
At higher order, the state-space needs cannot be easily represented linearly (unless you use pruning). This is not yet supported.

---

<div class="post-metadata">

**Author:** ![Lorenzo](https://forum.dynare.org/letter_avatar_proxy/v4/letter/l/4da419/32.png) [@Lorenzo](https://forum.dynare.org/u/Lorenzo)\
**Post date:** [14 January 2016 11:51 UTC](https://forum.dynare.org/t/state-space-representation/5218/3 "2016-01-14T11:51:05Z")

</div>

Dear Johannes,  
Thanks for your reply. Thanks for the function ABCD\_test.m. However, this function simply uses the output from Dynare and reshuffles it a bit. Basically, I am trying to estimate a model with Bayesian estimation up to the third order. The estimation itself should be fine. However, I would need to be able to retrieve the state space representation from somewhere - I was thinking about Dynare. As a first step, I tried to replicate the examples (2nd order) from Schmitt-Grohe and Uribe (2004) “Solving dynamic general equilibrium models using a second-order approximation to the policy function” - basically get the same coefficients of the 2nd order approximation. However, this seems not to be possible with Dynare… Do you have any idea how this could be accomplished?  
Thanks so much,  
Lorenzo

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [14 January 2016 14:45 UTC](https://forum.dynare.org/t/state-space-representation/5218/4 "2016-01-14T14:45:39Z")

</div>

As I said, it is not clear which state space representation you mean. At higher order, you have a nonlinear statespace so that you won’t get

`s_t = A*s_t-1 + B*epsilon_t
x_t = C*s_t`  
but rather a more general

`s_t = f(s_t-1,epsilon_t)
x_t = g(s_t)`  
As there is no standard form, you would need to do this yourself. The only help you can find is the unpacking of the g\_\* matrices conducted in  
[github.com/DynareTeam/dynare/blob/master/matlab/k\_order\_pert.m](https://github.com/DynareTeam/dynare/blob/master/matlab/k_order_pert.m)  
and the simulations in  
[github.com/DynareTeam/dynare/blob/master/matlab/simult\_.m  
 ](https://github.com/DynareTeam/dynare/blob/master/matlab/simult_.m)
