# Quadratic welfare loss

Dear Dynare users,
I have derived a quadratic loss function of a sligthly complicated model. I want to be sure that my algebra is correct: I have written a Dynare code to simulate the model and verify that, up to a second order, the following objects are identical:

``````W=logC-1/(1+phi)*N^(1+phi)+beta*W(1);               % Welfare
W_appr=-(y^2 + eps/lambda*pi^2 + G)+beta*W_appr(1);   % Quadratic welfare that I have derived
``````

where G is a linear function of other quadratic terms. I have simulated the model, but up to a second order, the IRF of W and W_appr are slightly different. Up to a 1st order, the IRF are identical.

In order to be sure that this is the correct approach, I have also written a code (which I attach) in order to simulate the Galiâ€™s textbook NK model. Again, the IRF of welfare and approximated welfare are slightly different at the second order. Notice that, compared to Galiâ€™s quadratic welfare, I have also included terms independent from policy: these terms are of course necessary to compare W and W_appr.

My question is: is this the right approach to verify in Dynare whether a quadratic welfare loss derived by hand is correct? Becuase, either this is not the correct approach, but then I really would like to understand why. Or this is the right approach but my code is wrong (maybe it is wrong the non-linear Calvo Block. Or maybe I have made some mistakes when I have included terms independent from policy in the welfare function).

Thank you so much,

Valerionk.mod (3.8 KB)

1 Like

At second order, the two should be identical. Is there a reason you approximate the objective manually?

Yes, I approximate it manually becuase I want to know the exact formula of the several coefficients of the welfare loss. In this way I can better interpret the role of every single friction in the model. But I also would like to know if my algerba is correct. So, if I have understood correctly your answer, my approach is correct: if the two objects are different it means that I made some mistakes, even in the basic textbook framework.

You might find https://github.com/JohannesPfeifer/DSGE_mod/tree/master/Born_Pfeifer_2018/Welfare helpful as it implements the nonlinear objective underlying the results of Galiâ€™s textbook results derived from a quadratic function.

Thank you Johannes,
I have used your code to check if my non-linear Calvo block is correct. However, still I am puzzled because up to 2nd order the following two variables are different (and they are supposed to be equal):

``````Welf=log(C)-N^(1+phi)/(1+phi)+betta * Welf(+1);
Welf_gali=Uss-(1+phi)/2 * y^2 +a - epsilon_p/(2*lambda)*pi^2+betta * Welf_gali(+1);
``````

where Uss is utility in steady state.

I have figured out that the problem is the behavior of log price dispersion, variable s in my code. According to Galiâ€™s and Woodfordâ€™s books, up to 2nd order log price dispersion should be:

``````s2=epsilon_p/(lambda * 2)*pi^2;
``````

However, in my model â€śsâ€ť (log price dispersion) and â€śs2â€ť (defined above) are two different objects.

Indeed, if I write my quadratic welfare loss as:

``````Welf_appr=Uss-(1+phi)/2*y^2 +a -s                       +betta * Welf_appr(+1);
``````

then â€śWelf_apprâ€ť and â€śWelfâ€ť are exactly the same object, up to a 2nd order.

Still, I donâ€™t understand why the standard relation between price dispertion and inflation does not hold here.

I attach my code, let me know if you have any idea about this problem.

Thank you so much,

Valerio

nk2.mod (4.6 KB)

Thatâ€™s hard to tell without going through the full derivation. Have you checked e.g. the Lombardo/Vestin (2008) paper? I found the ECB working paper version quite helpful.

That paper helps, thank you. The problem was that price dispersion is not equal to:

epsilon_p/(lambda * 2)*pi^2

It is the discounted sum of price dispersion equal to the discounted sum of the previous expression.

Thank you very much for the suggestion. Now it works.