Problems with welfare analysisi based on Dynare

I’m trying to do some welfare analysis and compare different policy regimes based on second-order approximation of a nonlinear model with habit formation. I define a welfare variable as
my question is what is the impulse response of Wel_t mean for the welfare analysis? Does the time-1 impulse response represents the welfare gain or loss?

I’m also very curious why acorrding to my simulation less flucutuation in output and consumption seems to lead to lower unconditional and conditional welfare and here is my mod file.
model_baseline_pinstr.mod (15.6 KB)

You did not provide the parameter file.

I’m so sorry and here are the parameter file, the file calculating the deterministic steady state and the main programs.
main_pinstr2.m (3.7 KB)
param.mat (3.6 KB)
param_ss.m (6.1 KB)

Dear all, I have another probelm. I tried to calculate the unconditional and conditional welfare based on the second order approximation using Dynare 5.4, but the results seems to be very unsmooth when I change the policy parameters, and I’m not sure what’s the problem. Thank you very much!

Please provide the most recent file.

So sorry and please see the zip file below, run main_dydel.m and it will do both first-order and second-order approximation and calculate the welfare effect. Thank you again for your patience! (15.4 KB)

This seems to be a problem with the steady state computation tolerance that introduces numerical inaccuracies. I increased the tolerance a bit and sped up the loop:
model_wel_dydel.mod (15.6 KB)
main_dydel.m (6.3 KB)

My matlab says “ERROR: model_wel_dydel.mod: line 364, cols 8-11: syntax error, unexpected TOLX”. Why does this happen? I’m using dynare 5.4

Please upgrade to Dynare 6.

That works! Thank you very much!