Steady state block calling a m.file
Posted: 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
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