Welfare Surface

Dear Dynare users,

I’m trying to do a surface analysis of the loss function of a DSGE model.
I have tried several ways, but I cannot find the solution, I would like to make a graphic similar to the one attached below.
in my case the surface should be made up of the inflation coefficient, the output gap coefficient and the loss function.
I hope you give me some hints.

lfa.mod (13.9 KB)

Hi MrDSGE,

Some tricks:

  1. you need mesh command, but be careful of your order, that is,
    if L(phiP, phiX) is taken from Ls(phiPs, phiXs), then you should type

mesh(phiXs,phiPs,Ls);

instead of

 mesh(phiPs,phiXs,Ls);
  1. The other error dynare reports is BK condition violated, if you temporarily erase noprint in your stoch_simul. You need to quantify your phiP greater than 1. Here I set phiPs to start from 1.1

So I add and modify some codes as follows:

phiPs    = 1.1:0.5:3.1;
phiXs    = 0:0.5:3;
Ls       = -Inf*ones(length(phiPs),length(phiXs));
for ii   = 1:length(phiPs)
    phiP = phiPs(ii);
for jj   = 1:length(phiXs)
    phiX = phiXs(jj);
stoch_simul(order=1, nograph, noprint) 
x y bl piD pi pD p ti er Der i il rR M a g iS pS;

Then I slightly rearrange some parts of your codes, to let Dynare compute moments in each iteration. Your original codes may not work very well for the mission of “looping over parameters”.

Finally, I close the loop and attach figures via:

Ls(ii,jj)=L;
end;
end;

figure(1);
mesh(phiXs,phiPs,Ls);
figure(2);
contourf(phiXs,phiPs,Ls);

Figures look like

lfa_figure1

lfa_figure2

lfa_welfsurf2.mod (13.3 KB)

Enjoy!! :beer: :beer: :beer:

2 Likes

Dear HelloDynare,

I’m very grateful for your explanation. It is just what I was looking for !
I will enjoy writing my paper with these graphics.

Thanks a lot !! :beers: :beers: :beers: