Cannot find SS using dynare. What is the next most efficient way?


I cannot isolate one of the variables in my steady state system, hence can’t plug my SS directly in dynare. I used fsolve in Matlab, but I am not sure what is the most efficient way to proceed from now. Is there a way I can include the vectors I get from the simple matlab files, or do I necessarily need to re-write my _steadystate.m file as mentioned in the user guide?


If it’s just one variable you solve numerically for, have a look at the example3.mod in the Dynare examples folder. It shows how to use a small helper file within a steady_state_model-block

Thank you for this tip. I did it this way but now I get the following error: ERROR: gwgrow.mod: line 144, cols 8-14: Symbol z_ss cannot take arguments.

This is how z_ss enters the model:


z_ss = gwgrow_steady_state_helper(params);


z_ss is a 3-by-1 vector in this case

and line 144 is :

@#for j in 1:M

z1_@{j} = z_ss(@{j});

is the problem coming from z_ss being a vector?

Hard to tell. I would need to run the code myself.

This is the two files needed to run it.

Thank you.
gwgrowth_steady_state_helper.m (400 Bytes)
gwgrowth.mod (2.9 KB)

Dynare 4 only handles scalar parameters, not vectors. Thus, you cannot work with z_ss[j]. You need to output several scalars instead.

What would be the best way to do that? I tried by saving the vector of z_ss as data and loading it into dynare but I end up with the same problem, where z_ss is a vector. And I cannot just consider every scalar of z_ss separately, because z_ss will potentially be 120 by 1 in the actual final model.

Have you tried having the helper function return a vector and then using the preprocessor to write the vector entries into scalar parameters used in the model-block?

I found a way around this. I save each element of z_ss as zss_j (i.e. if z_ss is 3-by-1, then zss_1 = z_ss(1) , zss_2 = z_ss(2) , zss_3 = z_ss(3) ). Then I save all the parameters in Matlab as parameterfile.m. From here, I load parameterfile.mat in my .mod file. I think I am doing everything correctly, but when I run it, I get the following error:

Error using subsindex
Function ‘subsindex’ is not defined for values of class ‘struct’.

Error in gw_with_growth (line 383)
oo_.dr.eigval = check(M_,options_,oo_);

Error in dynare (line 223)
evalin(‘base’,fname) ;

I cannot figure out what the issue might be. I already used model diagnostics, but that doesn’t seem to be helping me much. Attached are the .mod and the .m files that I used. Any help would be appreciated.

gw_with_growth.mod (2.8 KB)
gwgrow_ss.m (2.0 KB)
steadygrow.m (536 Bytes)

  1. You should have used a _steadystate.m-file to do this. Your current approach is error prone.
  2. The reason you get this error is because check.m is a Dynare file and you name a variable in gwgrow_ss.m that way. This creates a naming conflict.

thank you.

Yes, you are right. I will switch to using _steadystate.m instead.