steady state 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.

Re: steady state file

Postby tanya » Thu Aug 02, 2012 6:38 pm

Dear All

I am using the steady state file given above in the post by jpfeifer » Mon Nov 08, 2010 9:32 pm
It worked fine up until I tried dynare 4.3.0

Immediately after loading observations it crashes and writes


Loading 43 observations from UKdata.m

Attempt to reference field of non-structure array.

Error in evaluate_steady_state_file (line 95)
if max(abs(residuals)) > options.dynatol.f

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

Error in dynare_estimation_init (line 341)
oo_.steady_state =
evaluate_steady_state(oo_.steady_state,M,options_,oo_,steadystate_check_flag);

Error in dynare_estimation_1 (line 59)
[dataset_,xparam1, M_, options_, oo_, estim_params_,bayestopt_] =
dynare_estimation_init(var_list_, dname, [], M_, options_, oo_, estim_params_,
bayestopt_);

Error in dynare_estimation (line 70)
dynare_estimation_1(var_list,dname);


I have checked: immediately after it plots the priors it gets to the line

if max(abs(residuals)) > options.dynatol.f

and at this point options.dynatol.f does not seem to be defined. Before it was 1e-5. So it forgets this value somehow.

Can I fix it somehow?
tanya
 
Posts: 37
Joined: Tue Sep 12, 2006 6:41 pm

Re: steady state file

Postby jpfeifer » Fri Aug 03, 2012 3:30 pm

Could you please post the mod- and the steady state file that generate this error.
------------
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

Re: steady state file

Postby tanya » Sun Aug 12, 2012 10:15 pm

Sorry, i got distracted.

I traced this - there is some kind of bug, the error appears because some kind of options (including options.dynatol.f) are redefined in the middle. However, because of my model is linear and the steady state is zero, I just killed these nuisance lines, and it all worked. All I wanted this time is to check that different versions give me the same result. They did. So I cannot be bothered to dig deeper this time.
tanya
 
Posts: 37
Joined: Tue Sep 12, 2006 6:41 pm

Re: steady state file

Postby Newbie » Tue Dec 11, 2012 7:16 pm

Dear all,

regarding the external steady steate file I would have the following questions please:

1. if the model is log-linearised then the loop at the end of the example steady state file can also include ys(i)=0; We would have only the equations for the parameters in the file.

2. If I use your template I get an error. The first variable from M_.endo_names(i,:) is "v_K" in my case, but I get an error message that the variable is unknown. "v_K" is declared as a variable in the *.mod file. Why do I get this error message? Do I need to include it somehow as an input parameter in the *_steadystate function?

3. In order to get the external steady file to work I replaced:
Code: Select all
  %varname = deblank(M_.endo_names(i,:));
  %eval(['ys(' int2str(i) ') = ' varname ';']);


with
Code: Select all
ys(i)=0;

because my model is log-linearised and in steady state all log-deviations should be 0.

4. When I try to estimate my model I get the Blanchard-Kahn error and that a steady state could not be calculated. However, I get no error when I run stoch_simul(). Everything seems to work fine then.

I try then to use the option lik_init=2 instead of lik_init=1(even if my model is stationarised), but in this case the csminwel algorithm iterates 1000 times and at the end I get the error that the Hessian is negative(posterior maximisation error). My data is detrended with HP filter and I take log differences. The measurement equations are accordingly.( OBS_x = x - x(-1));

Any suggestions are higly appreciated!
Thank you in advance!
Daniel.
Newbie
 
Posts: 6
Joined: Sun Nov 11, 2012 2:53 pm

Re: steady state file

Postby jpfeifer » Sat Dec 29, 2012 9:47 am

1. Yes, you can do that.
2. You get the error, because in the steady state file you try to assign the value assigned to v_K in the steady state file to the v_K defined in the mod-file. However, you did not assign a value to v_K in the steadystate file.
3. By doing this, you now assign a value to v_K (equivalent to defining v_K=0 in the file before). Thus, it works now.
4. It sounds as if you use wrong initial parameter values for estimation.
------------
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

Re: steady state file

Postby nemesis » Wed Jan 30, 2013 8:32 pm

I am a new user of Dynare. I tried to enter my model's steady state ratios to jpfeifer's code but is gives me the error of unknown variables. Is there any specific method for writing steady state equations ??? I guess I should write them in this way:
- For each endogenous variable, there should be one equation.
- At the left hand side, we should just have one endogenous variable, not a ratio.
-The first endogenous variable should be completely defined by parameters.
-For the second endogenous variable, we can use parameters and first endogenous variable but we cannot use any new endogenous variable that is not defined earlier by parameters, because Matlab gives you the error for unknown variable.
Am I right?
nemesis
 
Posts: 1
Joined: Wed Jan 30, 2013 7:02 pm

Re: steady state file

Postby phoezy » Sat Feb 16, 2013 3:50 am

gbel wrote:Thanks Johannes,

Sorry for the late reply (paternity leave).

I'm resubmiting the file with your correction.

Gilles



Hi,
thanks for the steady state file. Can I use it to calculate my model's steady state? Should I change some codes in the files? There are 102 equations and 102 variables in my model.
I have been working with the model for one month, but I cannot get the right steady state by hand. I appreciate that you share your code here. Thank again and I hope for a further help from you. thanks!!!

cindy
phoezy
 
Posts: 6
Joined: Fri Feb 15, 2013 3:30 am

Re: steady state file

Postby jpfeifer » Mon Feb 18, 2013 6:03 pm

The code posted here only delivers one of the two formats required to enter a manual steady state into Dynare. You still need to compute the steady state by pencil and paper in order to be able to enter it. If you don't want to set parameters in your steady state or use a numerical solver (e.g. you reduced your system to a nonlinear equation in labor, solve this equation using fsolve and then compute the other variables), everything that the steady state file does, can also be provided in the initval-block.
------------
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

Re: steady state file

Postby phoezy » Thu Feb 21, 2013 2:27 pm

Thank you for your reply.
I tried and I get the steady state by pencil.
Thanks again.
Best regards.

cindy
phoezy
 
Posts: 6
Joined: Fri Feb 15, 2013 3:30 am

Re: steady state file

Postby mbbr » Mon Feb 25, 2013 11:43 am

Dear jpfeifer,

I tried to use your code to create steady state file. But I got an error;

Configuring Dynare ...
[mex] Generalized QZ.
[mex] Sylvester equation solution.
[mex] Kronecker products.
[mex] Sparse kronecker products.
[mex] Local state space iteration (second order).
[mex] Bytecode evaluation.
[mex] k-order perturbation solver.
[mex] k-order solution simulation.
[mex] Quasi Monte-Carlo sequence (Sobol).
[mex] Markov Switching SBVAR.

Starting Dynare (version 4.3.1).
Starting preprocessing of the model file ...
Found 19 equation(s).
Evaluating expressions...done
Computing static model derivatives:
- order 1
Computing dynamic model derivatives:
- order 1
Processing outputs ...done
Preprocessing completed.
Starting MATLAB/Octave computing.
Warning: Some of the parameters have no value (rstar, sd, yss, kss, k_over_ghss,
hss) when using steady. If these parameters are not initialized in a steadystate
file, Dynare may not be able to solve the model...
> In test_for_deep_parameters_calibration at 46
In steady at 33
In uribefinanssfile at 226
In dynare at 120
Undefined function or variable 'M_'.

Error in uribefinanssfile_steadystate (line 11)
if isfield(M_,'param_nbr') == 1

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

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 uribefinanssfile (line 226)
steady;

Error in dynare (line 120)
evalin('base',fname) ;


I attached my codes. Could you help me ? Thanks...
Attachments
uribefinanssfile_steadystate.m
(3.11 KiB) Downloaded 169 times
uribefinanssfile.mod
(5.76 KiB) Downloaded 161 times
mbbr
 
Posts: 10
Joined: Thu Feb 21, 2013 9:32 am

Re: steady state file

Postby jpfeifer » Mon Feb 25, 2013 1:42 pm

The error message comes because you deleted the space between M_ and lgy_ in the global variable definition. Next, you should never name parameters alpha, beta, gamma because these are the names of Matlab functions. Use e.g. alphha, betta, gammma instead. If you do this, you will see that your analytical steady state is wrong. See the attached files.
Attachments
uribefinanssfile_steadystate.m
(3.12 KiB) Downloaded 223 times
uribefinanssfile.mod
(5.79 KiB) Downloaded 198 times
------------
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

Re: steady state file

Postby mbbr » Mon Feb 25, 2013 3:08 pm

Thank you very much for your reply. I made correction in my code. It helps.
One more question. When I run the code making estimation, it gives this result;


Configuring Dynare ...
[mex] Generalized QZ.
[mex] Sylvester equation solution.
[mex] Kronecker products.
[mex] Sparse kronecker products.
[mex] Local state space iteration (second order).
[mex] Bytecode evaluation.
[mex] k-order perturbation solver.
[mex] k-order solution simulation.
[mex] Quasi Monte-Carlo sequence (Sobol).
[mex] Markov Switching SBVAR.

Starting Dynare (version 4.3.1).
Starting preprocessing of the model file ...
Found 23 equation(s).
Evaluating expressions...done
Computing static model derivatives:
- order 1
Computing dynamic model derivatives:
- order 1
Processing outputs ...done
Preprocessing completed.
Starting MATLAB/Octave computing.





Residuals of the static equations:

Equation number 1 : 0
Equation number 2 : 0
Equation number 3 : 0
Equation number 4 : 0
Equation number 5 : 0
Equation number 6 : -7.9604
Equation number 7 : -7.9604
Equation number 8 : 0
Equation number 9 : 0
Equation number 10 : 7.9604
Equation number 11 : 0
Equation number 12 : 0
Equation number 13 : 0
Equation number 14 : 0
Equation number 15 : 0
Equation number 16 : 0
Equation number 17 : 0
Equation number 18 : 0
Equation number 19 : 0
Equation number 20 : 0
Equation number 21 : 0
Equation number 22 : 0
Equation number 23 : 0


Error using print_info (line 55)
The steadystate file did not compute the steady state

Error in resid (line 116)
print_info(info,options_.noprint)

Error in steady (line 90)
resid;

Error in uribefinansestson (line 291)
steady;

Error in dynare (line 120)
evalin('base',fname) ;

Thanks again.
mbbr
 
Posts: 10
Joined: Thu Feb 21, 2013 9:32 am

Re: steady state file

Postby jpfeifer » Mon Feb 25, 2013 5:04 pm

As I wrote, your steady state computation is wrong. There still is a residual in equations 6,7, and 10.
------------
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

Re: steady state file

Postby mbbr » Tue Feb 26, 2013 3:40 pm

Thank you for your reply. But i dont understand that when i run the model without steady state file, resid(1) gives for all equations zero. It gives this result.

Configuring Dynare ...
[mex] Generalized QZ.
[mex] Sylvester equation solution.
[mex] Kronecker products.
[mex] Sparse kronecker products.
[mex] Local state space iteration (second order).
[mex] Bytecode evaluation.
[mex] k-order perturbation solver.
[mex] k-order solution simulation.
[mex] Quasi Monte-Carlo sequence (Sobol).
[mex] Markov Switching SBVAR.

Starting Dynare (version 4.3.1).
Starting preprocessing of the model file ...
Found 23 equation(s).
Evaluating expressions...done
Computing static model derivatives:
- order 1
Computing dynamic model derivatives:
- order 1
Processing outputs ...done
Preprocessing completed.
Starting MATLAB/Octave computing.


STEADY-STATE RESULTS:

c 0.150095
h 0.179761
lamda 275.756
a 1
g 1.01
k 0.292417
d 0.007
i 0.0396226
r 0.105919
y 0.211472
k_over_gh 1.61059
v 1
s 0.0211472
mu 1
gy 1.01
gc 1.01
gi 1.01
tb 0.000607129
tby 0.00287096
gy_obs 1.01
gc_obs 1.01
gi_obs 1.01
tby_obs 0.00287096




Residuals of the static equations:

Equation number 1 : 0
Equation number 2 : 0
Equation number 3 : 0
Equation number 4 : 0
Equation number 5 : 0
Equation number 6 : 0
Equation number 7 : 0
Equation number 8 : 0
Equation number 9 : 0
Equation number 10 : 0
Equation number 11 : 0
Equation number 12 : 0
Equation number 13 : 0
Equation number 14 : 0
Equation number 15 : 0
Equation number 16 : 0
Equation number 17 : 0
Equation number 18 : 0
Equation number 19 : 0
Equation number 20 : 0
Equation number 21 : 0
Equation number 22 : 0
Equation number 23 : 0


Loading 105 observations from arj_data.m


SOLVE: maxit has been reached

SOLVE: maxit has been reached

SOLVE: maxit has been reached
Error in computing likelihood for initial parameter values
Error using print_info (line 57)
Impossible to find the steady state. Either the model doesn't have a unique
steady state of the guess values are too far from the solution

Error in initial_estimation_checks (line 69)
print_info(info, DynareOptions.noprint)

Error in dynare_estimation_1 (line 147)
oo_ =
initial_estimation_checks(objective_function,xparam1,dataset_,M_,estim_params_,options_,bayestopt_,oo_);

Error in dynare_estimation (line 70)
dynare_estimation_1(var_list,dname);

Error in uribefinansestson (line 328)
dynare_estimation(var_list_);

Error in dynare (line 120)
evalin('base',fname) ;

But with the steady state file, it gives errors for equations 6,7 and 10 and residuals of the static equations are different from zero? What is the reason behind this? May it stem from MCMC algorithm which uses different initial point for each draw? In simulation part, it works with steady state file. I really appreciate all answers. Thanks.
mbbr
 
Posts: 10
Joined: Thu Feb 21, 2013 9:32 am

Re: steady state file

Postby jpfeifer » Tue Feb 26, 2013 7:41 pm

Seems to me you put resid(1) after steady, not before. If you use steady, Dynare numerically computes the steady state before you check for residuals.
------------
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

PreviousNext

Return to Dynare help

Who is online

Users browsing this forum: No registered users and 9 guests