# How oo_.gamma{nar+3} is calculated?

As verified, oo_.mean = oo_.dr.ys + oo_.gamma{nar+3}? So how oo_.gamma{nar+3} is calculated? Is it has something to do with oo_.dr.ghs2?
Thanks! Anybody can hlep?

The means at order=2 are based on the pruned state space as in Kim, Kim, Schaumburg, Sims (2008): Calculating and using second-order accurate solutions of discrete time dynamic equilibrium models.
The solution at second order can be written as:

\hat x_t = g_x \hat x_{t - 1} + g_u u_t + \frac{1}{2}\left( g_{\sigma\sigma} \sigma^2 + g_{xx}\hat x_t^2 + g_{uu} u_t^2 \right)
]
Taking expectations on both sides requires to compute E(x^2)=Var(x), which can be obtained up to second order from the first order solution

\hat x_t = g_x \hat x_{t - 1} + g_u u_t
]
by solving the corresponding Lyapunov equation.
Given Var(x), the above equation can be solved for E(x_t) as

E(x_t) = (I - {g_x}\right)^{- 1} 0.5\left( g_{\sigma\sigma} \sigma^2 + g_{xx} Var(\hat x_t) + g_{uu} Var(u_t) \right)
]
The 0.5 g_{\sigma\sigma} \sigma^2 is stored in oo_.dr.ghs2