Steady state block calling a m.file

This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location where you will have to reset your password.
Forum rules
This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location (https://forum.dynare.org) where you will have to reset your password.

Steady state block calling a m.file

Postby Hugo » Wed Jan 14, 2015 3:28 am

Hello,

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)/(alpha*lambda*(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)
[ys_(1),ys_(3),ys_(2)]=deval_steady_state_helper(params(1),params(2),params(3),params(4),params(5),params(6),params(7),params(8),params(9));

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)
steady;

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,

Hugo
Attachments
deval_steady_state_helper.m
Helper file
(321 Bytes) Downloaded 69 times
deval.mod
Model main file
(2.4 KiB) Downloaded 68 times
m1.m
System definition
(1.53 KiB) Downloaded 65 times
Hugo
 
Posts: 8
Joined: Wed Jan 14, 2015 2:20 am

Re: Steady state block calling a m.file

Postby jpfeifer » Thu Jan 15, 2015 9:07 am

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.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany


Return to Dynare help

Who is online

Users browsing this forum: No registered users and 11 guests