Bansal-Yaron (2009) problem with the code

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.

Bansal-Yaron (2009) problem with the code

Postby igorvele » Thu Jul 15, 2010 5:35 am

I am trying to estimate Bansal-Yaron (2009) model but i´m getting this error

You did not declare endogenous variables after the estimation command.

It repeats a thousand times.
Can anyone tell me what´s wrong?
thanks!
Attachments
LLR.mod
(5.76 KiB) Downloaded 241 times
igorvele
 
Posts: 3
Joined: Wed Aug 12, 2009 2:22 am

Re: Bansal-Yaron (2009) problem with the code

Postby jpfeifer » Thu Jul 15, 2010 6:10 am

It's not an error but a warning. So you can ignore it. Instead, try naming your data-file differently from the Dynare model file.
------------
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: Bansal-Yaron (2009) problem with the code

Postby igorvele » Fri Jul 16, 2010 6:00 am

thanks!

another thing:

when i estimate BY(2004) model using mode_compute=6, i have this error:

STEADY: numerical initial values incompatible with the following equations
4 5

and it stops working


however, if i change mode_compute to 3, i got the same message, but dynare calculate posteriors and everything
why?
igorvele
 
Posts: 3
Joined: Wed Aug 12, 2009 2:22 am

Re: Bansal-Yaron (2009) problem with the code

Postby jpfeifer » Fri Jul 16, 2010 6:50 am

Could you post the mod-file and the data-file? Note that you should always give valid starting values, irregardless of the way you compute the mode. Use the initval-block for this.
The error you got, may derive from several problems:
1. You forgot to initialize one of the parameters so Dynare set it to NaN, [] or 0.
2. You did not specify starting values for the steady state computation by using the initval-block. In this case, Dynare uses 0 as the starting values. In some cases, you divide in some equations by this variable, giving you this error. The same may happen if the starting values leads to taking the root of a negative number.
3. The same problem as is the case for the endogenous variables in 2 may happen if you use wrong initial values for the parameters.
------------
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: Bansal-Yaron (2009) problem with the code

Postby igorvele » Fri Jul 16, 2010 10:41 am

here it is!

//This is Bansal-Yaron (2004) model for US and Brazil

//endogenous variables
var c d pc pd x;

//exogenous variables
varexo ec ex ed;

//parameters
parameters beta gamma psi mu_c mu_d rho tau;
beta =0.95;
gamma =2;
psi =1.5;
mu_c =0.01;
mu_d =0.01;
rho =0.9;
tau =3;

model;
c = mu_c + x(-1) +ec;
d = mu_d + tau*x(-1) + ed ;
x = rho*x(-1) + ex;
pc = beta^((1-gamma)/(1-(1/psi)))*exp((-((1-gamma)/(1-(1/psi)))/psi)*c(+1)+(((1-gamma)/(1-(1/psi)))-1)*log(((1+pc(+1))/pc)*exp(c(+1))))*(1+pc(+1))*exp(c(+1));
pd = beta^((1-gamma)/(1-(1/psi)))*exp((-((1-gamma)/(1-(1/psi)))/psi)*c(+1)+(((1-gamma)/(1-(1/psi)))-1)*log(((1+pc(+1))/pc)*exp(c(+1))))*(1+pd(+1))*exp(d(+1));
end;

initval;
c=mu_c;
d=mu_d;
x=0;
pc=0.01;
pd=0.01;
ec=0;
ex=0;
ed=0;
end;

shocks;
var ec; stderr .01;
var ed; stderr .01;
var ex; stderr .01;
end;

check;
steady;

estimated_params;
beta ,NORMAL_PDF ,0.98 ,0.05;
gamma ,NORMAL_PDF ,2 ,0.50;
psi ,NORMAL_PDF ,1.6 ,0.5;
mu_c ,NORMAL_PDF ,0.01 ,0.005;
mu_d ,NORMAL_PDF ,0.01 ,0.005;
rho ,NORMAL_PDF ,0.98 ,0.05;
tau ,NORMAL_PDF ,3 ,0.7;

stderr ed ,INV_GAMMA_PDF ,0.01 , .02;
stderr ex ,INV_GAMMA_PDF ,0.001 , .02;
stderr ec ,INV_GAMMA_PDF ,0.001 , .02;
end;

varobs c d pd;
estimation(datafile=databy04,xls_sheet=ready,xls_range=g2:i121,mode_compute=3,mh_replic=1000,mh_nblocks=2);
Attachments
databy04.xls
(245.5 KiB) Downloaded 224 times
BY04.mod
(1.36 KiB) Downloaded 206 times
igorvele
 
Posts: 3
Joined: Wed Aug 12, 2009 2:22 am

Re: Bansal-Yaron (2009) problem with the code

Postby jpfeifer » Fri Jul 16, 2010 6:36 pm

I guess your true problem is with your priors. E.g. , you should not use a normal prior for beta. The reason is that beta is always between 0 and 1, but a normal distribution has the whole real line as its support. The correct prior here would be a beta distribution. If the estimation tries a value for beta that is negative, computing
Code: Select all
beta^((1-gamma)/(1-(1/psi)))

might involve taking the root of a negative number. The same problem with priors having the wrong support may apply to other parameters as well, e.g. for autoregressive parameters like rho which should be between -1 and 1.
------------
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


Return to Dynare help

Who is online

Users browsing this forum: No registered users and 7 guests