Page 1 of 2

external steady state file with linear model

PostPosted: Wed Sep 16, 2015 4:45 pm
by hodabbbb
Hi,
I have a question.
I wanted to calibrate a model in its loglinearized form using an external steady state.

I am calibrating several parameters to match certain targets using a fun.m file.
When the mode was not loglinearized, I called the parameters from the '<example_steady state.m> file in the <example.mod> file as
x = STEADY_STATE(x); as each x-parameter was declared as endogenous variable.

In the loglinearized version do I follow the same steps. (i.e declare parameters that are calibrated as endogenous variables, and call them via the command x = STEADY_STATE(x) ??

Re: external steady state file with linear model

PostPosted: Thu Sep 17, 2015 7:47 pm
by jpfeifer
I am not following. What do you mean with
each x-parameter was declared as endogenous variable
?

If x is a variable, it cannot be a parameter. STEADY_STATE(x) will be a parameter.

If you are asking how to access the steady state levels of the original level variables when you are dealing with a log-linearized model: you define e.g. a parameter x_ss and set this parameter to the steady state value for the level of x computed in the steady state file. The model variable xhat must be set to 0 in the steady state file. Basically, you only use the steady state file to access the nonlinear steady state values of the original model.

Re: external steady state file with linear model

PostPosted: Thu Sep 17, 2015 10:34 pm
by hodabbbb
Thanks a lot for your comment Mr. Pfeifer. It's exactly what I am asking. So the way I understand th proposed solution is: when i have a loglinearized mod file use the same steady state.m and fun.m files I was using when I had a *.mod file in levels but now call only the ss value of the variables with x_ss=STEADYSTATE (x) inside th model (linear) ... end; block. Then I have to declare both x & xhat as endogenous variables and x_ss as parameter. Amy right?

Re: external steady state file with linear model

PostPosted: Fri Sep 18, 2015 5:42 am
by jpfeifer
First, that is not my name.

Second, that is not what I was saying. You can only use the steady_state()-operator on variables and in a log-linearized model you level variables are not defined as variables. Rather define x_ss in the mod_file

Code: Select all
parameters x_ss;


Then in the steady state file set x_ss to its steady state value

Code: Select all
x_ss=((1/beta-delta)/alpha)^(1/(1-alpha));


and set the variable x that is percentage deviations of x from its steady state to 0:

Code: Select all
x=0;

In every run of your model, Dynare will update the parameter x_ss from the deep parameters of the model. An example for a steady state file is the NK_baseline.mod in the Dynare examples folder

Re: external steady state file with linear model

PostPosted: Fri Sep 18, 2015 8:03 am
by hodabbbb
1. Apologies for misspelling the name. I was writing from my Phone last night, and the software of the phone end up displaying sth else from what I intend to write. Obviously for this case I probably have not corrected it.

2. Thank you very much for your helpful comments. This is how I am proceeding. (and I did looked at the example with NK baseline model) .

The extra issue I got is that I am calibrating some of the parameters (mu, Theta, psi etc) in the steady state file. When the model was in level, they were declared as endogenous variables and called in the model block of FILE.mod as : mu = STEADY_STATE(mu) in order to convert tem into fixed values ( and use them as parameters). They were calibrated to account for nonlinearities in the the FUN.m file.

Now that the model is linear, are these to-be-calibrated parameters declared as endogenous again ?

and in case so, do I call them in the model(linear) block in the same way { mu = STEADY_STATE(mu) }, which implies the steady state value will not be zero , while zero for other ''x'' (loglinearized) variables ?

Regards

Re: external steady state file with linear model

PostPosted: Fri Sep 18, 2015 12:59 pm
by hodabbbb
I get this message when I run my linear Model with external steady state .
The parameters for DYNARE says ''no value '' (as seen below) are functions of parameters which I am trying to calibrate (mup). So obviously Dynare did not read the value of the calibrated parameters (mu,Theta,psi).
Any help would be highly appreciated (I am attaching the files).


Code: Select all
Warning: Some of the parameters have no value (PSTARss, MC, DELTA, RK, IY, CY, varrho, YWss, Yss, Iss, Kss, Gss, Css, W) 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 NKlinear at 382
  In dynare at 180
Warning: Trust-region-dogleg algorithm of FSOLVE cannot handle non-square systems; using Levenberg-Marquardt algorithm
instead.
> In fsolve at 285
  In NKlinear_steadystate at 30
  In evaluate_steady_state_file at 49
  In evaluate_steady_state at 58
  In steady_ at 54
  In steady at 81
  In NKlinear at 382
  In dynare at 180
Warning: Trust-region-dogleg algorithm of FSOLVE cannot handle non-square systems; using Levenberg-Marquardt algorithm
instead.
> In fsolve at 285
  In NKlinear_steadystate at 30
  In evaluate_steady_state_file at 49
  In evaluate_steady_state at 58
  In resid at 55
  In steady at 90
  In NKlinear at 382
  In dynare at 180

Re: external steady state file with linear model

PostPosted: Mon Sep 21, 2015 12:17 pm
by jpfeifer
Never ever name a variable just i. Use invest. Your steady state file uses a loop index named i as well! You are overwriting all results.

Moreover, use a correct steady state file! Your's is missing the
Code: Select all
for iter = 1:length(M_.params) %update parameters set in the file
  eval([ 'M_.params(' num2str(iter) ') = ' M_.param_names(iter,:) ';' ])
end

at the bottom. Again, see the NK_baseline.mod

Finally, you cannot use
Code: Select all
KYW     = STEADY_STATE(KYW);
mup     = STEADY_STATE(mup);
muY     = STEADY_STATE(muY);


Those three objects are parameters, not variables.

Re: external steady state file with linear model

PostPosted: Mon Sep 21, 2015 3:04 pm
by hodabbbb
Thanks a lot for the response Prof. Johannes. I did add the extra lines and the relevant substitution.

It still does not give values to the SS parameters which are function of deep parameters ( though I am loading them).
Could it be that I am missing some command in the beginning of the steadystate file or in the ...fun.m file?


Code: Select all
Warning: Some of the parameters have no value (varrho, RK, W, IY, CY, YWss, Yss, Iss, Kss, Gss, Css, PSTARss, MC, DELTA, KYW, mup, muY) 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 NKlinear at 374
  In dynare at 180
Warning: Trust-region-dogleg algorithm of FSOLVE cannot handle non-square systems; using Levenberg-Marquardt algorithm instead.
> In fsolve at 285
  In NKlinear_steadystate at 30
  In evaluate_steady_state_file at 49
  In evaluate_steady_state at 58
  In steady_ at 54
  In steady at 81
  In NKlinear at 374
  In dynare at 180



Though it does calculate the value of SS parameters it still gives some warnings as if not doing so (I edited this text after several trials) .

And should I bother for this warning also ? Why should it be a warning that is using another algorithm ? is sth wrong with it ?
Code: Select all
Warning: Trust-region-dogleg algorithm of FSOLVE cannot handle non-square systems; using Levenberg-Marquardt algorithm instead.


Many many Thanks Prof. Pfeifer.

Re: external steady state file with linear model

PostPosted: Tue Sep 22, 2015 8:32 am
by jpfeifer
Read the message carefully:
If these parameters are not initialized in a steadystate file, Dynare may not be able to solve the model

But you are initializing them in the steady state file. So no reason to worry here.

The other warning regarding fsolve is also harmless. You can get rid of it by adding to optimset the option
Code: Select all
'Algorithm','levenberg-marquardt'


There are still two additional issues:
1. lambda isn't present at the current period in the model.
2. The Blanchard-Kahn conditions are not satisfied. The is most probably still a timing error

Re: external steady state file with linear model

PostPosted: Tue Sep 22, 2015 1:07 pm
by hodabbbb
Many Thanks Prof. Johannes,

I works fine now. very much appreciated.
It's weird though when dynare says :

Code: Select all
There are 12 eigenvalue(s) larger than 1 in modulus
for 12 forward-looking variable(s)

The rank condition ISN'T verified!
...
...
then
...
Error using print_info (line 48)
Blanchard Kahn conditions are not satisfied: indeterminacy due to rank failure


There should be a way to fix it.

Re: external steady state file with linear model

PostPosted: Tue Sep 22, 2015 2:55 pm
by jpfeifer
Why is that weird? When your model does not satisfy the rank condition, it does not help when the BK conditions are satisfied. Does model_diagnostics return anything?

Re: external steady state file with linear model

PostPosted: Tue Sep 22, 2015 3:26 pm
by hodabbbb
the problem with lambda. You already mentioned that before .

Code: Select all
>> model_diagnostics(M_,options_,oo_)
The following endogenous variables aren't present at the current period in the model:
lambda   
Undefined function 'BggGKlinear_steadystate' for input arguments of type 'double'.

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 model_diagnostics (line 65)
[dr.ys,params,check1]=evaluate_steady_state(oo.steady_state,M,options,oo,1);



Is it fine to write in the model(linear) block (i.e. is it the samething?) :

Code: Select all
 
lambda = - rr;
... instead of....
lambda(+1) = - rr (+1) ;


Correction: Many many Thanks Prof. Johannes. I think I fixed by doing what I just wrote above.

My last question: I have a vector called
Code: Select all
mycalib     = [KYW, APS, PSI, mup,        ThetaB, sigmaB, xiB, sigmaE, xiE,muY]



in my steady state file:
Code: Select all
FILENAME_steadystate.m     


How can I import these values in my dynare file called: ?
Code: Select all
FILENAME.mod


what are the commands for that. I have been searching for days, I can not get the syntax right. (Ps. It will help me get around with this warning that SS parameters are not initialized (although the are) . Just the idea that it shows up seems bothering.

Re: external steady state file with linear model

PostPosted: Wed Sep 23, 2015 9:33 am
by jpfeifer
No,
Code: Select all
lambda = - rr;

is not the same as
Code: Select all
lambda(+1) = - rr (+1) ;

The latter is E_t(lambda(+1))=E_t(-rr(+1)), i.e. the equation then only has to hold in expectations. As lambda does not enter any equation, you can just delete this equation and get rid of lambda.

Just forget about the warning. There is no way around it. It is designed exactly for this purpose of warning a user that these parameters have to be defined in the steady state file, which you do.

Re: external steady state file with linear model

PostPosted: Wed Sep 23, 2015 10:12 am
by hodabbbb
Alright. Many thanks Prof.
then the problem with the BK condition is there. back to square 1.

Re: external steady state file with linear model

PostPosted: Wed Sep 23, 2015 2:06 pm
by jpfeifer
If you had a running nonlinear version, finding the problem should not be too difficult.