Steady State Error

Dear Prof,

Would appreciate your help in solving Steady State error. I am estimating Mendoza’s Sudden Stop model (attached SS.mod). I have used 2 different external file for estimating the steady state (SS_steadystate.m is one of them and attached too). However, dynare returns steady state related error “Too many input arguments”. Also how can I avoid this problem in the future?

Many thanks.

SS.mod (2.7 KB) SS_steadystate.m (2.5 KB)

The syntax for user-defined steady state files has changed in Dynare 4.6. See https://git.dynare.org/Dynare/dynare/-/wikis/BreakingFeaturesIn4.6
The attached file works in that regard, but fails because you are using endogenous objects in the file before they are used.
NK_baseline_steadystate.m (4.0 KB)

1 Like

Much appreciated prof.
I have amended the external Steady State file based on attachment you provided (attached).However, If I managed to solve for some of the equations and 2-3 equations left out without an analytical steady state solution due to high nonlinearity. Can then dynare solve for the rest of the steady state variables ? If yes, as I see from previous discussions, then how to do it and should I impose initial values for these unsolved variables ? (I am new to dynare so excuse me for repeating myself over the same issue and thanks a million)Mendoza.mod (2.7 KB) Mendoza_steadystate.m (2.3 KB)

I am not sure what your are doing. There are obvious typos in your steady state file. In

lambda(1-Z*R)=mu;

there is a sign missing before the bracket.
Regarding your question: you can call a solver within the steady state file to deal with the remaining nonlinear equations.

Dear Prof.
Thank you for the update. Yes, this a typo and it should be lambda*(1-Z*R)=mu instead. I will go over the SS block again for double check since when tried to solve it using fsolve matlab function it returned complex numbers solution. I will use the NK_baseline_steadystate and revert if the issue persists.

Again, Many thanks for your help.

dyn_main_steadystate.m (2.7 KB)
Dear Johannes,
I am trying to update my code to be used with Dynare 4.6.x but I’m messing up with my steady state file… I don’t know how to adapt it correctly. May you help me, please? I was trying to follow BreakingFeaturesIn4.6.
Thanks

Why don’t you start from https://git.dynare.org/Dynare/dynare/-/blob/master/examples/NK_baseline_steadystate.m and add your own equations where it says

%% Enter model equations here

dyn_main.mod (11.7 KB) dyn_main_steadystate.m (3.2 KB)
Johannes,
You’re right. Sorry. I should have explored the example better before asking in the forum.
I upload now the new steadystate file and the main mod-file. I get a new error saying

Error using eval
Undefined function or variable 'c'.

I have a two-country model and I have c@, which takes name cH and cF. May the problem come from this fact? How could I make the steady state file account for it?
You may notice that, compared to the example, I changed {} by () because I was getting another error: Brace indexing is not supported for variables of this type. Can I safely do this change?

The full error I get is:

Error using eval
Undefined function or variable ‘c’.

Error in dyn_main_steadystate (line 133)
eval([‘ys(’ int2str(ii) ') = ’ varname ‘;’]);

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 dyn_main.driver (line 768)
steady;

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

I guess this post might be better allocated in “Undefined function or variable 'mc'” or a similar one…

  1. What are you loading in
    % load('dyn_main_M.mat')
    It seems you are overwriting the M_-structure.
  2. You again did not start from the correct file. Try dyn_main_steadystate.m (3.1 KB)

Thanks for your patience…

  1. I load a structure M_ that is later overwritten (when you run the code). If you put this line off, you get the error:

Error using eval
Must be a string scalar or character vector.

Error in dyn_main_steadystate (line 12)
eval([ paramname ’ = M_.params(’ int2str(ii) ‘);’]);

I do not clearly remember why we could solve it loading the structure. I asked my coauthor…

  1. Taking the file you uploaded, I again needed to substitute {} to avoid the Brace indexing error. Moreover, if I do not add

par = cell2struct(…
num2cell(M_.params),…
cellstr(M_.param_names)…
);

alfH = par.alfH;
alfF = par.alfF;
bet = par.bet;
nu = par.nu;
tau = par.tau;
Matlab tells me bet is undefined…

After adding this part in your file and changing {} , I again get the
Error using eval
Undefined function or variable ‘c’.

  1. My file is the correct one. You seem to be loading the M_ structure from an older Dynare version that does not yet use cell arrays.
  2. You are wrong when you say that M_ is later overwritten by the code. Some of it stays and screws up the code.
  3. I am getting an error because
dyn_det
`` 
has not been provided.

v7justq.rar (20.2 KB)
Ok. Thank you… I deleted the M_ structure loading and retook the correct file you provided me.
The attachment contains all code files.

It works with dyn_main_steadystate.m (2.5 KB)

Many thanks, Johannes. Yesterday, it did not work in my laptop. It worked today in my PC… I don’t understand what I did wrong (once I used the file you uploaded).

What’s the error message?

I reinstalled dynare in my laptop and cleanned Matlab path and now it works, but I cannot remember the details of the error. It was an error regarding ‘c’ having to be a string scalar or character vector.
We have a two-country model and we define c@, which takes names cH and cF.

One last thing that may be connected to the new Dynare version (sorry!):
I get a new error if I run the code from dyn_calibration.m (included in the .rar):

Dot indexing is not supported for variables of this type.
Error in dyn_sssim (line 20)
        num2cell(oo_.steady_state),...
Error in dyn_stats_qadj (line 12)
  SS = dyn_sssim(M_,options_,oo_,'ss');
Error in dyn_calibration (line 10)
[newss, ssH, ssF, stdH, stdF, acrH, acrF, corH, corF, corHF] =
dyn_stats_qadj(M_,oo_,oo_sim); 

If I substitute () by {} I get:

Undefined function or variable 'num2cell'.
Error in dyn_sssim (line 20)
SS=dyn_sssim(M_,options_,oo_,'ss');

Thank you…

On my machine I am not getting any error, but the dyn_calibration you sent me does not included a call to dyn_stats_qadj

I’m getting crazy… Now it’s working for me too. No clue what was happening… dyn_calibration has the call to dyn_stats_qadj commented. I (un)comment line 9 or 10 to run one version or the other.
Thanks…