using a matlab program to calculate functions of deep params

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.

using a matlab program to calculate functions of deep params

Postby cocoa » Wed Apr 29, 2009 9:23 pm

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!
cocoa
 
Posts: 5
Joined: Wed Apr 29, 2009 9:15 pm

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

Postby fschwart » Tue Jun 23, 2009 6:53 pm

I have exactly the same problem. Have you found a solution yet?

Felipe
fschwart
 
Posts: 8
Joined: Tue Jul 01, 2008 7:13 pm

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

Postby StephaneAdjemian » Thu Jun 25, 2009 9:55 am

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.
Attachments
dog_steadystate.m
The steadystate file for dog.mod
(2.53 KiB) Downloaded 461 times
dog.mod
dog.mod (a growthless deterministic growth model)
(1.99 KiB) Downloaded 423 times
Stéphane Adjemian
Université du Maine, GAINS and DynareTeam
https://stepan.adjemian.eu
StephaneAdjemian
 
Posts: 429
Joined: Wed Jan 05, 2005 4:24 pm
Location: Paris, France.

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

Postby fschwart » Thu Jun 25, 2009 2:22 pm

Perfect. Looks like exactly what I need. Thanks!!!!
fschwart
 
Posts: 8
Joined: Tue Jul 01, 2008 7:13 pm

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

Postby fschwart » Thu Jun 25, 2009 5:45 pm

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
fschwart
 
Posts: 8
Joined: Tue Jul 01, 2008 7:13 pm

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

Postby StephaneAdjemian » Fri Jun 26, 2009 7:41 am

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.
Stéphane Adjemian
Université du Maine, GAINS and DynareTeam
https://stepan.adjemian.eu
StephaneAdjemian
 
Posts: 429
Joined: Wed Jan 05, 2005 4:24 pm
Location: Paris, France.

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

Postby fschwart » Fri Jun 26, 2009 5:02 pm

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
fschwart
 
Posts: 8
Joined: Tue Jul 01, 2008 7:13 pm


Return to Dynare help

Who is online

Users browsing this forum: Google [Bot] and 11 guests