Steady state block calling a m.file


I have a question regarding the steady_state_model block in Dynare and its relationship with Matlab.

In a model steady state, I have a total of 5 equations and 5 variables. I easily obtain by hand the steady state values of the first two variables. For the three remaining variables, I have three highly non-linear equations. Therefore, to solve this three-equation three-variable system, I write a helper function in Matlab, and refer to this function in my steady_state_model block in Dynare.

In fact, I have tried to follow the same method as the Dynare-supplied example3. In this example3 example, there is a highly non-linear equation in labor, and a example3_steady_state_helper is a matlab file which computes the solution to the non-linear equation.

In my case, I have written a deval_steady_state_helper m.file (itself referring to another m. file to define the system) to solve the three non-linear equations.

Yet, when I run my model on Dynare, I get message errors just after “Starting Matlab/Octave computing”.

May you please tell me whether I have misunderstood how the steady_state_model block works?

Do you have an idea of what the issue might be?

Please find as attached files:

  • Dynare main mod.file describing my model
  • Matlab m. file using the fsolve function to solve my system of three non-linear steady state equations
  • Matlab m. file defining my system of three equations

The error message by Dynare is:

Processing outputs …done
Preprocessing completed.
Starting MATLAB/Octave computing.

Error using ^
Inputs must be a scalar and a square matrix.
To compute elementwise POWER, use POWER (.^) instead.

Error in m1 (line 6)
f(1) = (((((1-delta)/(alphalambda(deltax-1)))((1-n)^((sigma+eta)/eta))((wx/(1+vatx))^(1/eta))…

Error in fsolve (line 217)
fuser = feval(funfcn{3},x,varargin{:});

Error in deval_steady_state_helper (line 4)
[cx,vat,vatx] = fsolve(‘m1’, guess, options);

Error in deval_steadystate2 (line 6)

Error in evaluate_steady_state_file (line 54)
[ys,params1,check] = h_steadystate(ys_init, exo_ss, params);

Error in evaluate_steady_state (line 58)
[ys,params,info] = evaluate_steady_state_file(ys_init,exo_ss,M, …

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

Error in deval (line 147)

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

Caused by:
Failure in initial user-supplied objective function evaluation. FSOLVE cannot continue.

Thank you very much for your help,

Kind regards,

deval_steady_state_helper.m (321 Bytes)
deval.mod (2.4 KB)
m1.m (1.53 KB)

You cannot use global variables to pass parameters to your function, because Dynare variables and parameters are unknown to Matlab. Given the structure of your problem, use a full-fledged steady_state-file as in the NK_baseline.mod instead of the steady_state_model-block. There, variables and parameters will be available with their names.