Questions on Ramsey welfare in Dynare 4.7

Hello everyone,

I would like to ask questions related with welfare calculation under the optimal policy. My computation basically follows this paper:

Let me summarize the main steps:

Suppose we have a separable utility function:
W_t =\displaystyle \mathbb{E}_t\sum^{\infty}_{j=0}\beta^j\left[\frac{{C_{t+j}}^{1-\sigma}}{1-\sigma}-\chi \frac{{N_{t+j}}^{1+\phi}}{1+\phi}\right].

Specifically, in the baseline Competitive Equilibrium (CE) case, we define the conditional welfare:
W^b_t = W^{Cb}_t+W^{Nb}_t,
in which
W^{Cb}_t = \displaystyle \mathbb{E}_t\sum^{\infty}_{j=0}\beta^j\frac{{C^b_{t+j}}^{1-\sigma}}{1-\sigma}, and W^{Nb}_t = \displaystyle -\mathbb{E}_t\sum^{\infty}_{j=0}\beta^j\chi \frac{{N^b_{t+j}}^{1+\phi}}{1+\phi},
where C^b_{t+j} and N^b_{t+j}, for j = 0,1,\dots, are consumption and labour sequences when the economy achieves the CE.

Similarly, W^{Ca}_t and W^{Na}_t are the partial conditional welfare when the economy is in an alternative policy regime.

So at the outset of t:
\displaystyle W^b_t = \mathbb{E}_t \sum_{j=0}^{\infty} \beta^j \left[ \frac{\left(\left(1+\Delta^{con}\right)C^a_{t+j}\right)^{1-\sigma}}{1-\sigma} - \chi \frac{{N^a_{t+j}}^{1+\phi}}{1+\phi} \right].
Work out \Delta^{con} implicitly:
\displaystyle \Delta^{con} = \left[ \frac{W^b_t-W^{Na}_t}{W_t^{Ca}}\right]^{\frac{1}{1-\sigma}}-1.

Now my question is how to compute W^{Ca}_t and W_t^{Na} in a Ramsey context?

First, we know W^b_t under the CE can be derived by

Then according to the new functionality in Dynare 4.7:

If the alternative policy is a Ramsey type, by evaluate_planner_objective, we know W^a_t.

But how to split this value into two parts, W^{Ca}_t and W_t^{Na}?



  1. I guess you want to have conditional welfare at the deterministic steady state.
  2. Have you tried to explicitly define W_t^{Na} in the Ramsey model, i.e.
    W_t^{Na}=\chi \frac{\left(N_t^b\right)^{1+\phi}}{1+\phi}+\beta E_t W_{t+1}^{Na}
    That should allow you to back out W_t^{Ca} given the W_t^{a} provided.

Thank you for the reply!

Yes, I need conditional welfare in both the baseline and the alternative regime.

For the baseline, the Competitive Equilibrium (CE) scenario, it is indeed perturbed around its deterministic steady state, the concept that is also recently discussed in the thread:

For the Ramsey case, I’m not sure whether the economy is approximated around the Ramsey steady state or somewhere else, after all I don’t see Dynare’s report about this sort of steady state.

But this seems to be not important. Suppose Dynare can compute the true conditional welfare of the Ramsey. Then the merit of partial welfare is that it allows the Ramsey case and the CE case to be compared at the same initial point, probably CE’s deterministic steady state, if I understand the following equality correctly:

Anyway, I saw this expression almost everywhere, for example, in

Yet, his derivation is the same as the above JEDC paper, but the numerical part is not quite clear.

The authers compute the welfare in an optimal simple rules.

So it’ll be rather interesting to extend this approach in a Ramsey setting!


My conditional welfare under the CE: -155.6874
My conditional welfare under the Ramsey (one instrument R_t):

    - with initial Lagrange multipliers set to 0: -163.13101105
    - with initial Lagrange multipliers set to steady state: -155.35499773

They look reasonable.

However, Dynare also reports the unconditional welfare:

Approximated value of unconditional welfare:  830037293448262400.00000000

That’s so ridiculous!

I set

Utility = C^(1-SIGMA)/(1-SIGMA)-CHI*N^(1+PHI)/(1+PHI);

WelfC = C^(1-SIGMA)/(1-SIGMA) + BETA*WelfC(1);

%WelfN = - CHI*N^(1+PHI)/(1+PHI)+ BETA*WelfN(1);

Because set both WelfC and WelfN may cause some singularity problem as well, my strategy is exactly yours:

Next, my conditional welfare under the Ramsey (two instruments):

Error using print_info (line 32)
Blanchard & Kahn conditions are not satisfied: no stable equilibrium.

Both one instrument and two-instrument versions of the Ramsey (without WelfC or WelfN) are comfortably executed in Dynare 4.6.1 and 4.6.4

So even including only WelfC may cause some internal problem in Dynare.

Can you provide me with the codes?

  1. The BK violation comes from differences in the computed steady states. They may not be unique.
  2. It turns out you cannot have additive parts of the welfare function in the model as they will introduce a singularity. The big number you encounter comes from Dynare replacing the resulting NaN with a large number. 4.7 should have a warning in that case. Now to the workaround. What you can do is have the components of utility as variables in the model:
% WelfareC
UC = C^(1-SIGMA)/(1-SIGMA);

UN = -CHI*N^(1+PHI)/(1+PHI);

and then manually compute the decomposition based on the codes in evaluate_planner_objective after running the model. Here, it would be

%% housekeeping to have access to relevant info
if isempty(options_.qz_criterium)
    options_.qz_criterium = 1+1e-6;
dr = oo_.dr;
exo_nbr = M_.exo_nbr;
nstatic = M_.nstatic;
nspred = M_.nspred;
beta = get_optimal_policy_discount_factor(M_.params, M_.param_names);

%% Original objective
[U,Uy,Uyy] = feval([M_.fname '.objective.static'],ys,zeros(1,exo_nbr), M_.params);
%% override original objective and instead read out UC (or UN if desired); needs to be defined in model-block
U=ys(UC_pos); %get steady statee
Uy(UC_pos)=1; %first derivative is 1 for defined variable, zero for all others
Uyy=sparse(zeros(size(Uyy))); %all second derivatives are zero

Gy = dr.ghx(nstatic+(1:nspred),:);
Gu = dr.ghu(nstatic+(1:nspred),:);
Gyy = dr.ghxx(nstatic+(1:nspred),:);
Gyu = dr.ghxu(nstatic+(1:nspred),:);
Guu = dr.ghuu(nstatic+(1:nspred),:);
Gss = dr.ghs2(nstatic+(1:nspred),:);

gy(dr.order_var,:) = dr.ghx;
gu(dr.order_var,:) = dr.ghu;
gyy(dr.order_var,:) = dr.ghxx;
gyu(dr.order_var,:) = dr.ghxu;
guu(dr.order_var,:) = dr.ghuu;
gss(dr.order_var,:) = dr.ghs2;

Uyy = full(Uyy);

Uyygygy = A_times_B_kronecker_C(Uyy,gy,gy);
Uyygugu = A_times_B_kronecker_C(Uyy,gu,gu);
Uyygugy = A_times_B_kronecker_C(Uyy,gu,gy);

%% Unconditional welfare


oo_.mean(isnan(oo_.mean)) = options_.huge_number;
oo_.var(isnan(oo_.var)) = options_.huge_number;

Ey = oo_.mean;
Eyhat = Ey - ys(dr.order_var(nstatic+(1:nspred)));

Eyhatyhat = oo_.var(:);
Euu = M_.Sigma_e(:);

EU = U + Uy*gy*Eyhat + 0.5*((Uyygygy + Uy*gyy)*Eyhatyhat + (Uyygugu + Uy*guu)*Euu + Uy*gss);
EW = EU/(1-beta);

1 Like

Yes, posting your comments and modified codes in the forum will benefit other users. :+1:

Please give me some days to digest them. After that, I may ask questions related with the welfare comparison between OSR and Ramsey, since I still feel some problem in the conditional welfare reported by Dynare 4.7. This problem does not occur in previous versions. Be patient. Thank you!