Issue with consumption equivalent

Hello everyone,

I am currently trying to calculate the consumption equivalent in order to rank my Ramsey policy against the decentralized benchmark solution.

I took the inspiration from the files proposed in this thread (Consumption Equivalence_Welfare analysis - #8 by mikegouv) about the consumption equivalent.
If I understood correctly, the proposed approach is to find the level of consumption (ξ) that is the zero of the difference between the recursive welfare function of the benchmark and the one of the alternative policy.

I created the two attached mod files (benchmark and alternative policy with ξ (called lambda_utility) in the utility function and hence in the recursive welfare ) and a loop file meant to find the value of ξ that is the zero of the difference of the two welfares. Yet, the values of the welfare functions I get in return (for different values of ξ) seems to be always equal, while I would expect them to change at every iteration, since the welfare equation does not participate to the dynamics of the model,since it is supposed to run always with the same variables, but whith different ξ.

Could you please help me undestrand if there is some mistake in the files of wheter if I am missing something conceptually?

Thank you very much for the help,
have a nice day

loop_ce.m (605 Bytes)
market_economy_benchmark.mod (6.1 KB)
ramsey_policy.mod (6.8 KB)

Why are you focusing on the IRF of welfare, which always substracts the steady state. Also, doing a grid search is wildly inefficient. Try the approach used in

dynare market_economy_benchmark;
target = oo_.mean(1);

dynare ramsey_policy;

get_consumption_equivalent.m (318 Bytes)
ramsey_policy.mod (6.8 KB)
market_economy_benchmark.mod (6.1 KB)

Dear Professor,

thank you very much, this was very useful. I solved my issue.

In your opinion, what was I doing wrong in my procedure?

Thanks again,
Have a nice weekend!

As mentioned above, you did not use the level of welfare, but rather its response to an IRF. That’s the wrong object.

@jpfeifer shouldn’t the mod files be using a 2nd order approximation?

Generally, the answer is yes.

1 Like

Could you please tell me how to initialize the value of lambda_utility?

Many thanks for your time and guidance.

Dear @jpfeifer

When following this approach

dynare market_economy_benchmark;
target = oo_.mean(1);

dynare ramsey_policy;

I get an error “evaluate_planner_objective: encountered NaN moments in the endogenous variables often associated
evaluate_planner_objective: with either non-stationary variables or singularity due e.g. including
evaluate_planner_objective: the planner objective function (or additive parts of it) in the model.
evaluate_planner_objective: I will replace the NaN with a large number, but tread carefully,
evaluate_planner_objective: check your model, and watch out for strange results.”

Is it because we cannot define Recursive Welfare for Ramsey as in Two m files and two mod files - #22 by jpfeifer

Please guide me on how to compute consumption equivalent while using Ramsey as the benchmark

I would need to see the files.

It seems the cause is a unit root in the model. That would explain the NaN.

Is it because the ramsey_policy file defines Recursive_welfare1 and then updates the value of lambda_utility in order to maximize Recursive_welfare1 in the get_consumption_equivalent.m file?

Could you please suggest an alternative way of computing consumption equivalent with Ramsey as benchmark in Dynare? This seems to be very standard in the literature.

I am not sure I understand. In a first step, you should be able to compute the Ramsey welfare using evaluate_planner_objective. In a second step, you should be able to use that value to compute the consumption equivalent in a different mod-file relative to Ramsey. You cannot do this in one mod-file.

You would need to use the approach at

With a specific example, I could assist you in porting the code to Dynare 6.

Thank you Prof. Pfeifer, I was sending a reply at OSR and Ramsey Welfare Comparison where in I had mentioned the same link.

Following Questions on Ramsey welfare in Dynare 4.7 - #7 by jpfeifer in Dynare 5.2 I was able to compute unconditional welfare for each agent. However, I do not know how to compute conditional welfare for each agent. Please advise on the next steps.

You can follow the respective part of evalute_planner_objective:

        %% Conditional welfare starting from the non-stochastic steady-state (i) with Lagrange multipliers set to their steady-state value (ii) with Lagrange multipliers set to 0
        Wbar = U/(1-beta);
        Wy = Uy*gy/(eye(nspred)-beta*Gy);
        Wu = Uy*gu + beta*Wy*Gu;

        if isempty(options_.qz_criterium)
            options_.qz_criterium = 1+1e-6;
        %solve Lyapunuv equation Wyy=gy'*Uyy*gy+Uy*gyy+beta*Wy*Gyy+beta*Gy'Wyy*Gy
        Wyy = reshape(lyapunov_symm(sqrt(beta)*Gy',reshape(Uyygygy + Uy*gyy + beta*Wy*Gyy,nspred,nspred),options_.lyapunov_fixed_point_tol,options_.qz_criterium,options_.lyapunov_complex_threshold, 3, options_.debug),1,nspred*nspred);
        Wyygugu = A_times_B_kronecker_C(Wyy,Gu,Gu);
        Wyygugy = A_times_B_kronecker_C(Wyy,Gu,Gy);
        Wuu = Uyygugu + Uy*guu + beta*(Wyygugu + Wy*Guu);
        Wss = (Uy*gss + beta*(Wy*Gss + Wuu*M_.Sigma_e(:)))/(1-beta);
        Wyu = Uyygugy + Uy*gyu + beta*(Wyygugy + Wy*Gyu);

        [yhat_L_SS,yhat_L_0, u]=get_initial_state(ys,M_,dr,oo_);

        Wyu_yu_L_SS = A_times_B_kronecker_C(Wyu,yhat_L_SS,u);
        Wyy_yy_L_SS = A_times_B_kronecker_C(Wyy,yhat_L_SS,yhat_L_SS);
        Wuu_uu_L_SS = A_times_B_kronecker_C(Wuu,u,u);
        W_L_SS = Wbar+Wy*yhat_L_SS+Wu*u+Wyu_yu_L_SS+0.5*(Wss+Wyy_yy_L_SS+Wuu_uu_L_SS);

        Wyu_yu_L_0 = A_times_B_kronecker_C(Wyu,yhat_L_0,u);
        Wyy_yy_L_0 = A_times_B_kronecker_C(Wyy,yhat_L_0,yhat_L_0);
        Wuu_uu_L_0 = A_times_B_kronecker_C(Wuu,u,u);
        W_L_0 = Wbar+Wy*yhat_L_0+Wu*u+Wyu_yu_L_0+0.5*(Wss+Wyy_yy_L_0+Wuu_uu_L_0);

        planner_objective_value.conditional.steady_initial_multiplier = W_L_SS;
        planner_objective_value.conditional.zero_initial_multiplier = W_L_0;

Thank you so much Prof Pfeifer!

I used the above code to compare OSR with a calibrated model.

dynare market_economy_benchmark;
target = oo_.mean(1);

dynare ramsey_policy;

The code works well for most cases. However, for a particular shock,I get the following error:
Error using print_info (line 32)
The Jacobian matrix evaluated at the steady state contains elements that are not real or are infinite.
Error in stoch_simul (line 120)
print_info(info, options_.noprint, options_);
Error in get_consumption_equivalent (line 5)
[info, oo_] = stoch_simul(M_, options_, oo_, {‘W’});
Error in @(chi)get_consumption_equivalent_r(chi,target_W,M_,options_,oo_)

Error in trustnleqn (line 210)
F = feval(funfcn{3},reshape(xTrial,sizes.xShape),varargin{:});
Error in fsolve (line 421)

This shock leads to higher variances (ex variance of inflation in this model is 0.02 as compared to 0.0001 or even lower for other shocks).

Is it because the persistence parameter for this shock is 0.9 and it is causing an eigenvalue close to 1? How can I do welfare comparison in this case?

(Please note that I have used stoch_simul(order=2,irf = 0) as simulations are not required for computing welfare cost of business cycle as I was getting a Warning: Aggregate variance and sum of variances by shocks differ by more than 0.01 %)

I could run the code by redefining chi on the calibrated model and using the other as target. I get a large value of chi =-0.9 indicating that the calibrated model is much worse.