Need help with the Medina and Soto(2005) model

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

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,

parameters gamma,theta,eta,B,omega,alpha,pa,sigmaL,po,ppsi,ppistar,etastar,delta,chyh,cy,xy,my,chstarx,pcstar,cfm,oco,oho,
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//


//Aggregate Demand//
//1 Domestic Consumption of Home goods
//2 Domestic Consumption of Foreign goods//
//3: Domestic Consumption of Oil goods//
//4: Euler Equation//

//Aggregate Supply and Inflation//
//5: Passive Resetting price equation//
//6: Optimal input//
//7: Production Funtion//
//8: Technology process//
//9: Marginal rate of substitution between labor and consumption//

//Relative Prices//
//10: Real price of home goods//
//11: Real price of oil//
//12: The process of real price oil abroad with respect to foreign index AR(1)//
//13: The deviation from law of one price -> the oil stabilization fund//
//14: Real Exchange Rate//
//15: Foregin Inflation rate AR(1)//
//16: The relation among the real pice of oil, the real price of Home goods, and the real exchange rate//

//Aggregate Equilibrium//
//17: Market Clearing Condition for Home Good Sector//
//18: Total GDP//
//19: Total Export//
//20: Foreign Consumption Ar(1);
//21: Total Import//
//22: Total Oil//

//Added: not sure if it is right to add this//


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; 

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;


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.


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,

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?