Page 1 of 1

Steady State File

PostPosted: Mon Jun 20, 2016 6:16 pm
by sp1589
Hello,

I have a few questions regarding the steady state file.

So, I have a loglinearized model with steady state expressions obviously entering the linearized equations. I have written a script using fsolve to find the steady state variables in my system, which I then manually input into my dynare file. I have a bunch of robustness checks that I have to implement and I want to automate this process by writing a steady state file. I am slightly confused however how this is supposed to work. I saw the nk_model example in the dynare folder, but I am still not clear on how I should implement this. I essentially only changed the model specific part of that file, however I think I am not completely understanding how this file is supposed to work.

What I want to do is simple. I have to pin down 7 variables from a system of 7 equations. Right now, I have a separate script that does this, but I want to automate that by creating a steady state file that dynare can read. Is there a sample code that does this (even simpler than the NK_model steady state example.) For some reason, I cannot replicate that code using my model specifics.

Thank you

Re: Steady State File

PostPosted: Tue Jun 21, 2016 11:20 am
by sesser
Attached you will find a log-linearized version of a standard RBC model with a corresponding steady state file. Note that the code snippet in the Matlab file where the steady state values are passed to your mod file needs to be slightly adjusted:

Code: Select all
NumberOfEndogenousVariables = M_.endo_nbr;                    % Number of endogenous variables.
ys = zeros(NumberOfEndogenousVariables,1);                    % Initialization of ys (steady state).
for i = 1:NumberOfEndogenousVariables                         % Loop...
  %varname = deblank(M_.endo_names(i,:));                      %    Get the name of endogenous variable i.                     
  %eval(['ys(' int2str(i) ') = ' varname ';']);
  ys(i)=0;%    Get the steady state value of this variable.
end     


Within your steady state file, you can also employ Matlab's fsolve and call your external file which computes your steady state variables.

Re: Steady State File

PostPosted: Wed Jun 22, 2016 12:17 am
by AbrahamVela
Hi:

I think it is posible to do what you want (I think I have seen it in some codes, unfortunately I do not remember which ones), as exemplified by "sesser".
I am not pretending to be rude, but I must ask why you want to do that!
The steady state file is automatically created by Dynare and it reports the steady state values after doing that.
And those values are the ones Dynare uses in the rest of your exercise.
Perhaps I misunderstood your question.
Good luck.
Abe

Re: Steady State File

PostPosted: Wed Jun 22, 2016 6:17 am
by jpfeifer
I also do not understand what you mean. The NK_baseline_steady_state.m provides you with the necessary structure in the header and footer and indicates where you can put your own equations. You simply have to modify these equations in between to your liking. There is no example for this, because it is model-specific.

Re: Steady State File

PostPosted: Thu Jun 23, 2016 3:58 pm
by sp1589
Thank you for all of your replies. To be more specific, do I have to make any changes to the header and the footer when creating my steady state file or the way they have been written (as provided for instance in the NK_baseline_steadystate file) provide the general structure necessary for the mod file to read the steady state values provided in the model specific block. I am asking this because I get an error in the last line of the footer:


Code: Select all
eval(['ys(' int2str(ii) ') = ' varname ';']);


I am not quite sure why the endogenous variables in my model cannot be read. Here is a simple example code at what I am doing. Assume these are all of the steady state values in my model. Given this, should something in this code be modified in order for this to run?

Code: Select all
function [ys,check] = sep_steadystate(ys,exo)
global M_
NumberOfParameters = M_.param_nbr;
for ii = 1:NumberOfParameters
  paramname = deblank(M_.param_names(ii,:));
  eval([ paramname ' = M_.params(' int2str(ii) ');']);
end
% initialize indicator
check = 0;
%Model Specific Block
Iss=0.267;
Xss=0.194;
mcss=1.312;
lambda_I_C=0.42;
Yss=0.915;
wss=3.215;
Css=0.64;

% End of the steady state model block


for iter = 1:length(M_.params) %update parameters set in the file
  eval([ 'M_.params(' num2str(iter) ') = ' M_.param_names(iter,:) ';' ])
end

NumberOfEndogenousVariables = M_.orig_endo_nbr; %auxiliary variables are set automatically
for ii = 1:NumberOfEndogenousVariables
  varname = deblank(M_.endo_names(ii,:));
  eval(['ys(' int2str(ii) ') = ' varname ';']);
end



Thanks

Re: Steady State File

PostPosted: Thu Jun 23, 2016 7:00 pm
by jpfeifer
Even if you use a log-linearized model the footer of the steady_state-file assumes that all endogenous variables have been set. Therefore, you have two choices.
1. You set each variable to 0 in the file, e.g.
Code: Select all
yhat=0

2. You replace the loop
Code: Select all
NumberOfEndogenousVariables = M_.orig_endo_nbr; %auxiliary variables are set automatically
for ii = 1:NumberOfEndogenousVariables
  varname = deblank(M_.endo_names(ii,:));
  eval(['ys(' int2str(ii) ') = ' varname ';']);
end

by
Code: Select all
NumberOfEndogenousVariables = ;                    % Number of endogenous variables.
ys = zeros(M_.endo_nbr,1);                    % Initialization of ys (steady state).

so that
Code: Select all
ys
is set to 0

Re: Steady State File

PostPosted: Fri Jun 24, 2016 8:25 am
by dynare16
Hi,

there is also something that I don't understand about the steady state file. In Dynare manual, the steady state file is presented as an alternative to solving the model with an external Maple file by solving the model directly into Matlab. However, because all equations have to be input sequentially, with all endogenous variables being defined as functions of parameters and already known endogenous variables at their steady state, it seems to me that using a steady state file exactly amounts to solving for the steady state by hand, right ?

Re: Steady State File

PostPosted: Fri Jun 24, 2016 4:01 pm
by jpfeifer
Not exactly, although this is the most common application. Often the model can be boiled down to a small set of equations that can be solved by a solver (as in the NK_baseline.mod). Once this is done, you can easily compute everything else. The alternative is just solving the steady state by brute force, i.e. trying a solver on all equations simultaneously, which is what Dynare tries by default when there is no steady state file or steady_state_model-block. See Remark 15 (initval vs. steady_state_model vs. steadystate-file)
in Pfeifer(2013): "A Guide to Specifying Observation Equations for the Estimation of DSGE Models" at https://sites.google.com/site/pfeiferecon/Pfeifer_2013_Observation_Equations.pdf.

Re: Steady State File

PostPosted: Sun Jun 26, 2016 7:22 am
by dynare16
Thank you for your answer.

When Dynare -by default- solves for the steady state directly with a non-linear solver and the residuals are not zero in some of the equations when checking with the resid command, this means that Dynare fails to find the steady state, right ? (even if the model runs anyway and no warning message appears).

Re: Steady State File

PostPosted: Sun Jun 26, 2016 6:24 pm
by jpfeifer
This is behavior that should not happen. Do you have an example?

Re: Steady State File

PostPosted: Mon Jun 27, 2016 9:18 am
by dynare16
Here is an example. Residuals are small but still. I encountered cases in which there were residuals for almost all equations and it was still running. Is it simply that when residuals are small, it is ok ?

Thanks a lot !

Re: Steady State File

PostPosted: Mon Jun 27, 2016 9:59 am
by jpfeifer
Residuals smaller than
Code: Select all
options_.dynatol.f

are taken as 0. That criterion is usually 1e-5. Anything bigger should result in an error. If you encounter bigger residuals and this still happens in the current unstable version, please report this.

Re: Steady State File

PostPosted: Mon Jun 27, 2016 11:24 am
by dynare16
Ok, thank you very much !