Error using ==> dynare
Posted: Mon Aug 30, 2010 10:23 am
Hi:
Recently I am working on a two-country open economy model, combining BGG(1999) and Obstfeld & Rogoff(1995). I assume the home country's currency is pegged to the foreign country's, and in each period, a fixed portion of foreign net worth enters home country as FDI, but the short-term foreign debt, as well as other forms short-term capital flows are forbidden in the home country. Therefore, since home country's currency is pegged, it has to use money base to balance its current account and FDI account to stabilize the exchange rate.
As a beginner of Dynare, I found that the following problems keeps showing in my Matlab after I fed Dynare the parameter value and F.O.Cs of the model.
I hope someone will help debug my Dynare programme here(when I write this programme I refer to the BGG programme a lot, see atachment). My model's F.O.Cs are also presented in the attachment.Thanks !
My programme starts:
// Bin Zhu
// Aug 10
// intial: rU is rU(-1);kU is kU(-1)
// BGG and FDI open economy model, code for Dynare
// assume flexible price
// variablenamef is the foreign counterpart
var y_w , e, rs, t_U; // involve both countries;tU is trade balance of home country; rs is foreign reserve of home country; y_w is world output
var cU , i , mo, k , q ,y, yh, x, ph, h , p, pi , r , n , ce , rk , efp , aU, gU, m; // for home country; mo is monitoring cost
var cfU , i_f , mof, kf , qf , yf, yhf, xf, phf, hf , pf, pif , rf , nf , cef , rkf , efpf , af, gf, mf; // for foreign country
varexo e_gU, e_aU, ksi, e_gf, e_af, ksif;
parameters epsl,TB_F,FDI_F,v,mkup,E,Rg;
parameters CY_w,CeY_w,IY_w,GY_w,MoY_w,kn,yn,Rk,beta,eta,ita,zeta,alphaK,delta,phi,omega,gamma,psiz,GDP_TB,nomC_TB,nomI_TB,nomG_TB,nomCe_TB,nomMo_TB; // for home country
parameters CY_wf,CeY_wf,IY_wf,GY_wf,MoY_wf,knf,ynf,Rkf,betaf,etaf,itaf,zetaf,alphaKf,deltaf,phif,omegaf,vf,gammaf,psizf; // for foreign country
epsl = 0.957593537 ; //degree of substitution, the more the larger
TB_F = 0.78 ; // ratio of trade balance trend and foreign reserve trend for home country
FDI_F = 0.22 ; // ratio of net FDI trend and foreign reserve trend
mkup = 1.1 ; //%X: steady state value
v = 0.2;//proportion of FDI
E = 1;//steady state value of exchange rate
Rg = 0.03;//nominal net interest rate of foreign government bond
CY_w = 0.1 ; CY_wf = 0.2;// nC/Y_w: long-term trend of national consumption share of world demand
CeY_w = 0.005 ; CeY_wf = 0.005 ;// nCe/Y_w
IY_w = 0.184229809 ; IY_wf = 0.184229809;// nI/Y_w
GY_w = 0.2 ; GY_wf = 0.1;// nG/Y_w
MoY_w = 0.015 ; MoY_wf = 0.015;// nMo/Y_w
kn = 1.081759973 ; knf = 2.081759973;//K/N: economic-wide leverage rate
yn = 0.3 ; ynf = 0.282494996 ;//%Y/N: ratio of output and net worth
Rk = 2.018177298 ; Rkf = 1.018177298 ;//expected gross return of one unit physical capital
beta = 0.99 ; betaf = 0.99;//calibrated by risk-free interest rate
eta = 2.89 ; etaf = 3;//steady state value of the ratio of leisure hours over working hours
ita = 0.052092347 ; itaf = 0.052092347;//coefficient in loan demand equation
zeta = 0.9576 ; zetaf = 0.9576; //coefficient in capital demand equation
alphaK = 0.4 ; alphaKf = 0.35;//capital share in wholesale goods production
delta = 0.03 ; deltaf = 0.025 ;//capital depreciation rate
phi = 0.25 ; phif = 0.25;//coefficient in investment demand equation
omega = 0.97; omegaf = 0.984615;//ordinary worker's labor share in entire labor input
gamma = 0.9728 ; gammaf = 0.9728;//survival rate of entrepreneurs
psiz = 0.996; psizf = 0.996;//autoregressive coefficien of technology shock
GDP_TB = 12; // nominal GDP over nominal trade balance for home country
nomC_TB = 4.48;
nomI_TB = 5.97;
nomG_TB = 1.634;
nomCe_TB = 1;
nomMo_TB = 1.05;
R = 1/beta ; Rf = 1/betaf;
model;
mo = rk + q(-1) + k; //definition of mo
mof = rkf + qf(-1) + kf; //definition of mof
y_w = (CY_w*cU + CY_wf*cfU) + (IY_w*i + IY_wf*i_f) + (GY_w*gU + GY_wf*gf) + (CeY_w*ce + CeY_wf*cef) + (MoY_w*mo + MoY_wf*mof); //aggregate demand
cU = -r + cU(+1); //4.15 Euler equation
cfU = -rf + cfU(+1); //4.15*
ce = n; //4.16 entrepreneurs' demand
cef = nf; //4.16*
m - p = -cU - beta/(1-beta)*r(+1) + beta/(1-beta)*pi(+1); //money demand
mf - pf = -cfU - betaf/(1-betaf)*rf(+1) + betaf/(1-betaf)*pif(+1); //money demand
pi = p - p(-1); //definition of inflation
pif = pf - pf(-1);
efp = rk(+1) - r; //definition of premium
efpf = rkf(+1) - rf; //definition of premium*
rk(+1) - r = -ita*(n-q-k); //4.17 loan demand
rkf(+1) - rf = -itaf*(nf-qf-kf); //4.17*
rk = (1-zeta)*(y-k(-1)-x) + zeta*q - q(-1); //4.18 capital demand
rkf = (1-zetaf)*(yf-kf(-1)-xf) + zetaf*qf - qf(-1); //4.18*
q = phi*(i-k(-1)); //4.19 investment demand
qf = phif*(i_f-kf(-1)); //4.19*
y = aU + alphaK*k(-1)+(1-alphaK)*omega*h; //4.20 wholesale goods supply
yf = af + alphaKf*kf(-1)+(1-alphaKf)*omegaf*hf; //4.20*
yh = -epsl*(ph - p) + y_w; //diversified product supply
yhf = -epsl*(phf - pf) + y_w; //
yh = y;
yhf = yf;
y - h - x - cU = eta^(-1)*h; //4.21 labor market equilibrium
yf - hf - xf - cfU = etaf^(-1)*hf; //4.21*
p = n*ph + (1-n)*(e + phf) ;//price evolution
pf = n*(ph-e) + (1-n)*phf ;
ph = p - x ;//optimal price setting
phf = ph - xf ;
m - m(-1) = e + (rs - rs(-1)) + ksi; // money supply
mf - mf(-1) = ksif;
e = 0; // fixed exchange rate regime
k = delta*i + (1-delta)*k(-1); //4.23 capital formation
kf = deltaf*i_f + (1-deltaf)*kf(-1); //4.23*
n = gamma/beta*n(-1) + ((gamma/beta)-((gamma*kn)/beta))*r + ((gamma*kn)/beta+((gamma*kn)*(Rk-(1/beta))))*rk +((gamma*kn)*(Rk-(1/beta)))*q(-1) + ((gamma*kn)*(Rk-(1/beta)))*k + ((1-alphaK)*(1-omega)*yn/mkup)*(y-x) + v*E*nf; //4.24 net worth evolution
nf = (1-v)*gammaf/betaf*nf(-1) + ((1-v)*(gammaf/betaf)-((gammaf*knf)/betaf))*rf + ((gammaf*knf)/betaf+((gammaf*knf)*(Rkf-(1/betaf))))*rkf +((gammaf*knf)*(Rkf-(1/betaf)))*qf(-1) + ((gammaf*knf)*(Rkf-(1/betaf)))*kf + ((1-alphaKf)*(1-omegaf)*ynf/mkup)*(yf-xf); //4.24
rs = (1+Rg)*rs(-1) + TB_F*t_U + FDI_F*(nf + pf + e) // foreign reserve
t_U = GDP_TB*(epsl*p + y_w + (1-epsl)*ph) - nomC_TB*(p+cU) - nomI_TB*(p+i) - nomG_TB*(p+gU) - nomCe_TB*(p+ce) - nomMo_TB*(p+mo);
gU = 0.95*gU(-1) + e_gU; //government purchase shock process, 4.26
gf = 0.95*gf(-1) + e_gf; //government purchase shock process, 4.26*
aU = psiz*aU(-1) + e_aU; //4.27 technology shock
af = psizf*af(-1) + e_af; //4.27*
end;
//initval;
//end;
shocks;
var e_gU; stderr 0.0155;
//var e_gU; stderr 0;
var e_aU; stderr 0.0043;
//var e_aU; stderr 0;
var ksi;stderr 0.06;
var e_gf; stderr 0.0155;
//var e_gf; stderr 0;
var e_af; stderr 0.0043;
//var e_af; stderr 0;
var ksif;stderr 0.06;
end;
steady(solve_algo=2);
check;
stoch_simul(order=1,irf=20) y cU i efp n rn pi r rk yf cfU i_f efpf nf rnf pif rf rkf;
Matlab result:
Starting Dynare (version 4.1.2).
Starting preprocessing of the model file ...
ERROR: Untitled3.mod:94.1-3: syntax error, unexpected NAME
??? Error using ==> dynare
DYNARE: preprocessing failed
Recently I am working on a two-country open economy model, combining BGG(1999) and Obstfeld & Rogoff(1995). I assume the home country's currency is pegged to the foreign country's, and in each period, a fixed portion of foreign net worth enters home country as FDI, but the short-term foreign debt, as well as other forms short-term capital flows are forbidden in the home country. Therefore, since home country's currency is pegged, it has to use money base to balance its current account and FDI account to stabilize the exchange rate.
As a beginner of Dynare, I found that the following problems keeps showing in my Matlab after I fed Dynare the parameter value and F.O.Cs of the model.
I hope someone will help debug my Dynare programme here(when I write this programme I refer to the BGG programme a lot, see atachment). My model's F.O.Cs are also presented in the attachment.Thanks !
My programme starts:
// Bin Zhu
// Aug 10
// intial: rU is rU(-1);kU is kU(-1)
// BGG and FDI open economy model, code for Dynare
// assume flexible price
// variablenamef is the foreign counterpart
var y_w , e, rs, t_U; // involve both countries;tU is trade balance of home country; rs is foreign reserve of home country; y_w is world output
var cU , i , mo, k , q ,y, yh, x, ph, h , p, pi , r , n , ce , rk , efp , aU, gU, m; // for home country; mo is monitoring cost
var cfU , i_f , mof, kf , qf , yf, yhf, xf, phf, hf , pf, pif , rf , nf , cef , rkf , efpf , af, gf, mf; // for foreign country
varexo e_gU, e_aU, ksi, e_gf, e_af, ksif;
parameters epsl,TB_F,FDI_F,v,mkup,E,Rg;
parameters CY_w,CeY_w,IY_w,GY_w,MoY_w,kn,yn,Rk,beta,eta,ita,zeta,alphaK,delta,phi,omega,gamma,psiz,GDP_TB,nomC_TB,nomI_TB,nomG_TB,nomCe_TB,nomMo_TB; // for home country
parameters CY_wf,CeY_wf,IY_wf,GY_wf,MoY_wf,knf,ynf,Rkf,betaf,etaf,itaf,zetaf,alphaKf,deltaf,phif,omegaf,vf,gammaf,psizf; // for foreign country
epsl = 0.957593537 ; //degree of substitution, the more the larger
TB_F = 0.78 ; // ratio of trade balance trend and foreign reserve trend for home country
FDI_F = 0.22 ; // ratio of net FDI trend and foreign reserve trend
mkup = 1.1 ; //%X: steady state value
v = 0.2;//proportion of FDI
E = 1;//steady state value of exchange rate
Rg = 0.03;//nominal net interest rate of foreign government bond
CY_w = 0.1 ; CY_wf = 0.2;// nC/Y_w: long-term trend of national consumption share of world demand
CeY_w = 0.005 ; CeY_wf = 0.005 ;// nCe/Y_w
IY_w = 0.184229809 ; IY_wf = 0.184229809;// nI/Y_w
GY_w = 0.2 ; GY_wf = 0.1;// nG/Y_w
MoY_w = 0.015 ; MoY_wf = 0.015;// nMo/Y_w
kn = 1.081759973 ; knf = 2.081759973;//K/N: economic-wide leverage rate
yn = 0.3 ; ynf = 0.282494996 ;//%Y/N: ratio of output and net worth
Rk = 2.018177298 ; Rkf = 1.018177298 ;//expected gross return of one unit physical capital
beta = 0.99 ; betaf = 0.99;//calibrated by risk-free interest rate
eta = 2.89 ; etaf = 3;//steady state value of the ratio of leisure hours over working hours
ita = 0.052092347 ; itaf = 0.052092347;//coefficient in loan demand equation
zeta = 0.9576 ; zetaf = 0.9576; //coefficient in capital demand equation
alphaK = 0.4 ; alphaKf = 0.35;//capital share in wholesale goods production
delta = 0.03 ; deltaf = 0.025 ;//capital depreciation rate
phi = 0.25 ; phif = 0.25;//coefficient in investment demand equation
omega = 0.97; omegaf = 0.984615;//ordinary worker's labor share in entire labor input
gamma = 0.9728 ; gammaf = 0.9728;//survival rate of entrepreneurs
psiz = 0.996; psizf = 0.996;//autoregressive coefficien of technology shock
GDP_TB = 12; // nominal GDP over nominal trade balance for home country
nomC_TB = 4.48;
nomI_TB = 5.97;
nomG_TB = 1.634;
nomCe_TB = 1;
nomMo_TB = 1.05;
R = 1/beta ; Rf = 1/betaf;
model;
mo = rk + q(-1) + k; //definition of mo
mof = rkf + qf(-1) + kf; //definition of mof
y_w = (CY_w*cU + CY_wf*cfU) + (IY_w*i + IY_wf*i_f) + (GY_w*gU + GY_wf*gf) + (CeY_w*ce + CeY_wf*cef) + (MoY_w*mo + MoY_wf*mof); //aggregate demand
cU = -r + cU(+1); //4.15 Euler equation
cfU = -rf + cfU(+1); //4.15*
ce = n; //4.16 entrepreneurs' demand
cef = nf; //4.16*
m - p = -cU - beta/(1-beta)*r(+1) + beta/(1-beta)*pi(+1); //money demand
mf - pf = -cfU - betaf/(1-betaf)*rf(+1) + betaf/(1-betaf)*pif(+1); //money demand
pi = p - p(-1); //definition of inflation
pif = pf - pf(-1);
efp = rk(+1) - r; //definition of premium
efpf = rkf(+1) - rf; //definition of premium*
rk(+1) - r = -ita*(n-q-k); //4.17 loan demand
rkf(+1) - rf = -itaf*(nf-qf-kf); //4.17*
rk = (1-zeta)*(y-k(-1)-x) + zeta*q - q(-1); //4.18 capital demand
rkf = (1-zetaf)*(yf-kf(-1)-xf) + zetaf*qf - qf(-1); //4.18*
q = phi*(i-k(-1)); //4.19 investment demand
qf = phif*(i_f-kf(-1)); //4.19*
y = aU + alphaK*k(-1)+(1-alphaK)*omega*h; //4.20 wholesale goods supply
yf = af + alphaKf*kf(-1)+(1-alphaKf)*omegaf*hf; //4.20*
yh = -epsl*(ph - p) + y_w; //diversified product supply
yhf = -epsl*(phf - pf) + y_w; //
yh = y;
yhf = yf;
y - h - x - cU = eta^(-1)*h; //4.21 labor market equilibrium
yf - hf - xf - cfU = etaf^(-1)*hf; //4.21*
p = n*ph + (1-n)*(e + phf) ;//price evolution
pf = n*(ph-e) + (1-n)*phf ;
ph = p - x ;//optimal price setting
phf = ph - xf ;
m - m(-1) = e + (rs - rs(-1)) + ksi; // money supply
mf - mf(-1) = ksif;
e = 0; // fixed exchange rate regime
k = delta*i + (1-delta)*k(-1); //4.23 capital formation
kf = deltaf*i_f + (1-deltaf)*kf(-1); //4.23*
n = gamma/beta*n(-1) + ((gamma/beta)-((gamma*kn)/beta))*r + ((gamma*kn)/beta+((gamma*kn)*(Rk-(1/beta))))*rk +((gamma*kn)*(Rk-(1/beta)))*q(-1) + ((gamma*kn)*(Rk-(1/beta)))*k + ((1-alphaK)*(1-omega)*yn/mkup)*(y-x) + v*E*nf; //4.24 net worth evolution
nf = (1-v)*gammaf/betaf*nf(-1) + ((1-v)*(gammaf/betaf)-((gammaf*knf)/betaf))*rf + ((gammaf*knf)/betaf+((gammaf*knf)*(Rkf-(1/betaf))))*rkf +((gammaf*knf)*(Rkf-(1/betaf)))*qf(-1) + ((gammaf*knf)*(Rkf-(1/betaf)))*kf + ((1-alphaKf)*(1-omegaf)*ynf/mkup)*(yf-xf); //4.24
rs = (1+Rg)*rs(-1) + TB_F*t_U + FDI_F*(nf + pf + e) // foreign reserve
t_U = GDP_TB*(epsl*p + y_w + (1-epsl)*ph) - nomC_TB*(p+cU) - nomI_TB*(p+i) - nomG_TB*(p+gU) - nomCe_TB*(p+ce) - nomMo_TB*(p+mo);
gU = 0.95*gU(-1) + e_gU; //government purchase shock process, 4.26
gf = 0.95*gf(-1) + e_gf; //government purchase shock process, 4.26*
aU = psiz*aU(-1) + e_aU; //4.27 technology shock
af = psizf*af(-1) + e_af; //4.27*
end;
//initval;
//end;
shocks;
var e_gU; stderr 0.0155;
//var e_gU; stderr 0;
var e_aU; stderr 0.0043;
//var e_aU; stderr 0;
var ksi;stderr 0.06;
var e_gf; stderr 0.0155;
//var e_gf; stderr 0;
var e_af; stderr 0.0043;
//var e_af; stderr 0;
var ksif;stderr 0.06;
end;
steady(solve_algo=2);
check;
stoch_simul(order=1,irf=20) y cU i efp n rn pi r rk yf cfU i_f efpf nf rnf pif rf rkf;
Matlab result:
Starting Dynare (version 4.1.2).
Starting preprocessing of the model file ...
ERROR: Untitled3.mod:94.1-3: syntax error, unexpected NAME
??? Error using ==> dynare
DYNARE: preprocessing failed