Page 1 of 1

Need help with the Medina and Soto(2005) model

PostPosted: Thu Apr 28, 2016 6:51 am
by psbe20
Hello all,

I recently got started using dynare. Currently, I am trying to replicate and simplified the Medina and Soto(2005) model. Now it seems that I have some problems with the number of the eigenvalues. I did also try to adjust the t period in the forward-looking equations, but it does not help. In addition, when I ran the model diagnostics test, it shows that there is a non-redundant equation missing. Can anybody here give me some suggestion ?

Thanks a lot in advance

Attached here is my code
Code: Select all
/*
The following model follows a DSGE model developed by Medina and Soto(2005),
however this is the simplified version by excluding the Calvo pricing, Monetary Authority, and
the returns on investment.
*/


/*
ch      =   consumption of home goods
rer     =   real exchange rate
prh     =   nominal home-good price relative to consumption bundle price
c       =   total domestic consumption
cf      =   consumption of foreign goods
oc      =   oil consumption in domestic household
pro     =   nominal oil price relative to consumption bundle price
pi      =   domestic headline inflation
pih     =   domestic core inflation
oh      =   oil used in domestic production
l       =   labor
wr      =   nominal wage relative to consumption bundle price
yh      =   total home goods produced
ah      =   productivity/technology
prostar =   nominal foreign oil price relative to consumption bundle(abroad)
psi     =   oil stabilization fund
deltae  =   nominal exchange rate(adjustment of the law of one price)
pistar  =   foreign inflation
cstar   =   total foreign consumption
y       =   domestic gdp
x       =   domestic export
m       =   domestic import
o       =   domestic oil
*/

var ch,rer,prh,c,cf,oc,pro,pi,pih,oh,l,wr,yh,ah,prostar,psi,deltae,pistar,cstar,y,x,m,o;

/*
gamma   =   share in core consumption
theta   =   intratemporal elasticity of substitution between home and foreign goods
eta     =   elasticity of substitution between oil and core consumption
B       =   discount factor
omega   =   elasticity of substitution between labor and oil in production
alpha   =   share of input in production
pa      =   AR product. shock
sigmaL  =   inverse elasticity of labor supply wrt. real wage
po      =   AR oil price shock
ppsi    =   AR oil fund shock
ppistar =   AR foreign inflation shock
etastar =   elasticity of substitution between oil and core consumption(foregin)
delta   =   share in domestic consumption
chyh    =   home goods consumption/home goods produced
cy      =   domestic consumption/GDP
xy      =   export/GDP
my      =   import/GDP
chstarx =   foreign demand for home goods/export
pcstar  =   AR foreign consumption
cfm     =   domestic demand for foreign goods/import
oco     =   household oil consumption/total oil
oho     =   oil used in production/total oil
*/

varexo ea,eo,epsi,epistar,ecstar,
       edeltae;

parameters gamma,theta,eta,B,omega,alpha,pa,sigmaL,po,ppsi,ppistar,etastar,delta,chyh,cy,xy,my,chstarx,pcstar,cfm,oco,oho,
            pdeltae;
gamma   = .075;  // alp and elekdag
theta   = .616;  //medina and soto
eta     = .656;  //medina and soto
B       = .9926; //Surach
omega   = .507;  //median and soto
alpha   = .5;
pa      = .936;  //medina and soto
sigmaL  = 3.0303; //Surach =1 in alp and elekdag
po      = .88;   //medina and soto
ppsi    = .968;  //medina and soto
ppistar = .140;  //medina and soto
etastar = 1.14;  //medina and soto =.508 alp and elekdag
delta   = .5;
chyh    = .8;
cy      = .7;
xy      = .12;
my      = .18;
chstarx = 1; //in the case of Thailand
pcstar  = .887; //medina and soto
cfm     = .7;
oco     = .5;
oho     = .5;

pdeltae =.8; //Add//


Model(linear);

//Aggregate Demand//
//1 Domestic Consumption of Home goods
ch=(1-gamma)*(theta-eta)*rer-(theta*(1-gamma)+gamma*eta)*prh+c;
//2 Domestic Consumption of Foreign goods//
cf=-((theta*gamma)+eta*(1-gamma))*rer+gamma*(theta-eta)*prh+c;
//3: Domestic Consumption of Oil goods//
oc=(-eta*pro)+c;
//4: Euler Equation//
c=c(+1)+(-pi(+1));

//Aggregate Supply and Inflation//
//5: Passive Resetting price equation//
pih=(B*pih(+1));
//6: Optimal input//
oh-l=omega*(wr-pro);
//7: Production Funtion//
yh=ah+((1-alpha)*l)+alpha*oh;
//8: Technology process//
ah=pa*ah(-1)+ea;
//9: Marginal rate of substitution between labor and consumption//
wr=c+sigmaL*l;

//Relative Prices//
//10: Real price of home goods//
prh=prh(-1)+pih-pi;
//11: Real price of oil//
pro=rer+prostar+psi;
//12: The process of real price oil abroad with respect to foreign index AR(1)//
prostar=po*prostar(-1)+eo;
//13: The deviation from law of one price -> the oil stabilization fund//
psi=ppsi*psi(-1)+epsi;
//14: Real Exchange Rate//
rer=rer(-1)+deltae+pistar-pi;
//15: Foregin Inflation rate AR(1)//
pistar=ppistar*pistar(-1)+epistar;
//16: The relation among the real pice of oil, the real price of Home goods, and the real exchange rate//
0=delta*pro+((1-delta)*gamma*prh)+(1-delta)*(1-gamma)*rer;

//Aggregate Equilibrium//
//17: Market Clearing Condition for Home Good Sector//
yh=chyh*ch+(1-chyh)*cstar-etastar*(1-chyh)*(prh-rer);
//18: Total GDP//
y=cy*c+xy*x-my*m;
//19: Total Export//
x=-etastar*(chstarx)*(prh-rer)+chstarx*cstar;
//20: Foreign Consumption Ar(1);
cstar=pcstar*cstar(-1)+ecstar;
//21: Total Import//
m=(cfm)*cf+(1-cfm)*o;
//22: Total Oil//
o=(oco*oc)+(oho*oh);

//Added: not sure if it is right to add this//
deltae=pdeltae*(deltae(-1))+edeltae;

end;

initval;
ch  =   0;
rer =   0;
prh =   0;
c   =   0;
cf  =   0;
oc  =   0;
pro =   0;
pi  =   0;
pih =   0;
oh  =   0;
l   =   0;
wr  =   0;
yh  =   0;
ah  =   0;
prostar =   0;
psi     =   0;
deltae  =   0;
pistar  =   0;
cstar   =   0;
y       =   0;
x       =   0;
m       =   0;
o       =   0;
end;
steady;
check;


shocks;
var ea; stderr 3.019 ; //medina and soto
var eo; stderr .134; //medina and soto
var epsi; stderr 5.376; //medina and soto
var epistar; stderr 1.167; //medina and soto
var ecstar; stderr 4.659; //medina and soto
var edeltae; stderr .018;
end;
model_diagnostics;
//stoch_simul;


Re: Need help with the Medina and Soto(2005) model

PostPosted: Tue Jun 21, 2016 11:43 pm
by AbrahamVela
Hi:

Despite your simplification, only a few people will have the time to review you code in detail. Especially if there is a missing equation and they are not fully familiar with the paper.
There is a versión of the Dynare Code by the same authors for another 2007 paper in the Macroeconomic Models Database. It might prove useful as a starting point.
Have you tried to reach the authors to get their code and start from there? If not, I suggest you do so.
It is the easiest and safe way to go.

Best,
Abe

Re: Need help with the Medina and Soto(2005) model

PostPosted: Tue Jun 21, 2016 11:54 pm
by AbrahamVela
By the way, when this is happenned to me, what I do is to simplify the model as much as posible.
Once I get the oversimplified versión working, I start to add the additional features one by one and make sure each one of the new versions work.
This has helped me to identify what my mistakes are, including the Blanchard-Khan condition, missing equations, and the like.
Good luck,
Abe

Re: Need help with the Medina and Soto(2005) model

PostPosted: Wed Jun 22, 2016 12:09 am
by AbrahamVela
One more thing: Your Euler equation looks rather odd to me. I can see you are ruling out habit persistence. But Euler equations tend to be a little bit more complicated than what you have. In fact, when I look at equation A5 in Medina and Soto (2005) paper, the Euler equation is much more elaborated than what you have. They have a second order stochastic diffrence equation for log-deviations from consumption from the steady state, plus the deviation of the nominal interest rate (which you do not have) and the expected next period inflation rate. Why is it that you do not have the nominal interest rate?