Getting Results from DYNARE in an iterative procedure when steady state is approximate


#1

Dear all,

I am wondering if it is possible to obtain results from dynare even when the steady state is close to the accurate one but not identical exactly. I am trying to find the risky steady state where i iterate on moments. I calculate the steady state in a separate m. file and provide the results to dynare using initval. Then I call DYNARE repeatedly to update covariance matrix.
For the deterministic case there are no issues.

However when I move to risky steady state and update the steady state i get error from dynare saying that some equations have not converged etc… But i am trying to iterate on the moments and I am aware that the initial guesses of steady state may not be 100% accurate. All i need is to get the new covariance matrix.

But during the loop after the initial update of steady state DYNARE runs a a few times and gives me the error that steady state is not defined. And stops. I dont want it to stop, I want DYNARE to just give me the covariance matrix that i can use for my outside steady state file

I am wondering if it is possible to suppress the dynare error about steady state and obtain the covariance matrix then iterate until i find a solution that satisfies both dynare initval solver and my external steady state file solver.

I would really appreciate your help. I am worried that i might need to switch the entire model (around 50 equations) to Schmitt-Grohe package which computes the covariance matrix function for any given steady state without checking if it satisfies the conditions. But this will make the whole notation much much messier

Thanks a lot


#2

I do not understand the details… My impression is that you just have to change the value of the tolerance parameter used by the nonlinear solver (by increasing its value). Look for the tolf option of the steady command in the reference manual.

Best,
Stéphane.


#3

Hello Stéphane,

Thanks for taking your time. Basically my mod file looks like

  1. var;

  2. parameters;

  3. model;

  4. steady_state_model or initval
    here i use an extrernal m file to get the steady states

  5. steady;

  6. stoch_simul

and now i get oo_gamma_y{1,1}

what is important for me is to get oo_gamma_y{1,1} and i use this to go back to the external steady state file.
Then start from step 1

When i get errors it stops but i dont want it to stop

Regards


#4

Did you try to use the nocheck option (same section in the reference manual)?

Best,
Stéphane.


#5

Hello Stéphane,

I did try different combinations. I put the following below while using initval but still did not work

options.solve_tolf=1000;
options4fsolve.TolFun = 1000;
options.solve_tolf=100;
options.dynatol.f=100;
options.solve_tolf=1000;
steady(nocheck);
resid;

Is steady_state_model and initval different in terms of using the steady state convergence functions?


#6

Yes it’s different. If you provide an approximate steady state in the steady_state_model block and use the nocheck option I believe it should do the trick (actually I did not try in this kind of situation). I would not change the tolerance parameters.

Best,
Stéphane.


#7

Hi Stéphane,

Yes you were right, steady_state_model-block with steady(nocheck) works,
also if you remove the steady command completely and just check the resids from equations that also works both with initval and steady_state_block commands.

I think, i might be wrong, that dynare without steady command does the same thing as Schmit Grohes package does

but i hope that i am not doing something wrong by removing the steady block completely. Would this affect the way the covariance matrix is calculated?


#8

I do not know what the package you are referring to is doing. But to solve the local approximation of a model, at some point, you need to compute the point around which you do the approximation. Even if you do not use the steady command, Dynare will first compute the steady state when stoch_simul command is called (using the one provided by the steady state file or block, or using a Newton like algorithm).

If you remove the steady state block or file, Dynare will use a nonlinear solver. But if you do not have the external file for the steady state, I do not understand how you iterate with the covariance (as described in your second message). More generally I still do not understand what is the fixed point you are looking after with this algorithm…

Best,
Stéphane.


#9

Hello Stéphane,

Thanks for the responses. I am stuck so these are very helpful. Sorry for being vague about my description before.

  1. The package I was referring to is
    “Solving Dynamic General Equilibrium Models Using a Second-Order Approximation to the Policy Function,” by Stephanie Schmitt-Grohe and Martin Uribe (JEDC, vol. 28, January 2004, pp. 755-775)

They use symbolic toolbox to calculate the derivatives and once you provide the system a point (whether it is steady state or not) it calculates the impulse responses and second moments etc…

  1. The risky steady state I am referring to is not widely used but the main idea is as
    image

Gertler, Mark, Nobuhiro Kiyotaki, and Albert Queralto. “Financial crises, bank risk exposure and government financial policy.” Journal of Monetary Economics 59 (2012): S17-S34.

Similar method is applied also by

de Groot, Oliver. “Computing the risky steady state of DSGE models.” Economics Letters 120.3 (2013): 566-569.

The basic idea is to find the risky steady state by iterating on moments until they converge. But all these papers I think use the SGU package and i am trying to do this in dynare

  1. Thanks to your suggestions, i was able to resolve the issue of Dynare stopping if it does not have a completely accurate steady state.

I have an external steady state file that computes the steady state and in deterministic setting with steady_state_block i get residiuals in all equations 0. Also with initval letting dynare to find the steady state it still works

  1. But after working on this a bit, I do not think dynare calculates the covariance function (or at least updates it) with steady(nocheck) option

I mean after two iterations, even though my external steady state file produces different steady states as i update them with second moments, the oo_.gamma_y{1,1} matrix remains the same after the second iteration. It is not updated.

I do get small errors in residuals but that is ok, my point is to be constantly receiving an new covariance matrix for each new steady state i provide.

You mentioned that dynare uses a nonlinear solver. Does this mean that even if I provide dynare a steady state (without focusing on whether residuals of equations are all 0s) and want it to give me the results at that point given by my external file, dynare will ignore this and will use its own nonlinear solver?

In other words, lets assume steady state of a variable is 5. But my external file gives the initial value for this as 4.8, will dynare with steady(nocheck) option provide me with a covariance matrix around 4.8 or will it use its solver and go to 5 and give me the oo_.gamma_y{1,1}. I want to get oo_.gamma_y{1,1} at 4.8. That is what confuses me :frowning:

Appreciate your help very much. Just with package programs like dynare many things become so much simpler but certain things remain a black box and i am not that good in going into details of the dynare code, that is why i wanted to ask

PS: In the code, i just changed the steady state value of a variable in steady_state_block to be 10000. I get huge errors in residual function but the oo_.gamma_y{1,1} stays the same

PS2: Is it possible in dynare to completely shut its steady state calculation. Something similar to set_param_value(‘alpha_K’,P.alpha_K ); and setting steady state value of a variable lets say K to be 1000 and not having dynare change this value

Best regards


#10

@MichelJuillard Do you have an example of computing the risky steady state with Dynare?


#11

Thank you for your help.

I am wondering if I am actually doing something wrong since the covariance matrix is not changing. Basically what I do is

1- record parameters in a structure in main m file. And save this structure P. I also use this p structure in dynare to load parameters using set parameter command
2- pass the structure to det_ss file and compute the steady state values externally and save them as a structure as well. Ss1
3- load ss1 to to steady_dynare which gives the steady state values in steady_state_block.
4- run stoch_simul with steady(nocheck) option. Everything is fine until here. Residuals of equations are 0.

Second stage
4- get the covariance matrix and steady state results of dynare as initial values. Save these as structures.
5- load the moments, parameters, dynare steady states to my ss_risky1.m file to compute the new risks steady state.
6- save the new steady state from this file as a structure and load it to steady_dynare.m which basically just takes the variables to dynare format
7- run stoch-simul. Get new moments and go back to 4th step.

This works only once. After the second third iteration steady states change but moments remain same.

This is what confuses me. How can the covariance matrix remain same even though oo_ys or oo_ steady are with different values. I even increase the value of one variable to 1000. Steady state in oo_ys shows me the value of that variable as 1000. But neither the covariance matrix nor the residuals of equation errors change.
I call dYnare each time from my m file. I do not think the usual looping over parameters using resol would work in my case because I need to run stoch simul every time to get oo_gamma_y

Another issue is that when I try this steady_state_block in dynare example3.mod and I change the values of variables in their steady state I get a different covariance matrix :pensive::pensive: it seems to work with simple rbc model but in bigger model with 45 equations it fails. Even if I am doing something wrong I still don’t know how having values of steady state of 1000 and 2 could give me the same covariance matrix and exactly same residual errors of functions.


#12

If it works with example3, but not your code, there must still be a mistake that something is not properly updated. The rule is that you should never loop over all of Dynare, but just the functions you need. In your case, you need to loop over resol followed by

oo_=disp_th_moments(oo_.dr,var_list,M_,options_,oo_);

#13

Here is an old example of computing the risky steady state at order 2: example1_risky_2.mod (776 Bytes)
The risky steady state is computed iteratively while evaluating the derivatives away from the deterministic steady state. Currently, I have doubts about the pertinence of these iterations.


#14

Dear Johannes, Michel and Stéphane,

Thanks for all your help and suggestions. Sorry to reply you a bit late,I had to present the preliminary version of this and took a vacation afterwards.

In principle, what I am trying to do is to get dynare to give me the co-variance matrix (oo_gama) at a point that is not its determinisitc steady state (hence the residual errors of the functions would be non-zero)


The above note is directly from the lecture notes of SUG package. I am curious if dynare can do the same.

To test this, I compared the convariance matrix at different steady states of SGU package and dynare for the debt elastic interest rate model of closing small open economies paper by SGU. SGU provide their codes on their webpage and the dynare codes of the same paper are from Prof.Pfeifer’s page.

As you can see below, for the steady state which is the correct one, without residual errors, for given three variables I get very similar second moments.
However when I arbitrarily change the steady state and compute the new covariance matrix, there are differences.

This might be due to

  1. Dynare, takes the steady state values, checks residual errors (despite using steady(nocheck) ) and if errors are very large then it tries to find a steady state using its own steady state calculator and gives the covariance matriix at that point.
    In the example, in second column i give steady state value of k,1 (correct one is 1.22) and dynare might be trying to find the new steady state and giving the covariance matrix at point lets say 1.1 and not 1 which is the one i assigned

  2. The notation differences between SGU and DYNARE might be influencing the results. But if that is the case, i should see it also in the first column.

Basically I just want to be sure that dynare completely shuts off its own steady state calculator if i use steady(nocheck); command and takes the values for steady state I provide and gives me the covariance matrix at that point.

Thanks a lot for all your help, I really do appreciate it and benefit from it a lot.


#15

Unless there is a bug elsewhere, if I look at the content of evaluate_steady_state_file (which is called by resol for computing the reduced form solution of the model) when nocheck is used Dynare does not even evaluate the residuals of the the static equations. So I am sure that Dynare takes the steady state as it is provided by the user. Without the option, Dynare should raise an error (because there is no attempt to find the steady state with a nonlinear solver).

What is still unclear to me is that if you do the approximation around a point different from the deterministic steady state the reduced form provided by Dynare is wrong (at first order the constant is wrong, at higher order probably the slopes also). So I do not know what SGU does, but this may explain the difference on the moments computed from the reduced form solution.

Best,
Stéphane.


#16

Dear Stéphane,

Thanks for the clarification. Just to make sure I have tried to test Michel’s example1_risky_2.mod file. Below is a snapshot of results and also the files used for getting these results

The files uploaded are

  • example1_risky_2.mod : original risky steady state file
  • determ.mod:exclude options_.risky_steadystate = 1; basically I assume this makes the dynare look for determisitic steady state
  • riskySS.m: external steady state file

I have several questions:

  1. How can the residual errors for both risky steady state mod file and deterministic be all 0? Aren’t these two steads states supposed to be different?

  2. When I give arbitrary steady states, the covariance matrix changes substantially, not only in terms of magnitude but also being positive or negative which is very important to what i am trying to compute

  3. What is the difference between oo_.steady_state and oo_.mean? It seems that dynare calculates the covariance matrix based on oo_.mean because the covariance matrix is very different but oo_.steady_state values are same in second class of example.

determ.mod (755 Bytes)
riskySS.m (370 Bytes)
example1_risky_2.mod (780 Bytes)