Second order approximation and the IRF explosive


#55

Prof. Jpfeifer,

I understand that. My question is: is the mean of my defined welfare function the mean of the approximated theoretical moments? If not, it is the mean of the empirical moments based on simulation?


#56

If you set periods=0, then it’s theoretical moments


#57

Dear Prof. Jpferifer,

I have replace the code in welfare_objective.m with the conditional welfare codes at https://github.com/JohannesPfeifer/DSGE_mod/blob/master/Born_Pfeifer_2018/Welfare/get_consumption_equivalent_conditional_welfare.m. Now my code can run well.

However, there seems to be some problems. The code seems to just simulate 1 time, rather than 1000 times as I set in the mod-file. It just runs about 1 second and can show the results. The value stored in “fhat” which represents the welfare value “v” in my case, is very different from the mean of approximated theoretical moments of “v” shown in the command window. And the values of the parameters which I want to optimize, are just the same as the calibrated ones, which seems not to be optimized. Could you please help me check what the problem is and how to fix it?

Thank you very much. Here attached my code. conditional_welfare_objective.m (1.1 KB)
housing.mod (8.5 KB)


#58
  1. I don’t understand why you are trying to simulate here when you just want to obtain a single number
  2. y_sim is a matrix, so you need to select the correct element/column as you simulate more than 1 period for some reason
  3. You cannot use var_list_ with resol. It should be
outvalue=y_sim(strmatch('v',M_.endo_names,'exact'),1); %extract Welfare
  1. You need to find out why a change in your parameters does not affect the conditional welfare measure you are reading out of the model.

#59

Prof. Jpfeifer,

Thanks for your reply.

  1. As your posted code, I set nit = 1000; %Number of iterations in the mod-file. And when I do unconditional welfare computation, it simulates many times. So I think I also need to do a large number of times simulation in the conditional scenario. What I want to do is to find out the the optimal value of rho_r, rho_pi, and rho_y that get the highest welfare value “v”, given a three-dimensional grid of the parameters. And the welfare value is conditional upon the initial state of the economy being the nonstochastic steady state as Schmitt-Grohe & Uribe, 2004. So I need to do the simulation for a large number of times. Could you please help me with it in Dynare?

  2. I think the reason that why a change in the parameters does not affect the conditional welfare measure I am reading out of the model, is because I just simulate 1 time, thus Dynare just use the calibrated parameter value to compute the welfare measure. It indeed does’t do the optimization. But I do use the code “nit = 1000; %Number of iterations” in the mod-file. So I am confused about it.

I am looking forward to your reply. conditional_welfare_objective.m (1.1 KB)
housing.mod (8.5 KB)


#60

You are confusing something. nit=1000 is the upper bound for the Newton steps/iterations for the csminwel-solver. It has nothing to do with the simulation of the model.


#61

Prof. Jpfeifer,

  1. I have set periods=0, and Dynare should report the theoretical moments. However, the “fhat” value is different from the mean of approximated theoretical moment of the welfare variable “v” in my case. Why is it?

  2. Could you please explain me with outvalue=y_sim(strmatch('v',M_.endo_names,'exact'),1); %extract Welfare ? What does “1” mean here? When I change it to 2, the results are different. Also in the code shock_matrix = zeros(5,M_.exo_nbr); %create shock matrix with number of time periods in columns. I input “5” here because there are 5 shocks in my model. Am I right?

Thank you very much! conditional_welfare_objective.m (1.1 KB)
housing.mod (8.5 KB)


#62
  1. Because now you are looking at conditional welfare, while the theoretical mean of v is the unconditional one
  2. the M_.exo_nbr is the number of shocks. The point where you put the 5 is the number of time periods for the simulation, which you should have left at 1.

#63

Prof. Jpfeifer,

Thanks for your reply. It’s really helpful. Now I understand that the theoretical mean of v is the unconditional one, however, I also want to know whether the empirical mean of v is the conditional one?

Moreover, where can I find the moments of other variables when the welfare variable “v” is maximized?


#64
  1. How do you define the “empirical mean”? The conditional welfare measure is evaluated when all variables are in steady state today.
  2. For the other variables, you need to run stoch_simul again after you have found the optimal policy rule parameters with those parameter values.

#65

Prof. Jpfeifer,

Thanks for your reply. I notice some small points.

  1. In your code about computation of conditional welfare, it is written as
    Recursive_natural_welfare_equivalent=y_sim(strmatch(‘Recursive_natural_welfare_equivalent’,M_.endo_names,‘exact’),2);

    But you post that my code should be
    outvalue=y_sim(strmatch(‘v’,M_.endo_names,‘exact’),1); %extract Welfare

    What’s the difference between the figure 2 and 1? I think it is the dimensional scalar of the matrix y_sim. If I am right, why should I put 1 but you put 2?

  2. Also, you replied that the M_.exo_nbr is the number of shocks. The point where you put the 5 is the number of time periods for the simulation, which you should have left at 1. However, in your conditional welfare code of “Born_Pfeifer_2018”, it is shock_matrix = zeros(2,M_.exo_nbr); %create shock matrix with number of time periods in columns. Why should I put 1 but you put 2?

  3. In the code of unconditional welfare, you posted
    outvalue=-oo_.mean(strmatch(‘v’,var_list_,‘exact’)); %extract Welfare

    However, in the code of conditional welfare, there is NO negative sign in front of y_sim(strmatch(‘v’,M_.endo_names,‘exact’),1); %extract Welfare

    I think that because csminwel runs a minimizer algorithm, but I want to maximize the welfare, so I should put a negative sign in front of y_sim(strmatch(‘v’,M_.endo_names,‘exact’),1); %extract Welfare. Am I right?

here attached both the codes of unconditional and conditional welfare, and the mod-file.welfare_objective.m (713 Bytes)
housing.mod (8.5 KB)
conditional_welfare_objective.m (1.1 KB)


#66
  1. You are right. You should use 2. The reason is simult_ is returning the initial condition in the first column, so the first simulated point you want to read out is 2.
  2. I corrected the comment and the line in the file. It should be
    shock_matrix = zeros(1,M_.exo_nbr); %create shock matrix with number of time periods in rows
  3. Yes, you are using minimizers, so there should be a minus sign.