Could you let me know what “oo_.planner_objective_value” reports in “ramsey_policy”?
It is not the unconditional (theoretical) mean of the welfare.
Is it steady state of welfare plus .5Delta^2 in the solution of the second order approximation?
Is it steady state of welfare plus .5Delta^2 plus higher order terms (namely parameter multiplied with variances) in the solution of the second order approximation?

No, it is the conditional welfare.
The formula is (evaluate_objective_function.m)

planner_objective_value = Wbar+Wy*yhat+W_u*u+W_yu*yhat*u ...
+ 0.5*(W_yy*yhat^2 + Wuu_u^2+W_ss);
That is, it is a full second order expansion. Note that the concept of welfare is

W_t=U_t+beta*E_t (W_t+1)

so that today’s endogenous and exogenous states are contained in the information set at time t and affect U_t. You can specify these initial conditions with histval.

I would like to compute the unconditional welfare using “ramsey_policy,” which is trivial with the previous dynare code by Levin and Lopez-Salido. This is because W(t)=U(t)+betaW(t+1) must be added in the system of equation. Adding W(t)=U(t)+betaW(t+1) in “ramsey_policy” causes a problem since this becomes a redundant constraint.

Given the solution of the second order approximation:
Y(t)=.5DELTA^2+AAY(t-1)+BBu(t)+.5CC*(Y(t-1)xY(t-1))+.5DD(u(t)xu(t))+EE*(Y(t-1)xu(t)),
where all variables are deviations from the Ramsey steady states,
is the only way to compute the unconditional welfare that
E[Y(t)]=.5DELTA^2+.5CCvar(Y)+.5DDvar(u)+EEcovar(Y(t-1)Xu(t)))?

On the other hand, just to make is sure, what oo_.planeer_objective_value (the conditional welfare) with initial values being at the Ramsey steady state reports
E(t)[Y(t)]=.5DELTA^2+BBu(t)+.5DD(u(t)xu(t)).

Do I understand the procedures in dynare correctly? Also, if there is any easy way to compute the unconditional welfare, I would like to know this.

Sorry for posting a question again after your clear answer.

in your previous post, there shouldn’t be any u(t) because u(t) is observed at the beginning of the period and belongs by assumption to the information set of E_t()

If you want the unconditional welfare (a tricky concept), you could do the following

include utility = u(y_t), the period utility function, among the variable/equation of the model. This doesn’t generate the same problem as adding the definition of welfare.

then you can compute E(W_t) = E(u(y(t)) + \beta E(W_{t+1}) as E(W_t)= E(u(y_t))/(1-\beta) because E() being unconditional expectation, E(W_t) = E(W_{t+1}) and you can read E(u(y_t)) as the second order approximation to the mean of u

In order to get the second order approximation of the model under Ramsey, you must indicate
ramsey_model(planner_discount_factor=…);
stoch_simul(order=2);

Many thanks for your replies. I thought that I have not received answers. I really appreciate the way to compute unconditional welfare in the current Ramsey routine.