Page 1 of 1

using a matlab program to calculate functions of deep params

PostPosted: Wed Apr 29, 2009 9:23 pm
by cocoa
Hi there,

I am writing because I am not being able to run a matlab .m file to calculate the value of some parameters, which are functions of deeper parameters of the model (to be estimated).

So, basically I have a log-linearized model. Some of the coefficients on the log-linear variables, are ratios of steady-state *levels*. This steady-state levels are functions of deep parameters of the model that I want to estimate.

I have a matlab function that calculates these steady-state levels, given some previously defined deep parameters.

What I want is to run this matlab .m function within the definition of the model, so that every time the model is being solved during the estimation process, the coefficients on the variables of the log-linear equations are based upon the deep parameters being estimated, and not upon some fixed ones.

Say my model file is model.mod
I am writing #model_steadystate; as part of the definition of the model, but its not running.

Does anybody know how to handle this situation?

Thanks a lot for your help!

Re: using a matlab program to calculate functions of deep params

PostPosted: Tue Jun 23, 2009 6:53 pm
by fschwart
I have exactly the same problem. Have you found a solution yet?

Felipe

Re: using a matlab program to calculate functions of deep params

PostPosted: Thu Jun 25, 2009 9:55 am
by StephaneAdjemian
Hi Felipe,

With Dynare version 4 it is not possible to call matlab functions in the model block of a mod file. The reason is that this version of Dynare computes analytical derivates of the model, instead of numerical derivates with Dynare version 3. So Dynare needs to know how to derive any functions appearing in the model block. To overcome this limitation, you can define the parameters in the steady state file. Here is an example with a deterministic growth model (the same applies for stochastic simulations and estimation). In this example, two parameters (A and PSI) are computed in the steadystate matlab file. In this file you can call any matlab functions.

Best, Stéphane.

Re: using a matlab program to calculate functions of deep params

PostPosted: Thu Jun 25, 2009 2:22 pm
by fschwart
Perfect. Looks like exactly what I need. Thanks!!!!

Re: using a matlab program to calculate functions of deep params

PostPosted: Thu Jun 25, 2009 5:45 pm
by fschwart
One more (related) question: Is there a way to recover the steady state calculated in the previous iteration in the steady state file? I will have to use a non-linear solver to find some of the steady state variables, it would be handy to be able to use these as initial conditions.

Thanks again!

Felipe

Re: using a matlab program to calculate functions of deep params

PostPosted: Fri Jun 26, 2009 7:41 am
by StephaneAdjemian
Felipe, you will find the previous steady state in oo_.steady_state. oo_ is a global matlab structure gathering all the results (from stoch_simul or estimation).

Best, Stéphane.

Re: using a matlab program to calculate functions of deep params

PostPosted: Fri Jun 26, 2009 5:02 pm
by fschwart
Hi Stephane, thanks for the answer.

I don't seem to be able to call the oo_. structure from the steady state script, perhaps it has not been defined at that point?

In any case, I am able to get the same information from the ys vector, which is one of the inputs to the file you sent me and that appears to work. Does that sound right?

Bests,

Felipe