Steady State File

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

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:

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.
rbc_steadystate.m (1.66 KB)
rbc.mod (1.47 KB)

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

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.

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:

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]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,:slight_smile: ‘;’ ])
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

[/code]

Thanks

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.
  1. You replace the loop

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

NumberOfEndogenousVariables = ; % Number of endogenous variables. ys = zeros(M_.endo_nbr,1); % Initialization of ys (steady state).
so that ys is set to 0

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 ?

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 sites.google.com/site/pfeiferecon/Pfeifer_2013_Observation_Equations.pdf.

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).

This is behavior that should not happen. Do you have an example?

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 !

Residuals smaller than

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.

Ok, thank you very much !

Dear all,

I followed what the sesser files and also the NK_baseline_seadystate.m do but I keep having the same error message:

" Warning: Some of the parameters have no value (Phss, Nss, Css, Wrss, Rkrss, Kss, Atwoss, Aoness, Yss, Qss, EXss,
Mss, Iss, vss, MCss) when using steady. If these parameters are not initialized in a steadystate file or a
steady_state_model-block, Dynare may not be able to solve the model…
Error using thesis_steadystate
Too many input arguments.

Error in evaluate_steady_state_file (line 49)
[ys,params1,check] = h_steadystate(ys_init, exo_ss,M,options);

Error in evaluate_steady_state (line 210)
[ys,params,info] = evaluate_steady_state_file(ys_init,exo_ss,M, options,steadystate_check_flag);

Error in steady_ (line 55)
[steady_state,params,info] = evaluate_steady_state(oo_.steady_state,M_,options_,oo_,~options_.steadystate.nocheck);

Error in steady (line 80)
[oo_.steady_state,M_.params,info] = steady_(M_,options_,oo_);

Error in thesis.driver (line 444)
steady;

Error in dynare (line 293)
evalin(‘base’,[fname ‘.driver’]) ; "

I have no idea where the problem comes from.

I computed the steady state myself following what the NK_baseline files do. I am using a log-linearized small open economy model.
I attach my codes hoping that someone can maybe help me with this.
Thank you all !

thesis_steadystate.m (4.4 KB) thesis.mod (6.6 KB)

Hi Dudy,

when you click your way through your steady-state file with f9 in Matlab you will see that there is a problem with the fzero command in line 76, i.e. you did not declare any options for the optimizer. If you just delete the options part the code works, or define options that you want to have.
But then it seems that there is a mistake in the steady state that you computed, as the residual in equation 12 is -6. Hence, the steady-state file does not compute the actual steady state. You should further investigate this.

Hi DoubleBass,

Thank you for spotting that !! But the thing is that even without it (I took it off the equation) I still get the same error message… I dont understand how this can work for you but not for me :confused:

That is weird. What version of Dynare and Matlab are you on?
Please find your steady-state file attached that worked for me, I did not change anything but the options command I told you about.
thesis_steadystate.m (4.4 KB)

I use Matlab R2018b and Dynare 4.6.1. I checked your file and we both have the same. Yours doesnt work either.

Hm, then I don’t know. I have the same Matlab version but Dynare version 4.5.7. Maybe something was changed between the two, but I am not an expert on those things, sorry.
Maybe somebody else can clarify why this is the case.

Does it maybe work if you include the options again and define them above with something like:
options = optimset(‘Display’,‘Final’,‘TolX’,1e-10,‘TolFun’,1e-10); ?

I tried to include this but it still doesn’t work. It might have to do with the Dynare version. Thanks a lot for trying !!!