Comparing ramsey model solution


I am computing the optimal policy under commitment from a timeless perspective. To check that I am doing things correctly, I am comparing the solutions using the built-in “ramsey_model” feature of Dynare and the solutions I get from letting Dynare solve a system of linear equations that should describe the optimal policy. I think they should give me the same results, but my solutions differ. Most importantly, my solutions have a “zigzag” feature for the latter method which may imply that there are negative eigenvalues. Should these two methods be different? If so, why? If not, how come they are?

My setup for the latter is as follows.

\begin{align*} \min_{c_{T,t},y_{N,t},y_{T,t},B_t,e_t} \quad &\sum_{t=0}^\infty \beta^t \mathbb{E}_0\left[ \begin{aligned} &\frac{\phi}{2} B_t^2 + \frac{\sigma}{2}{c}_{T,t}^2 + \frac{\chi\sigma}{2}{y}_{N,t}^2 + \frac{\psi}{2\alpha_T}({y}_{T,t}-{a}_{T,t})^2 + \frac{\chi\psi}{2\alpha_N}({y}_{N,t}-{a}_{N,t})^2 \\ &+ \lambda_{1,t} \left[c_{T,t} - \frac{\phi \overline{C_T}}{\sigma}B_t - c_{T,t+1}\right]\\ &+ \lambda_{2,t}\left[c_{T,t} - y_{N,t} + \frac{1}{\sigma}e_t\right]\\ &+ \lambda_{3,t}\left[e_t - \frac{1-\alpha_T}{\alpha_T}y_{T,t} + \frac{1}{\alpha_T}a_{T,t}\right]\\ &+\lambda_{4,t}\left[c_{T,t} - y_{T,t}-\frac{1}{\overline{C_T}}(RB_{t-1}-B_t)\right] \end{aligned} \right] \end{align*}

I will have 9 first-order equations that solve for c_{T,t},y_{N,t},y_{T,t},B_t,e_t,\lambda_{1,t},\lambda_{2,t},\lambda_{3,t},\lambda_{4,t} which are the allocations under the optimal commitment policy from a timeless perspective. The .mod file for this is attached as “baseline_alt.mod”.

For the former method, I just use the built-in Dynare feature to solve for the allocation under optimal policy. The .mod file for this is attached as “baseline_alt.mod”.

My question is, should these two methods be different? If so, why? If not, why do I get different impulse response functions where the latter method gives me zigzags and the former method does not?

Thank you in advance.

baseline.mod (817 Bytes)
baseline_alt.mod (830 Bytes)

I think I found the solution. There was a typo in one of the first-order conditions.

Would it be correct then, to assume that these two methods produce the same results?

Unless you have multiple steady states and select different ones, your manual approach and Dynare’s implementation should yield identical results.

Great. Thank you!