# Problem about welfare loss value

Dear all，

I built a DSGE model to compare the effects of several monetary policies.
The welfare loss function is in the form of Woodford (2003) and Galí and Monacelli（2005）. I would like to ask how to calculate the welfare loss value？How to write dynare command and who can give me an example?

I actually had to do the same recently.
You can get the welfare loss by running the model for a certain monetary policy and
then write your definition of the welfare loss in the command window. Instead of writing “pi^2” or “x^2”, you simply write oo_.var(i,i) where “i” is number of the variable (check in which order you have declared your endogenous variables in the modfile to determine “i” for "pi and “x”).

Alternatively, you can just write the equation for the welfare loss in the m.file (without semicolon at the end).

Mburr，thank you for your reply. I just don’t know how to write dynare command. Can you give me an example?

it’s something I would like to learn as well. hence I am here replying

Let’s say that you have declared these variables in the following order in your model:

“var y x pi c k”

Now, because “x” is the second declared variable, Dynare automatically save the variance of this variable (after running the model) as “oo_.var(2,2)”. Simiarly, the variance of “pi” will then be saved as “oo._var(3,3)” - because it’s the third declared variable.

Now you can write your welfare loss function in your command window (or in the m.file):

"- (1- alpha)/2beta ( epsilon/lambda * oo_.var(3,3) + (1+ phi)*oo_.var(2,2) ) "

In this way you can find a discrete welfare loss.

1 Like

In this forum，I saw this link.https://github.com/JohannesPfeifer/DSGE_mod/blob/master/Gali_2015/Gali_2015_chapter_4.mod
It should be the welfare loss function written by professor Pfeifer. I have some difficulty in understanding what these dynare code mean.
I would like to ask if the result is consistent with your method？If so，I will try your method.

The two approaches should generate the same results. The difference is that my code is robust to the typical user mistakes that can happen if one is not careful.
The essential components are:

1. Reading out the required parameters via
``````        par.theta=M_.params(strmatch('theta',M_.param_names,'exact'));
``````
1. Getting the required variances via
``````     pi_pos=strmatch('pi',var_list_ ,'exact');
variance.pi=oo_.var(pi_pos,pi_pos);
``````
1. Computing the loss function based on these objects:
``````        L=0.5*((par.siggma+(par.varphi+par.alppha)/(1-par.alppha))*variance.y_gap+par.epsilon/par.lambda*variance.pi)/100;
``````
2 Likes

jpfeifer，thank you. I will try to understand and apply the dynare code.