Page 1 of 1

Dynare to RATS Conversion Utility

Posted: Wed Feb 17, 2010 12:35 pm
by TomDoan
We've posted a web page that converts Dynare code for DSGE models into RATS code.

To convert existing Dynare DSGE code, just go to:

http://www.estima.com/dynareconvert/dynareconvert.shtml

paste your Dynare code into the text box, and click on Submit. You'll get a new web page with the equivalent RATS code (to the extent possible), which you can copy and paste into RATS.

For more information on Dynare:

http://www.cepremap.cnrs.fr/dynare/

As an example, the following is a Dynare script:

Code: Select all

periods 1000; 

var y, phi, r, q, exch, A, phistar, ystar; 

varexo er, eq, eystar, ephistar, ez; 

parameters beta, tau, k, alpha, rhor, rhoq, rhoystar, rhophistar, rhoz, gamma1, gamma2, gamma3; 

beta=0.96; 
tau=0.5; 
k=0.5; 
alpha=0.10; 
rhor=0.5; 
rhoq=0.4; 
rhoystar=0.9; 
rhophistar=0.8; 
rhoz=0.2; 
gamma1=1.5; 
gamma2=0.25; 
gamma3=0.25; 


model(linear); 
y=y(+1)-(tau+alpha*(2-alpha)*(1-tau))*(r-phi(+1))-rhoz*(A-A(-1))-alpha*(tau+alpha*(2-alpha)*(1-tau))*q(+1)+alpha*(2-alpha)*((1-tau)/tau)*(ystar); 
phi=beta*phi(+1)+alpha*beta*q(+1)-(alpha*q)+(k/(tau+alpha*(2-alpha)*(1-tau)))*(y+alpha*(2-alpha)*((1-tau)/tau)*ystar); 
r=rhor*r(-1)+(1-rhor)*(gamma1*phi+gamma2*y+gamma3*exch)+er; 
exch=phi-(1-alpha)*q-phistar; 
q=rhoq*q(-1)+eq; 
A=A(-1)+ez; 
phistar=rhophistar*phistar(-1)+ephistar; 
ystar=rhoystar*ystar(-1)+eystar; 
end; 

shocks; 
var er; stderr 0.01; 
var eq; stderr 0.01; 
var ez; stderr 0.01; 
var eystar; stderr 0.01; 
var ephistar; stderr 0.01; 
end; 

stoch_simul(drop=200);
The converted code is:

Code: Select all

dec series y phi r q exch A phistar ystar
dec series er eq eystar ephistar ez
dec real beta tau k alpha rhor rhoq rhoystar rhophistar rhoz gamma1 gamma2  $
gamma3
compute beta=0.96
compute tau=0.5
compute k=0.5
compute alpha=0.10
compute rhor=0.5
compute rhoq=0.4
compute rhoystar=0.9
compute rhophistar=0.8
compute rhoz=0.2
compute gamma1=1.5
compute gamma2=0.25
compute gamma3=0.25
frml(identity) eqn1 = y - (y{-1}-(tau+alpha*(2-alpha)*(1-tau))*(r-phi{-1})-rhoz*(A-A{1}) $
-alpha*(tau+alpha*(2-alpha)*(1-tau))*q{-1}+alpha*(2-alpha)*((1-tau)/tau)*(ystar))
frml(identity) eqn2 = phi - (beta*phi{-1}+alpha*beta*q{-1}-(alpha*q)+(k/(tau+alpha*(2-alpha)*(1-tau)) $
)*(y+alpha*(2-alpha)*((1-tau)/tau)*ystar))
frml(identity) eqn3 = r - (rhor*r{1}+(1-rhor)*(gamma1*phi+gamma2*y+gamma3*exch)+er)
frml(identity) eqn4 = exch - (phi-(1-alpha)*q-phistar)
frml(identity) eqn5 = q - (rhoq*q{1}+eq)
frml(identity) eqn6 = A - (A{1}+ez)
frml(identity) eqn7 = phistar - (rhophistar*phistar{1}+ephistar)
frml(identity) eqn8 = ystar - (rhoystar*ystar{1}+eystar)
compute stoch_simul(drop=200)
frml           eqn9 = er
frml           eqn10 = eq
frml           eqn11 = eystar
frml           eqn12 = ephistar
frml           eqn13 = ez
group dsge eqn1 eqn2 eqn3 eqn4 eqn5 eqn6 eqn7 eqn8 eqn9 eqn10 eqn11 eqn12 eqn13
dsge(model=dsge,a=adlm,f=fdlm,z=zdlm) y phi r q exch A phistar ystar er eq eystar ephistar  $
ez
This requires just a bit of hand editing to produce usable input for RATS (deleting the compute stoch_simul(...) line). The endogenous variables from the Dynare var are listed in the same order on the DSGE instruction as the endogenous variables. The exogenous variables from the Dynare varexo generate additional equations without the identity option (here eqn9 to eqn13) and the series names are appended to the list of the endogenous variables on DSGE. The main set of equations are translated into the RATS form, replacing series(n) with series{-n}. All the arithmetic operators are the same in both. Most other lines in the Dynare script are translated into COMPUTE in RATS, which will generate some lines which need to be deleted.

Re: Dynare to RATS Conversion Utility

Posted: Thu Feb 18, 2010 4:12 am
by jdacuddy
Thank you very much, Tom. This is an excellent initiative. I have tested it on some other Dynare models and it has worked almost flawlessly.

I found a couple of small problems:
(1) it does not recognise local parameters identified with a # mark (eg, model(linear); # invh = 1/(1-h); in Dynare disappears in the RATS code)
(2) if a variable is declared as a series, subsequent attempts to initialise that variable (which are translated by RATS into compute statements) fail (eg,
dec series y c r pid vx s a q pi ys rs pis as vxs
...
compute y = 0
compute r = 0
compute pid = 0)

But these are small niggles, easily taken care of.

Regards

Re: Dynare to RATS Conversion Utility

Posted: Fri Feb 19, 2010 9:20 am
by TomDoan
jdacuddy wrote:Thank you very much, Tom. This is an excellent initiative. I have tested it on some other Dynare models and it has worked almost flawlessly.

I found a couple of small problems:
(1) it does not recognise local parameters identified with a # mark (eg, model(linear); # invh = 1/(1-h); in Dynare disappears in the RATS code)
(2) if a variable is declared as a series, subsequent attempts to initialise that variable (which are translated by RATS into compute statements) fail (eg,
dec series y c r pid vx s a q pi ys rs pis as vxs
...
compute y = 0
compute r = 0
compute pid = 0)

But these are small niggles, easily taken care of.

Regards
In the Dynare code, what's the point of y = 0 or r = 0? DSGE will accept y<<0.0 r<<0.0 to give an expansion point, or guess values for solving for the steady state for a non-linear model.

Re: Dynare to RATS Conversion Utility

Posted: Tue Mar 02, 2010 3:39 pm
by jdacuddy
Tom,
In reply to your query:
Since in most Dynare models, the variables are defined as z(t)=ln(x(t)/xbar), their steady-state values will be zero. The settings indicated in the code are defining those steady-state values.
Regards