Understanding ramsey_model

I have some trouble understanding the outcome of ramsey optimal policy. I ran the ramsey optimal policy with an objective function looking like this:
W = E_0 \sum_{t=0}^\infty \beta^t \left[\lambda \ln{C_{kt}} + (1-\lambda)\ln{C_{rt}} - \frac{N_t^{1+\phi}}{1+\phi}\right]
and i run it again with a different objective function, where the CB only considers one agent, looking like this:
W = E_0 \sum_{t=0}^\infty \beta^t \left[\ln{C_{kt}} - \frac{N_t^{1+\phi}}{1+\phi}\right]
(i did use the undiscounted one-period objective for planner_objective)

Now of course i got two different results, but what really confused me, was, that when I manually calculated welfare using the first welfare function for both cases, it was the second one, that had higher welfare. I thought the ramsey policy would give me the optimal outcome, given the objective I defined. How can it be, that I achieve higher welfare (as measured by the first objective) for the second case?
Hansen2020_NotLinearized_Ramsey.mod (5.6 KB)
run_different_ramsey_policies.m (1.1 KB)

How big are the differences? And how did you compute the objective manually?

I ran ramsey_model once with the first objective I wrote above and once with the second objective and than i wanted to compare the outcome of both regimes. Everything in a deterministic context.

I than calculated the Welfare directly, so calculated exactly this sum:
W = E_0 \sum_{t=0}^{50}\beta^t \left[\lambda \ln{C_{kt}} + (1-\lambda)\ln{C_{rt}} - \frac{N_t^{1+\phi}}{1+\phi}\right]
for both policy regimes.

The welfare difference between both regimes is not large, it is in the realm of 10^-4.

Also, I actually thought, that for the first case, this would be at least approximately identical to evaluate_planner_objective, since I evaluated the same objective I entered into planner_objective. But it doesn’t look like this is the case (with and without considering the discount factor).

It seems you are neglecting the terminal value. Welfare does not end at period 50. It will be at its steady state value (if periods is sufficiently high)

Yes, sry I wrote the wrong sum, there would be terminal value for 50 periods, but I’m doing 100, which is when all variables have returned to the steady-state in both cases and even for much larger periods the problem still persists.

Could the problem be my approach for calculating welfare?

The evaluate_planner_objective for the first case computes:
unconditional: -70.53292194
conditional: -69.93941409

But my approach of calculating the sum (which I thought would be approximately identical to evaluate_planner_objective, since it’s the same objective) computes:
-52.2670 and
-36.7160 when I also take into account the discount factor.

You should not be getting such big differences in numbers. There must be a mistake.