Hi, I’m writing my mod.file for the master thesis and I encountered some problems. For example, now the mod doesn’t run due to an error message about wrong declaration of i (used as index in order to define the presence of two countries). Why is this happening (I tried several other command but without success? Could you also point out any other errors you notice?
Thanks very much in advance
// Financial heterogeneity between two countries.
// Monetary, government spending, energy cost-push shocks.
// Differences in proportion of small-medium firms and big firms. Type of firms distinguishs for values of alpha
define N=2
define countries=1:N
for i in countries
var y_@{i} ysme_@{i} ybf_@{i} c_@{i} Isme_@{i} Ibf_@{i} ksme_@{i} kbf_@{i} Qsme_@{i} Qbf_@{i} r_@{i} rhosme_@{i} rhobf_@{i} asme_@{i} abf_@{i} H_@{i} Hhsme_@{i} Hhbf_@{i} W_@{i}
pi1_@{i} pi_@{i} rK_@{i} n_@{i} nb_@{i} se_@{i} sb_@{i} rb_@{i} csme_@{i} cB_@{i} G_@{i} MC_@{i} rn_@{i} Psme_@{i} Pbf_@{i} esme_@{i} ebf_@{i} Pe_@{i} I_@{i} ;
parameters n_ksme_@{i} ksme_n_@{i} rbar_@{i} rBbar_@{i} k_y_@{i} y_k_@{i} psi_@{i} psib_@{i} gammaf_@{i} rhosmebar_@{i} rhobfbar_@{i} rhop_@{i} rhoasme_@{i} rhoabf_@{i} ybar_@{i}
alpha_@{i} delta_@{i} theta_@{i} sigc_@{i} beta_@{i} sigh_@{i} csme_y_@{i} c_y_@{i} Isme_ysme_@{i} Ibf_ybf_@{i} ksmebar_@{i} kbfbar_@{i} esmebar_@{i} ebfbar_@{i} ysmebar_@{i} ybfbar_@{i} Wbar_@{i}
esme_ysme_@{i} ebf_ybf_@{i} G_y_@{i} rhog_@{i} phi_@{i} rhoa_@{i} Hbar_@{i} phi1_@{i} phi2_@{i} eps_@{i} Psmebar_@{i} Pbfbar_@{i} Pebar_@{i} rKbar_@{i} gammab_@{i} Ismebar_@{i} Ibfbar_@{i}
tb_@{i} nb_b_@{i} nb_ksme_@{i} ksme_nb_@{i} n_nb_@{i} nnb_nb_@{i} nb_nnb_@{i} n_nnb_@{i} cB_y_@{i} eta_@{i} sigma_@{i} rhoe_@{i} epsilon_@{i} b_@{i} Xi_@{i} vf_@{i} Qbfbar_@{i} Qsmebar_@{i};
end;
var z y_UM pi_UM v rpm pibar_UM ybar_UM ;
parameters gamma bet0 bet1 bet2 tau1 tau2 sebar sbbar ;
varexo Serpm Seasme Seabf Seg See ; // the latter is shock to energy price ;
// calibration of exogenous parameters
for i in countries
alpha_@{i} = 0.33; // Share of contribution of capital and energy on GDP
delta_@{i} = 0.03; // Depreciation of capital
theta_@{i} = 10.0; // Capital adjustment costs parameter
sigc_@{i} = 0.75; // Intertemporal elasticity of substitution
beta_@{i} = 0.99; // Discount factor
sigh_@{i} = 0.32; // Elasticity of labor disutility
rhog_@{i} = 0.95; // Persitence of government spending
rhoa_@{i} = 0.97; // Persistence of technological shock
gammaf_@{i} = 0.9831; // small-medium firms probability to survive
gammab_@{i} = 0.99; // bank probability to survive
tb_@{i} = 0.001; // part of capital trasferts to survival bank
psi_@{i} = 0.025; // small-medium enterprises external financial premium elasticity
eta_@{i} = 1.1; // value that multilpies the value of marginal costs inside PC
sigma_@{i} = 6; // value of rigidity, i.e. cost of adjustment of price
b_@{i} = 0.045; //share of energy on production
rhoe_@{i} = 0.95; // persistence of energy price shock process, calibrated as in Wei
epsilon_@{i} = 0.4; // CES production function of retailers parameter
vf_@{i} = -0.9; // CES capital/eneergy sobstitution parameter
end;
gamma=0.8; // "importance" of other country motions to domestic economy
bet0 = 0.9;
bet1= 1.1;
bet2 = 0;
psib_1=0.002; // banks external financial premium elasticity country 1
psib_2=0.002; // banks external financial premium elasticity country 2
nb_b_1=0.10; // Banks inside capital/loans ratio country 1
nb_b_2=0.10; // Banks inside capital/loans ratio country 2
tau1=0.7; //share on retailer production of big firms input country 1
tau2=0.3; // share on retailer production of big firms input country 2
//steady state
for i in countries
rhosmebar_@{i} = 1/1.1;
rhobfbar_@{i} = 1/1.1 ;
G_y_@{i} = 0.16;
n_ksme_@{i}=0.4;
//nb_b_@{i}=0.2;
Qsmebar_@{i}=1;
Qbfbar_@{i}=1;
ksme_n_@{i}=1/n_ksme_@{i};
nb_ksme_@{i}=nb_b_@{i}*(1-n_ksme_@{i});
ksme_nb_@{i}=1/nb_ksme_@{i};
n_nb_@{i}=n_ksme_@{i}*ksme_nb_@{i};
nnb_nb_@{i}=1+n_nb_@{i};
nb_nnb_@{i}=1/nnb_nb_@{i};
n_nnb_@{i}=1-nb_nnb_@{i};
rbar_@{i} = 1/beta_@{i}; //it would be both return of household and big firm rate on loans
rKbar_@{i}=rbar_@{i}+0.005; //Rate sme > Rate bf
ksme_ysme_@{i} = (alpha_@{i}*rhosmebar_@{i})/(rKbar_@{i}-(1-delta_@{i}));
kbf_ybf_@{i} = (alpha_@{i}*rhobfbar_@{i})/(rbar_@{i}-(1-delta_@{i}));
csme_y_@{i}=(1-gammaf_@{i})/gammaf_@{i}*n_ksme_@{i}*ksme_ysme_@{i};
cB_y_@{i}=(1-gammab_@{i})*(1-tb_@{i})/(gammab_@{i}*(1-tb_@{i})+tb_@{i})*nb_ksme_@{i}*ksme_y_@{i};
ysme_ksme_@{i}= 1/ksme_ysme_@{i};
ybf_kbf_@{i}= 1/kbf_ybf_@{i};
Isme_ysme_@{i} = delta_@{i}*ksme_ysme_@{i};
Ibf_ybf_@{i} = delta_@{i}*kbf_ybf_@{i};
c_y_@{i} = 1 - G_y_@{i} - Isme_ysme_@{i} - Ibf_ybf_@{i} - csme_y_@{i} - cB_y_@{i} ;
esme_ysme_@{i}=rhosmebar_@{i}*alpha_@{i}/Pebar_@{i};
ebf_ybf_@{i}=rhobfbar_@{i}*alpha_@{i}/Pebar_@{i};
Psmebar_@{i}=1/1.1 ;
Pbfbar_@{i}=1/1.1 ;
end;
if i == 1
ybf_ysme_@{i}= tau1^(epsilon)/((1-tau1)^epsilon) ;
else
ybf_ysme_@{i+1}=tau2^(epsilon)/(1-tau2)^epsilon) ;
end;
model (linear);
for i in countries
rhosme_@{i}=Psme_@{i}; // use this in order to do not change the rhosme
rhobf_@{i}=Pbf_@{i}; // use this in order to do not change the rhobf
//input of sme demanded by retailers
ysme_@{i}=(-epsilon_@{i}*Psme_@{i})+y_@{i}+(epsilon_@{i}*MC_@{i});
//input of bf demanded by retailers
ybf_@{i}=(-epsilon_@{i}*Pbf_@{i})+y_@{i}+(epsilon_@{i}*MC_@{i});
//production funct of wholesale producers: sme
ysme_@{i}=asme_@{i}+(alpha_@{i}*(ksmebar_@{i}^vf_@{i})*b_@{i}*ksme_@{i}+alpha_@{i}*(1-b_@{i})*(esmebar_@{i}^vf_@{i})*esme_@{i})/(b_@{i}*(ksmebar_@{i}^vf_@{i})+(1-b_@{i})*(esmebar_@{i}^vf_@{i}))+Hhsme_@{i}*(1-alpha_@{i}) ;
//production funct of wholesale producers: bf
ybf_@{i}=abf_@{i}+(alpha_@{i}*(kbfbar_@{i}^vf_@{i})*b_@{i}*kbf_@{i}+alpha_@{i}*(1-b_@{i})*(ebfbar_@{i}^vf_@{i})*ebf_@{i})/(b_@{i}*(kbfbar_@{i}^vf_@{i})+(1-b_@{i})*(ebfbar_@{i}^vf_@{i}))+Hhbf_@{i}*(1-alpha_@{i}) ;
//equation of equilibrium in labor market
H_@{i}=(Hhsme_@{i}/Hbar_@{i})+(Hhbf_@{i}/Hbar_@{i});
//Capital accumulation of sme
ksme_@{i}=(1-delta_@{i})*ksme_@{i}(-1) + delta_@{i}*Isme_@{i};
//Capital accumulation of bf
kbf_@{i}=(1-delta_@{i})*kbf_@{i}(-1) + delta_@{i}*Ibf_@{i};
//net worth of bank
nb_@{i}=(gammab_@{i}*(1-tb_@{i})+tb_@{i})*rKbar_@{i}*((1/nb_b_@{i}-1)*(rK_@{i}-r_@{i}(-1))+rbar_@{i}/rKbar_@{i}*r_@{i}(-1)+rbar_@{i}/rKbar_@{i}*nb_@{i}(-1)-(1/nb_b_@{i}-1)*sb_@{i}(-1));
// external financial premium
rK_@{i}(+1)=r_@{i}+psi_@{i}*(-n_nnb_@{i}*n_@{i}-nb_nnb_@{i}*nb_@{i}+Qsme_@{i}+ksme_@{i});
rb_@{i}=r_@{i}+psib_@{i}*(-n_nb_@{i}*nb_b_@{i}*n_@{i}-nb_@{i}+ksme_nb_@{i}*nb_b_@{i}*(Qsme_@{i}+ksme_@{i}));
se_@{i}=rK_@{i}(+1)-r_@{i}; //remind that this holds only of small-medium enterprises
sb_@{i}=rb_@{i}-r_@{i}; //same of se
//Investment of sme
Qsme_@{i} = theta_@{i}*delta_@{i}*Isme_@{i} - theta_@{i}*delta_@{i}*ksme_@{i}(-1);
//Investment of bf
Qbf_@{i} = theta_@{i}*delta_@{i}*Ibf_@{i} - theta_@{i}*delta_@{i}*kbf_@{i}(-1);
//aggregate investment
I_@{i}=Ibf_@{i}+Isme_@{i};
//price of wholesale good offered by sme
Psme_@{i}=ysme_@{i}*((1/(vf_@{i}-1))*((vf_@{i}/alpha_@{i})-1)-((ysmebar_@{i}-(Wbar_@{i}/ysmebar_@{i}*(1-alpha_@{i}))^(-1))*(1-(((1-alpha_@{i})*Wbar_@{i})/(ysmebar_@{i}-alpha_@{i}*ysmebar_@{i})^2))))+(((ysmebar_@{i}^((vf_@{i}/alpha_@{i})-1))/alpha_@{i})^(1/(vf_@{i}-1)))*((1-b_@{i})^(1/(1-vf_@{i})))*(Pebar_@{i}^(vf_@{i}/(1-vf_@{i})))*(vf_@{i}/(vf_@{i}-1))*(Pe_@{i})/(Psmebar_@{i}*((ysmebar_@{i}-(Wbar_@{i}/(ysmebar_@{i}-alpha_@{i}*ysmebar_@{i})))))+((ysmebar_@{i}^((vf_@{i}/alpha_@{i})-1)/alpha_@{i})^(1/(1-vf_@{i})))*(b_@{i}^(1/(1-vf_@{i})))*(rKbar_@{i}^(vf_@{i}/(vf_@{i})-1))*(vf_@{i}/(vf_@{i}-1))*(rK_@{i})+(((ysmebar_@{i}^((vf_@{i}/(alpha_@{i})-1)))/alpha_@{i})^(1/(vf_@{i}-1)))*((Pebar_@{i}^(vf_@{i}/(vf_@{i}-1)))*((1-b_@{i})^(1/(1-vf_@{i})))+(rKbar_@{i}^(vf_@{i}/(1-vf_@{i})))*(b_@{i}^(1/(1-vf_@{i}))))*(-1/(ysmebar_@{i}-(alpha_@{i}*ysmebar_@{i})))*W_@{i}*Wbar_@{i};
//price of wholesale good offered by bf
Pbf_@{i}=ybf_@{i}*((1/(vf_@{i}-1))*((vf_@{i}/alpha_@{i})-1)-((ybfbar_@{i}-(Wbar_@{i}/ybfbar_@{i}*(1-alpha_@{i}))^(-1))*(1-(((1-alpha_@{i})*Wbar_@{i})/(ybfbar_@{i}-alpha_@{i}*ybfbar_@{i})^2))))+(((ybfbar_@{i}^((vf_@{i}/alpha_@{i})-1))/alpha_@{i})^(1/(vf_@{i}-1)))*((1-b_@{i})^(1/(1-vf_@{i})))*(Pebar_@{i}^(vf_@{i}/(1-vf_@{i})))*(vf_@{i}/(vf_@{i}-1))*(Pe_@{i})/(Pbfbar_@{i}*((ybfbar_@{i}-(Wbar_@{i}/(ybfbar_@{i}-alpha_@{i}*ybfbar_@{i})))))+((ybfbar_@{i}^((vf_@{i}/alpha_@{i})-1)/alpha_@{i})^(1/(1-vf_@{i})))*(b_@{i}^(1/(1-vf_@{i})))*(rbar_@{i}^(vf_@{i}/(vf_@{i})-1))*(vf_@{i}/(vf_@{i}-1))*(r_@{i})+(((ybfbar_@{i}^((vf_@{i}/(alpha_@{i})-1)))/alpha_@{i})^(1/(vf_@{i}-1)))*((Pebar_@{i}^(vf_@{i}/(vf_@{i}-1)))*((1-b_@{i})^(1/(1-vf_@{i})))+(rbar_@{i}^(vf_@{i}/(1-vf_@{i})))*(b_@{i}^(1/(1-vf_@{i}))))*(-1/(ybfbar_@{i}-(alpha_@{i}*ybfbar_@{i})))*W_@{i}*Wbar_@{i};
//consumption of household
c_@{i} = c_@{i}(+1)-sigc_@{i}*r_@{i};
//consumption of sme // doesn't exist for bf as they don't declare bankaruptcy
csme_@{i}=n_@{i};
//consumption of bank
cB_@{i}=nb_@{i};
//labor supply faced by both bf and sme
H_@{i}=(-sigh_@{i}/sigc_@{i})*c_@{i}+(sigh_@{i}*W_@{i});
//interest rate short term motion
r_@{i} = rpm - pi_@{i}(+1);
//technological shock of sm
asme_@{i} = rhoasme_@{i}*asme_@{i}(-1) - Seasme ;
//technological shock of bf
abf_@{i} = rhoabf_@{i}*abf_@{i}(-1) - Seabf;
//shock of government spending
G_@{i} = rhog_@{i}*G_@{i}(-1) + Seg ;
// energy price shock
Pe_@{i} = rhop_@{i}*Pe_@{i}(-1) + See ;
end;
if i == 1 //different equations between two countries
pi_@{i}=gamma*pi1_@{i}+(1-gamma)*pi1_@{i+1} ; // value of inflation in first country
c_@{i}=c_@{i+1}+sigc_@{i}*v(-1) ; // aggregate consumption
y_@{i} = c_y_@{i}*c_@{i} + c_y_@{i}*((1-gamma)*(1-sigc_@{i})+(1-gamma)/(2*gamma-1))*v(-1)+(Ibf_ybf_@{i}+Isme_ysme_@{i})*I_@{i} + G_y_@{i}*G_@{i} +csme_y_@{i}*csme_@{i}+cB_y_@{i}*cB_@{i}; //resource constraint-->to modify
rhosme_@{i}+(1-gamma)*v+ysme_@{i}+Hhsme_@{i}=W_@{i} ;// labor demand by sme
rhobf_@{i}+(1-gamma)*v+ybf_@{i}+Hhbf_@{i}=W_@{i} ; // labor demand by bf
Pe_@{i}=rhosme_@{i}+(1-gamma)*v+ysme_@{i}-((b_@{i}*(ksmebar_@{i}^vf_@{i})+(1-b_@{i})*(esmebar_@{i}^vf_@{i}))^(-1))*b_@{i}*vf_@{i}*((ksmebar_@{i}^vf_@{i})*ksme_@{i})-(((b_@{i}*ksmebar_@{i}^(vf_@{i})+(1-b_@{i})*esmebar_@{i}^(vf_@{i}))^(-1))*(1-b_@{i})*(vf_@{i}-1)*(esmebar_@{i}^vf_@{i})+(vf_@{i}-1)*(1-b_@{i}))*esme_@{i}; //optimal condition of energy sme
Pe_@{i}=rhobf_@{i}+(1-gamma)*v+ybf_@{i}-((b_@{i}*(kbfbar_@{i}^vf_@{i})+(1-b_@{i})*(ebfbar_@{i}^vf_@{i}))^(-1))*b_@{i}*vf_@{i}*((kbfbar_@{i}^vf_@{i})*kbf_@{i})-(((b_@{i}*kbfbar_@{i}^(vf_@{i})+(1-b_@{i})*ebfbar_@{i}^(vf_@{i}))^(-1))*(1-b_@{i})*vf_@{i}*ebfbar_@{i}^(vf_@{i}-1)+(vf_@{i}-1)*(1-b_@{i}))*ebf_@{i}; //optimal condition of energy bf
rK_@{i}*rKbar_@{i}=v^(1-gamma)*ysmebar_@{i}/(b_@{i}*(ksmebar_@{i}^vf_@{i})+(1-b_@{i})*(esmebar_@{i}^vf_@{i}))*alpha_@{i}*b_@{i}*(ksmebar_@{i}^(vf_@{i}-1))*rhosme_@{i}*rhosmebar_@{i}+rhosmebar_@{i}*(ysmebar_@{i}/(b_@{i}*(ksmebar_@{i}^vf_@{i})+(1-b_@{i})*(esmebar_@{i}^vf_@{i})))*(1-gamma)*(v^(1-gamma))*alpha_@{i}*b_@{i}*(ksmebar_@{i}^(vf_@{i}-1))*v+rhosmebar_@{i}*(v^(1-gamma))*(b_@{i}*((ksmebar_@{i}^vf_@{i})+((1-b_@{i})*(esmebar_@{i}^(vf_@{i}))))^(-1))*alpha_@{i}*b_@{i}*(ksmebar_@{i}^(vf_@{i}-1))*ysme_@{i}*ysmebar_@{i}+ksme_@{i}*(rhosmebar_@{i}*(v^(1-gamma))*b_@{i}*ysmebar_@{i}*((1/(b_@{i}*(ksmebar_@{i}^vf_@{i})+(1-b_@{i})*(esmebar_@{i}^vf_@{i})))*(vf_@{i}-1)*(ksmebar_@{i}^(vf_@{i}-1))-((b_@{i}*(ksmebar_@{i}^vf_@{i})+(1-b_@{i})*(esmebar_@{i}^vf_@{i}))^(-2))*b_@{i}*vf_@{i}*(ksmebar_@{i}^(2*vf_@{i}-1)))-theta_@{i}*((Ismebar_@{i}/ksmebar_@{i})^2))+(1-alpha_@{i})*Qsme_@{i}*Qsmebar_@{i}-Qsme_@{i}(-1)*Qsmebar_@{i}; //foc capital of sme
r_@{i}*rbar_@{i}=v^(1-gamma)*ybfbar_@{i}/(b_@{i}*(kbfbar_@{i}^vf_@{i})+(1-b_@{i})*(ebfbar_@{i}^vf_@{i}))*alpha_@{i}*b_@{i}*(kbfbar_@{i}^(vf_@{i}-1))*rhobf_@{i}*rhobfbar_@{i}+rhobfbar_@{i}*(ybfbar_@{i}/(b_@{i}*(kbfbar_@{i}^vf_@{i})+(1-b_@{i})*(ebfbar_@{i}^vf_@{i})))*(1-gamma)*(v^(1-gamma))*alpha_@{i}*b_@{i}*(kbfbar_@{i}^(vf_@{i}-1))*v+rhobfbar_@{i}*(v^(1-gamma))*(b_@{i}*((kbfbar_@{i}^vf_@{i})+((1-b_@{i})*(ebfbar_@{i}^(vf_@{i}))))^(-1))*alpha_@{i}*b_@{i}*(kbfbar_@{i}^(vf_@{i}-1))*ybf_@{i}*ybfbar_@{i}+kbf_@{i}*(rhobfbar_@{i}*(v^(1-gamma))*b_@{i}*ybfbar_@{i}*((1/(b_@{i}*(kbfbar_@{i}^vf_@{i})+(1-b_@{i})*(ebfbar_@{i}^vf_@{i})))*(vf_@{i}-1)*(kbfbar_@{i}^(vf_@{i}-1))-((b_@{i}*(kbfbar_@{i}^vf_@{i})+(1-b_@{i})*(ebfbar_@{i}^vf_@{i}))^(-2))*b_@{i}*vf_@{i}*(kbfbar_@{i}^(2*vf_@{i}-1)))-theta_@{i}*((Ibfbar_@{i}/kbfbar_@{i})^2))+(1-alpha_@{i})*Qbf_@{i}*Qbfbar_@{i}-Qbf_@{i}(-1)*Qbfbar_@{i}; //foc capital of bf
y_@{i}=((tau1*ybfbar_@{i}^((epsilon_@{i}-1)/epsilon_@{i})+(1-tau1)*ysmebar_@{i}^((epsilon_@{i}-1)/epsilon_@{i}))^(1/(epsilon_@{i}-1))*(tau1*ybfbar_@{i}^((epsilon_@{i}-1)/epsilon_@{i})*ybf_@{i}+(1-tau1)*ysmebar_@{i}^((epsilon_@{i}-1)/epsilon_@{i})*ysme_@{i}))/ybar_@{i}; //retailer production funct country 1 (tau1)
(epsilon_@{i}-1)*MC_@{i}=(1/((tau1^epsilon_@{i})*(Pbfbar_@{i}^(1-epsilon_@{i}))+((1-tau1)^epsilon_@{i})*(Psmebar_@{i}^(1-epsilon_@{i}))))*(((-tau1^epsilon_@{i})*(1-epsilon_@{i})*(Pbfbar_@{i}^(1-epsilon_@{i}))*Pbf_@{i})-((1-tau1)^epsilon_@{i})*(1-epsilon_@{i})*(Psmebar_@{i}^(1-epsilon_@{i}))*Psme_@{i}); //marginal cost country 1 (depending on different values of tau between two countries)
pi1_@{i}=beta_@{i}*pi1_@{i}(+1)+eta_@{i}*MC_@{i}/sigma_@{i}; //Phillips curve country 1
else
pi_@{i}=gamma*pi1_@{i}+(1-gamma)*pi1_@{i-1} ; // value of inflation in second country
c_@{i}=c_@{i-1}+sigc_@{i}*v(-1) ; // aggregate consumption
y_@{i} = c_y_@{i}*c_@{i} + c_y_@{i}*(gamma*(1-sigc_@{i})+gamma/(1-2*gamma)+sigc_@{i})*v(-1)+(Isme_ysme_@{i}+Ibf_ybf_@{i})*I_@{i} + G_y_@{i}*G_@{i} +csme_y_@{i}*csme_@{i}+cB_y_@{i}*cB_@{i};
rhosme_@{i}+(gamma-1)*v+ysme_@{i}+Hhsme_@{i}=W_@{i}; //labor demand by sme
rhobf_@{i}+(gamma-1)*v+ybf_@{i}+Hhbf_@{i}=W_@{i}; //labor demand by bf
Pe_@{i}=rhosme_@{i}+(gamma-1)*v+ysme_@{i}-((b_@{i}*(ksme_@{i}^vf_@{i})+(1-b_@{i})*(esme_@{i}^vf_@{i}))^(-1))*b_@{i}*vf_@{i}*((ksmebar_@{i}^vf_@{i})*ksme_@{i})-(((b_@{i}*ksme_@{i}^(vf_@{i})+(1-b_@{i})*esmebar_@{i}^(vf_@{i}))^(-1))*(1-b_@{i})*vf_@{i}*esmebar_@{i}^vf_@{i}+(vf_@{i}-1)*(1-b_@{i}))*esme_@{i};//optimal condition of energy sme
Pe_@{i}=rhobf_@{i}+(gamma-1)*v+ybf_@{i}-((b_@{i}*(kbf_@{i}^vf_@{i})+(1-b_@{i})*(ebf_@{i}^vf_@{i}))^(-1))*b_@{i}*vf_@{i}*((kbfbar_@{i}^vf_@{i})*kbf_@{i})-(((b_@{i}*kbf_@{i}^(vf_@{i})+(1-b_@{i})*ebfbar_@{i}^(vf_@{i}))^(-1))*(1-b_@{i})*vf_@{i}*ebfbar_@{i}^vf_@{i}+(vf_@{i}-1)*(1-b_@{i}))*ebf_@{i};//optimal condition of energy bf
rK_@{i}*rKbar_@{i}=v^(gamma-1)*ysmebar_@{i}/(b_@{i}*(ksmebar_@{i}^vf_@{i})+(1-b_@{i})*(esmebar_@{i}^vf_@{i}))*alpha_@{i}*b_@{i}*(ksmebar_@{i}^(vf_@{i}-1))*rhosme_@{i}*rhosmebar_@{i}+rhosmebar_@{i}*(ysmebar_@{i}/(b_@{i}*(ksmebar_@{i}^vf_@{i})+(1-b_@{i})*(esmebar_@{i}^vf_@{i})))*(gamma-1)*(v^(1-gamma))*alpha_@{i}*b_@{i}*(ksmebar_@{i}^(vf_@{i}-1))*v+rhosmebar_@{i}*(v^(1-gamma))*(b_@{i}*((ksmebar_@{i}^vf_@{i})+((1-b_@{i})*(esmebar_@{i}^(vf_@{i}))))^(-1))*alpha_@{i}*b_@{i}*(ksmebar_@{i}^(vf_@{i}-1))*ysme_@{i}*ysmebar_@{i}+ksme_@{i}*(rhosmebar_@{i}*(v^(1-gamma))*b_@{i}*ysmebar_@{i}*((1/(b_@{i}*(ksmebar_@{i}^vf_@{i})+(1-b_@{i})*(esmebar_@{i}^vf_@{i})))*(vf_@{i}-1)*(ksmebar_@{i}^(vf_@{i}-1))-((b_@{i}*(ksmebar_@{i}^vf_@{i})+(1-b_@{i})*(esmebar_@{i}^vf_@{i}))^(-2))*b_@{i}*vf_@{i}*(ksmebar_@{i}^(2*vf_@{i}-1)))-theta_@{i}*((Ismebar_@{i}/ksmebar_@{i})^2))+(1-alpha_@{i})*Qsme_@{i}*Qsmebar_@{i}-Qsme_@{i}(-1)*Qsmebar_@{i}; //foc capital of sme country 2
r_@{i}*rbar_@{i}=v^(gamma-1)*ybfbar_@{i}/(b_@{i}*(kbfbar_@{i}^vf_@{i})+(1-b_@{i})*(ebfbar_@{i}^vf_@{i}))*alpha_@{i}*b_@{i}*(kbfbar_@{i}^(vf_@{i}-1))*rhobf_@{i}*rhobfbar_@{i}+rhobfbar_@{i}*(ybfbar_@{i}/(b_@{i}*(kbfbar_@{i}^vf_@{i})+(1-b_@{i})*(ebfbar_@{i}^vf_@{i})))*(gamma-1)*(v^(1-gamma))*alpha_@{i}*b_@{i}*(kbfbar_@{i}^(vf_@{i}-1))*v+rhobfbar_@{i}*(v^(1-gamma))*(b_@{i}*((kbfbar_@{i}^vf_@{i})+((1-b_@{i})*(ebfbar_@{i}^(vf_@{i}))))^(-1))*alpha_@{i}*b_@{i}*(kbfbar_@{i}^(vf_@{i}-1))*ybf_@{i}*ybfbar_@{i}+kbf_@{i}*(rhobfbar_@{i}*(v^(1-gamma))*b_@{i}*ybfbar_@{i}*((1/(b_@{i}*(kbfbar_@{i}^vf_@{i})+(1-b_@{i})*(ebfbar_@{i}^vf_@{i})))*(vf_@{i}-1)*(kbfbar_@{i}^(vf_@{i}-1))-((b_@{i}*(kbfbar_@{i}^vf_@{i})+(1-b_@{i})*(ebfbar_@{i}^vf_@{i}))^(-2))*b_@{i}*vf_@{i}*(kbfbar_@{i}^(2*vf_@{i}-1)))-theta_@{i}*((Ibfbar_@{i}/kbfbar_@{i})^2))+(1-alpha_@{i})*Qbf_@{i}*Qbfbar_@{i}-Qbf_@{i}(-1)*Qbfbar_@{i}; //foc capital of bf country 2
y_@{i}=((tau2*ybfbar_@{i}^((epsilon_@{i}-1)/epsilon_@{i})+(1-tau2)*ysmebar_@{i}^((epsilon_@{i}-1)/epsilon_@{i}))^(1/(epsilon_@{i}-1))*(tau2*ybfbar_@{i}^((epsilon_@{i}-1)/epsilon_@{i})*ybf_@{i}+(1-tau2)*ysmebar_@{i}^((epsilon_@{i}-1)/epsilon_@{i})*ysme_@{i}))/ybar_@{i}; //production funct of retailer country 2 (tau2);
(epsilon_@{i}-1)*MC_@{i}=(1/((tau2^epsilon_@{i})*(Pbfbar_@{i}^(1-epsilon_@{i}))+((1-tau2)^epsilon_@{i})*(Psmebar_@{i}^(1-epsilon_@{i}))))*(((-tau2^epsilon_@{i})*(1-epsilon_@{i})*(Pbfbar_@{i}^(1-epsilon_@{i}))*Pbf_@{i})-((1-tau2)^epsilon_@{i})*(1-epsilon_@{i})*(Psmebar_@{i}^(1-epsilon_@{i}))*Psme_@{i}); //marginal cost country 2 (depending on different values of tau between two countries);
pi1_@{i}=beta_@{i}*pi1_@{i}(+1)+eta_@{i}*MC_@{i}/sigma_@{i}; // Philliphs curve country 2
end;
// Values of Monetary unit : inflation, output and relied value in steady state
pi_UM=(pi_1+pi_2)/2;
y_UM=(y_1+y_2)/2;
pibar_UM=(pi_1-pi_2)/2;
ybar_UM=(y_1-y_2)/2;
// Values of rpm
rpm= bet0*rpm(-1) + (1-bet0)*(bet1*pi_UM + bet2*y_UM) + Serpm;
z=v;
sebar=se_1-se_2;
sbbar=sb_1-sb_2;
end;
steady;
check;
shocks;
var Serpm; stderr 1 //monetary shock ;
//var Seg; stderr 1 //government spending shock ;
//var Seasme; stderr 1 //technological shock for sme ;
//var Seabf; stderr 1 //technological shock for bf ;
//var See; stderr 1 //price of energy shock ;
end;
stoch_simul (irf=20);
Thanks very much for answer. I tried to do exactly what was done in the example mod, but now I’ve encountered this other error: Macro-processing error: backtrace…
variable: modelthesisFRA.mod:158.26-39 Index out of range
@#define: “modelthesisFRA.mod” line 158, col 1-39
I paste my updated file here:
// Financial heterogeneity between two countries.
// Monetary, government spending, energy cost-push shocks.
// Differences in proportion of small-medium firms and big firms. Type of firms distinguishs for values of alpha
@#define N=2
@#define countries=[1:N]
@#for i in countries
var y_@{i} ysme_@{i} ybf_@{i} c_@{i} Isme_@{i} Ibf_@{i} ksme_@{i} kbf_@{i} Qsme_@{i} Qbf_@{i} r_@{i} rhosme_@{i} rhobf_@{i} asme_@{i} abf_@{i} H_@{i} Hhsme_@{i} Hhbf_@{i} W_@{i}
pi1_@{i} pi_@{i} rK_@{i} n_@{i} nb_@{i} se_@{i} sb_@{i} rb_@{i} csme_@{i} cB_@{i} G_@{i} MC_@{i} rn_@{i} Psme_@{i} Pbf_@{i} esme_@{i} ebf_@{i} Pe_@{i} I_@{i} ;
parameters n_ksme_@{i} ksme_n_@{i} rbar_@{i} rBbar_@{i} k_y_@{i} y_k_@{i} psi_@{i} psib_@{i} gammaf_@{i} rhosmebar_@{i} rhobfbar_@{i} rhop_@{i} rhoasme_@{i} rhoabf_@{i} ybar_@{i}
alpha_@{i} delta_@{i} theta_@{i} sigc_@{i} beta_@{i} sigh_@{i} csme_y_@{i} c_y_@{i} Isme_ysme_@{i} Ibf_ybf_@{i} ksmebar_@{i} kbfbar_@{i} esmebar_@{i} ebfbar_@{i} ysmebar_@{i} ybfbar_@{i} Wbar_@{i}
esme_ysme_@{i} ebf_ybf_@{i} G_y_@{i} rhog_@{i} phi_@{i} rhoa_@{i} Hbar_@{i} phi1_@{i} phi2_@{i} eps_@{i} Psmebar_@{i} Pbfbar_@{i} Pebar_@{i} rKbar_@{i} gammab_@{i} Ismebar_@{i} Ibfbar_@{i}
tb_@{i} nb_b_@{i} nb_ksme_@{i} ksme_nb_@{i} n_nb_@{i} nnb_nb_@{i} nb_nnb_@{i} n_nnb_@{i} cB_y_@{i} eta_@{i} sigma_@{i} rhoe_@{i} epsilon_@{i} b_@{i} Xi_@{i} vf_@{i} Qbfbar_@{i} Qsmebar_@{i} ;
@#endfor
var z y_UM pi_UM v rpm pibar_UM ybar_UM ;
parameters gamma bet0 bet1 bet2 tau1 tau2 sebar sbbar ;
varexo Serpm Seasme Seabf Seg See ; // the latter is shock to energy price ;
// calibration of exogenous parameters
@#for i in countries
alpha_@{i} = 0.33; // Share of contribution of capital and energy on GDP
delta_@{i} = 0.03; // Depreciation of capital
theta_@{i} = 10.0; // Capital adjustment costs parameter
sigc_@{i} = 0.75; // Intertemporal elasticity of substitution
beta_@{i} = 0.99; // Discount factor
sigh_@{i} = 0.32; // Elasticity of labor disutility
rhog_@{i} = 0.95; // Persitence of government spending
rhoa_@{i} = 0.97; // Persistence of technological shock
gammaf_@{i} = 0.9831; // small-medium firms probability to survive
gammab_@{i} = 0.99; // bank probability to survive
tb_@{i} = 0.001; // part of capital trasferts to survival bank
psi_@{i} = 0.025; // small-medium enterprises external financial premium elasticity
eta_@{i} = 1.1; // value that multilpies the value of marginal costs inside PC
sigma_@{i} = 6; // value of rigidity, i.e. cost of adjustment of price
b_@{i} = 0.045; //share of energy on production
rhoe_@{i} = 0.95; // persistence of energy price shock process, calibrated as in Wei
epsilon_@{i} = 0.4; // CES production function of retailers parameter
vf_@{i} = -0.9; // CES capital/eneergy sobstitution parameter
@#endfor
gamma=0.8; // "importance" of other country motions to domestic economy
bet0 = 0.9;
bet1= 1.1;
bet2 = 0;
psib_1=0.002; // banks external financial premium elasticity country 1
psib_2=0.002; // banks external financial premium elasticity country 2
nb_b_1=0.10; // Banks inside capital/loans ratio country 1
nb_b_2=0.10; // Banks inside capital/loans ratio country 2
tau1=0.7; //share on retailer production of big firms input country 1
tau2=0.3; // share on retailer production of big firms input country 2
//steady state
@#for i in countries
rhosmebar_@{i} = 1/1.1;
rhobfbar_@{i} = 1/1.1 ;
G_y_@{i} = 0.16;
n_ksme_@{i}=0.4;
//nb_b_@{i}=0.2;
Qsmebar_@{i}=1;
Qbfbar_@{i}=1;
ksme_n_@{i}=1/n_ksme_@{i};
nb_ksme_@{i}=nb_b_@{i}*(1-n_ksme_@{i});
ksme_nb_@{i}=1/nb_ksme_@{i};
n_nb_@{i}=n_ksme_@{i}*ksme_nb_@{i};
nnb_nb_@{i}=1+n_nb_@{i};
nb_nnb_@{i}=1/nnb_nb_@{i};
n_nnb_@{i}=1-nb_nnb_@{i};
rbar_@{i} = 1/beta_@{i}; //it would be both return of household and big firm rate on loans
rKbar_@{i}=rbar_@{i}+0.005; //Rate sme > Rate bf
ksme_ysme_@{i} = (alpha_@{i}*rhosmebar_@{i})/(rKbar_@{i}-(1-delta_@{i}));
kbf_ybf_@{i} = (alpha_@{i}*rhobfbar_@{i})/(rbar_@{i}-(1-delta_@{i}));
csme_y_@{i}=(1-gammaf_@{i})/gammaf_@{i}*n_ksme_@{i}*ksme_ysme_@{i};
cB_y_@{i}=(1-gammab_@{i})*(1-tb_@{i})/(gammab_@{i}*(1-tb_@{i})+tb_@{i})*nb_ksme_@{i}*ksme_y_@{i};
ysme_ksme_@{i}= 1/ksme_ysme_@{i};
ybf_kbf_@{i}= 1/kbf_ybf_@{i};
Isme_ysme_@{i} = delta_@{i}*ksme_ysme_@{i};
Ibf_ybf_@{i} = delta_@{i}*kbf_ybf_@{i};
c_y_@{i} = 1 - G_y_@{i} - Isme_ysme_@{i} - Ibf_ybf_@{i} - csme_y_@{i} - cB_y_@{i} ;
esme_ysme_@{i}=rhosmebar_@{i}*alpha_@{i}/Pebar_@{i};
ebf_ybf_@{i}=rhobfbar_@{i}*alpha_@{i}/Pebar_@{i};
Psmebar_@{i}=1/1.1 ;
Pbfbar_@{i}=1/1.1 ;
@#endfor
@#if i == countries [1]
ybf_ysme_@{i}= tau1^(epsilon)/((1-tau1)^epsilon) ;
@#else
ybf_ysme_@{i+1}=tau2^(epsilon)/(1-tau2)^epsilon) ;
@#endif
model (linear);
@#for i in countries
rhosme_@{i}=Psme_@{i}; // use this in order to do not change the rhosme
rhobf_@{i}=Pbf_@{i}; // use this in order to do not change the rhobf
//input of sme demanded by retailers
ysme_@{i}=(-epsilon_@{i}*Psme_@{i})+y_@{i}+(epsilon_@{i}*MC_@{i});
//input of bf demanded by retailers
ybf_@{i}=(-epsilon_@{i}*Pbf_@{i})+y_@{i}+(epsilon_@{i}*MC_@{i});
//production funct of wholesale producers: sme
ysme_@{i}=asme_@{i}+(alpha_@{i}*(ksmebar_@{i}^vf_@{i})*b_@{i}*ksme_@{i}+alpha_@{i}*(1-b_@{i})*(esmebar_@{i}^vf_@{i})*esme_@{i})/(b_@{i}*(ksmebar_@{i}^vf_@{i})+(1-b_@{i})*(esmebar_@{i}^vf_@{i}))+Hhsme_@{i}*(1-alpha_@{i}) ;
//production funct of wholesale producers: bf
ybf_@{i}=abf_@{i}+(alpha_@{i}*(kbfbar_@{i}^vf_@{i})*b_@{i}*kbf_@{i}+alpha_@{i}*(1-b_@{i})*(ebfbar_@{i}^vf_@{i})*ebf_@{i})/(b_@{i}*(kbfbar_@{i}^vf_@{i})+(1-b_@{i})*(ebfbar_@{i}^vf_@{i}))+Hhbf_@{i}*(1-alpha_@{i}) ;
//equation of equilibrium in labor market
H_@{i}=(Hhsme_@{i}/Hbar_@{i})+(Hhbf_@{i}/Hbar_@{i});
//Capital accumulation of sme
ksme_@{i}=(1-delta_@{i})*ksme_@{i}(-1) + delta_@{i}*Isme_@{i};
//Capital accumulation of bf
kbf_@{i}=(1-delta_@{i})*kbf_@{i}(-1) + delta_@{i}*Ibf_@{i};
//net worth of bank
nb_@{i}=(gammab_@{i}*(1-tb_@{i})+tb_@{i})*rKbar_@{i}*((1/nb_b_@{i}-1)*(rK_@{i}-r_@{i}(-1))+rbar_@{i}/rKbar_@{i}*r_@{i}(-1)+rbar_@{i}/rKbar_@{i}*nb_@{i}(-1)-(1/nb_b_@{i}-1)*sb_@{i}(-1));
// external financial premium
rK_@{i}(+1)=r_@{i}+psi_@{i}*(-n_nnb_@{i}*n_@{i}-nb_nnb_@{i}*nb_@{i}+Qsme_@{i}+ksme_@{i});
rb_@{i}=r_@{i}+psib_@{i}*(-n_nb_@{i}*nb_b_@{i}*n_@{i}-nb_@{i}+ksme_nb_@{i}*nb_b_@{i}*(Qsme_@{i}+ksme_@{i}));
se_@{i}=rK_@{i}(+1)-r_@{i}; //remind that this holds only of small-medium enterprises
sb_@{i}=rb_@{i}-r_@{i}; //same of se
//Investment of sme
Qsme_@{i} = theta_@{i}*delta_@{i}*Isme_@{i} - theta_@{i}*delta_@{i}*ksme_@{i}(-1);
//Investment of bf
Qbf_@{i} = theta_@{i}*delta_@{i}*Ibf_@{i} - theta_@{i}*delta_@{i}*kbf_@{i}(-1);
//aggregate investment
I_@{i}=Ibf_@{i}+Isme_@{i};
//price of wholesale good offered by sme
Psme_@{i}=ysme_@{i}*((1/(vf_@{i}-1))*((vf_@{i}/alpha_@{i})-1)-((ysmebar_@{i}-(Wbar_@{i}/ysmebar_@{i}*(1-alpha_@{i}))^(-1))*(1-(((1-alpha_@{i})*Wbar_@{i})/(ysmebar_@{i}-alpha_@{i}*ysmebar_@{i})^2))))+(((ysmebar_@{i}^((vf_@{i}/alpha_@{i})-1))/alpha_@{i})^(1/(vf_@{i}-1)))*((1-b_@{i})^(1/(1-vf_@{i})))*(Pebar_@{i}^(vf_@{i}/(1-vf_@{i})))*(vf_@{i}/(vf_@{i}-1))*(Pe_@{i})/(Psmebar_@{i}*((ysmebar_@{i}-(Wbar_@{i}/(ysmebar_@{i}-alpha_@{i}*ysmebar_@{i})))))+((ysmebar_@{i}^((vf_@{i}/alpha_@{i})-1)/alpha_@{i})^(1/(1-vf_@{i})))*(b_@{i}^(1/(1-vf_@{i})))*(rKbar_@{i}^(vf_@{i}/(vf_@{i})-1))*(vf_@{i}/(vf_@{i}-1))*(rK_@{i})+(((ysmebar_@{i}^((vf_@{i}/(alpha_@{i})-1)))/alpha_@{i})^(1/(vf_@{i}-1)))*((Pebar_@{i}^(vf_@{i}/(vf_@{i}-1)))*((1-b_@{i})^(1/(1-vf_@{i})))+(rKbar_@{i}^(vf_@{i}/(1-vf_@{i})))*(b_@{i}^(1/(1-vf_@{i}))))*(-1/(ysmebar_@{i}-(alpha_@{i}*ysmebar_@{i})))*W_@{i}*Wbar_@{i};
//price of wholesale good offered by bf
Pbf_@{i}=ybf_@{i}*((1/(vf_@{i}-1))*((vf_@{i}/alpha_@{i})-1)-((ybfbar_@{i}-(Wbar_@{i}/ybfbar_@{i}*(1-alpha_@{i}))^(-1))*(1-(((1-alpha_@{i})*Wbar_@{i})/(ybfbar_@{i}-alpha_@{i}*ybfbar_@{i})^2))))+(((ybfbar_@{i}^((vf_@{i}/alpha_@{i})-1))/alpha_@{i})^(1/(vf_@{i}-1)))*((1-b_@{i})^(1/(1-vf_@{i})))*(Pebar_@{i}^(vf_@{i}/(1-vf_@{i})))*(vf_@{i}/(vf_@{i}-1))*(Pe_@{i})/(Pbfbar_@{i}*((ybfbar_@{i}-(Wbar_@{i}/(ybfbar_@{i}-alpha_@{i}*ybfbar_@{i})))))+((ybfbar_@{i}^((vf_@{i}/alpha_@{i})-1)/alpha_@{i})^(1/(1-vf_@{i})))*(b_@{i}^(1/(1-vf_@{i})))*(rbar_@{i}^(vf_@{i}/(vf_@{i})-1))*(vf_@{i}/(vf_@{i}-1))*(r_@{i})+(((ybfbar_@{i}^((vf_@{i}/(alpha_@{i})-1)))/alpha_@{i})^(1/(vf_@{i}-1)))*((Pebar_@{i}^(vf_@{i}/(vf_@{i}-1)))*((1-b_@{i})^(1/(1-vf_@{i})))+(rbar_@{i}^(vf_@{i}/(1-vf_@{i})))*(b_@{i}^(1/(1-vf_@{i}))))*(-1/(ybfbar_@{i}-(alpha_@{i}*ybfbar_@{i})))*W_@{i}*Wbar_@{i};
//consumption of household
c_@{i} = c_@{i}(+1)-sigc_@{i}*r_@{i};
//consumption of sme // doesn't exist for bf as they don't declare bankaruptcy
csme_@{i}=n_@{i};
//consumption of bank
cB_@{i}=nb_@{i};
//labor supply faced by both bf and sme
H_@{i}=(-sigh_@{i}/sigc_@{i})*c_@{i}+(sigh_@{i}*W_@{i});
//interest rate short term motion
r_@{i} = rpm - pi_@{i}(+1);
//technological shock of sm
asme_@{i} = rhoasme_@{i}*asme_@{i}(-1) - Seasme ;
//technological shock of bf
abf_@{i} = rhoabf_@{i}*abf_@{i}(-1) - Seabf;
//shock of government spending
G_@{i} = rhog_@{i}*G_@{i}(-1) + Seg ;
// energy price shock
Pe_@{i} = rhop_@{i}*Pe_@{i}(-1) + See ;
@# endfor
@#if i == countries [1] // different equations between two countries
@#define alt_co = countries [2]
pi_@{i}=gamma*pi1_@{i}+(1-gamma)*pi1_@{alt_co} ; // value of inflation in first country
c_@{i}=c_@{alt_co}+sigc_@{i}*v(-1) ; // aggregate consumption
y_@{i} = c_y_@{i}*c_@{i} + c_y_@{i}*((1-gamma)*(1-sigc_@{i})+(1-gamma)/(2*gamma-1))*v(-1)+(Ibf_ybf_@{i}+Isme_ysme_@{i})*I_@{i} + G_y_@{i}*G_@{i} +csme_y_@{i}*csme_@{i}+cB_y_@{i}*cB_@{i}; //resource constraint-->to modify
rhosme_@{i}+(1-gamma)*v+ysme_@{i}+Hhsme_@{i}=W_@{i} ;// labor demand by sme
rhobf_@{i}+(1-gamma)*v+ybf_@{i}+Hhbf_@{i}=W_@{i} ; // labor demand by bf
Pe_@{i}=rhosme_@{i}+(1-gamma)*v+ysme_@{i}-((b_@{i}*(ksmebar_@{i}^vf_@{i})+(1-b_@{i})*(esmebar_@{i}^vf_@{i}))^(-1))*b_@{i}*vf_@{i}*((ksmebar_@{i}^vf_@{i})*ksme_@{i})-(((b_@{i}*ksmebar_@{i}^(vf_@{i})+(1-b_@{i})*esmebar_@{i}^(vf_@{i}))^(-1))*(1-b_@{i})*(vf_@{i}-1)*(esmebar_@{i}^vf_@{i})+(vf_@{i}-1)*(1-b_@{i}))*esme_@{i}; //optimal condition of energy sme
Pe_@{i}=rhobf_@{i}+(1-gamma)*v+ybf_@{i}-((b_@{i}*(kbfbar_@{i}^vf_@{i})+(1-b_@{i})*(ebfbar_@{i}^vf_@{i}))^(-1))*b_@{i}*vf_@{i}*((kbfbar_@{i}^vf_@{i})*kbf_@{i})-(((b_@{i}*kbfbar_@{i}^(vf_@{i})+(1-b_@{i})*ebfbar_@{i}^(vf_@{i}))^(-1))*(1-b_@{i})*vf_@{i}*ebfbar_@{i}^(vf_@{i}-1)+(vf_@{i}-1)*(1-b_@{i}))*ebf_@{i}; //optimal condition of energy bf
rK_@{i}*rKbar_@{i}=v^(1-gamma)*ysmebar_@{i}/(b_@{i}*(ksmebar_@{i}^vf_@{i})+(1-b_@{i})*(esmebar_@{i}^vf_@{i}))*alpha_@{i}*b_@{i}*(ksmebar_@{i}^(vf_@{i}-1))*rhosme_@{i}*rhosmebar_@{i}+rhosmebar_@{i}*(ysmebar_@{i}/(b_@{i}*(ksmebar_@{i}^vf_@{i})+(1-b_@{i})*(esmebar_@{i}^vf_@{i})))*(1-gamma)*(v^(1-gamma))*alpha_@{i}*b_@{i}*(ksmebar_@{i}^(vf_@{i}-1))*v+rhosmebar_@{i}*(v^(1-gamma))*(b_@{i}*((ksmebar_@{i}^vf_@{i})+((1-b_@{i})*(esmebar_@{i}^(vf_@{i}))))^(-1))*alpha_@{i}*b_@{i}*(ksmebar_@{i}^(vf_@{i}-1))*ysme_@{i}*ysmebar_@{i}+ksme_@{i}*(rhosmebar_@{i}*(v^(1-gamma))*b_@{i}*ysmebar_@{i}*((1/(b_@{i}*(ksmebar_@{i}^vf_@{i})+(1-b_@{i})*(esmebar_@{i}^vf_@{i})))*(vf_@{i}-1)*(ksmebar_@{i}^(vf_@{i}-1))-((b_@{i}*(ksmebar_@{i}^vf_@{i})+(1-b_@{i})*(esmebar_@{i}^vf_@{i}))^(-2))*b_@{i}*vf_@{i}*(ksmebar_@{i}^(2*vf_@{i}-1)))-theta_@{i}*((Ismebar_@{i}/ksmebar_@{i})^2))+(1-alpha_@{i})*Qsme_@{i}*Qsmebar_@{i}-Qsme_@{i}(-1)*Qsmebar_@{i}; //foc capital of sme
r_@{i}*rbar_@{i}=v^(1-gamma)*ybfbar_@{i}/(b_@{i}*(kbfbar_@{i}^vf_@{i})+(1-b_@{i})*(ebfbar_@{i}^vf_@{i}))*alpha_@{i}*b_@{i}*(kbfbar_@{i}^(vf_@{i}-1))*rhobf_@{i}*rhobfbar_@{i}+rhobfbar_@{i}*(ybfbar_@{i}/(b_@{i}*(kbfbar_@{i}^vf_@{i})+(1-b_@{i})*(ebfbar_@{i}^vf_@{i})))*(1-gamma)*(v^(1-gamma))*alpha_@{i}*b_@{i}*(kbfbar_@{i}^(vf_@{i}-1))*v+rhobfbar_@{i}*(v^(1-gamma))*(b_@{i}*((kbfbar_@{i}^vf_@{i})+((1-b_@{i})*(ebfbar_@{i}^(vf_@{i}))))^(-1))*alpha_@{i}*b_@{i}*(kbfbar_@{i}^(vf_@{i}-1))*ybf_@{i}*ybfbar_@{i}+kbf_@{i}*(rhobfbar_@{i}*(v^(1-gamma))*b_@{i}*ybfbar_@{i}*((1/(b_@{i}*(kbfbar_@{i}^vf_@{i})+(1-b_@{i})*(ebfbar_@{i}^vf_@{i})))*(vf_@{i}-1)*(kbfbar_@{i}^(vf_@{i}-1))-((b_@{i}*(kbfbar_@{i}^vf_@{i})+(1-b_@{i})*(ebfbar_@{i}^vf_@{i}))^(-2))*b_@{i}*vf_@{i}*(kbfbar_@{i}^(2*vf_@{i}-1)))-theta_@{i}*((Ibfbar_@{i}/kbfbar_@{i})^2))+(1-alpha_@{i})*Qbf_@{i}*Qbfbar_@{i}-Qbf_@{i}(-1)*Qbfbar_@{i}; //foc capital of bf
y_@{i}=((tau1*ybfbar_@{i}^((epsilon_@{i}-1)/epsilon_@{i})+(1-tau1)*ysmebar_@{i}^((epsilon_@{i}-1)/epsilon_@{i}))^(1/(epsilon_@{i}-1))*(tau1*ybfbar_@{i}^((epsilon_@{i}-1)/epsilon_@{i})*ybf_@{i}+(1-tau1)*ysmebar_@{i}^((epsilon_@{i}-1)/epsilon_@{i})*ysme_@{i}))/ybar_@{i}; //retailer production funct country 1 (tau1)
(epsilon_@{i}-1)*MC_@{i}=(1/((tau1^epsilon_@{i})*(Pbfbar_@{i}^(1-epsilon_@{i}))+((1-tau1)^epsilon_@{i})*(Psmebar_@{i}^(1-epsilon_@{i}))))*(((-tau1^epsilon_@{i})*(1-epsilon_@{i})*(Pbfbar_@{i}^(1-epsilon_@{i}))*Pbf_@{i})-((1-tau1)^epsilon_@{i})*(1-epsilon_@{i})*(Psmebar_@{i}^(1-epsilon_@{i}))*Psme_@{i}); //marginal cost country 1 (depending on different values of tau between two countries)
pi1_@{i}=beta_@{i}*pi1_@{i}(+1)+eta_@{i}*MC_@{i}/sigma_@{i}; //Phillips curve country 1
@#else
@#define alt__co = countries [1]
pi_@{i}=gamma*pi1_@{i}+(1-gamma)*pi1_@{alt__co} ; // value of inflation in second country
c_@{i}=c_@{alt__co}+sigc_@{i}*v(-1) ; // aggregate consumption
y_@{i} = c_y_@{i}*c_@{i} + c_y_@{i}*(gamma*(1-sigc_@{i})+gamma/(1-2*gamma)+sigc_@{i})*v(-1)+(Isme_ysme_@{i}+Ibf_ybf_@{i})*I_@{i} + G_y_@{i}*G_@{i} +csme_y_@{i}*csme_@{i}+cB_y_@{i}*cB_@{i};
rhosme_@{i}+(gamma-1)*v+ysme_@{i}+Hhsme_@{i}=W_@{i}; //labor demand by sme
rhobf_@{i}+(gamma-1)*v+ybf_@{i}+Hhbf_@{i}=W_@{i}; //labor demand by bf
Pe_@{i}=rhosme_@{i}+(gamma-1)*v+ysme_@{i}-((b_@{i}*(ksme_@{i}^vf_@{i})+(1-b_@{i})*(esme_@{i}^vf_@{i}))^(-1))*b_@{i}*vf_@{i}*((ksmebar_@{i}^vf_@{i})*ksme_@{i})-(((b_@{i}*ksme_@{i}^(vf_@{i})+(1-b_@{i})*esmebar_@{i}^(vf_@{i}))^(-1))*(1-b_@{i})*vf_@{i}*esmebar_@{i}^vf_@{i}+(vf_@{i}-1)*(1-b_@{i}))*esme_@{i};//optimal condition of energy sme
Pe_@{i}=rhobf_@{i}+(gamma-1)*v+ybf_@{i}-((b_@{i}*(kbf_@{i}^vf_@{i})+(1-b_@{i})*(ebf_@{i}^vf_@{i}))^(-1))*b_@{i}*vf_@{i}*((kbfbar_@{i}^vf_@{i})*kbf_@{i})-(((b_@{i}*kbf_@{i}^(vf_@{i})+(1-b_@{i})*ebfbar_@{i}^(vf_@{i}))^(-1))*(1-b_@{i})*vf_@{i}*ebfbar_@{i}^vf_@{i}+(vf_@{i}-1)*(1-b_@{i}))*ebf_@{i};//optimal condition of energy bf
rK_@{i}*rKbar_@{i}=v^(gamma-1)*ysmebar_@{i}/(b_@{i}*(ksmebar_@{i}^vf_@{i})+(1-b_@{i})*(esmebar_@{i}^vf_@{i}))*alpha_@{i}*b_@{i}*(ksmebar_@{i}^(vf_@{i}-1))*rhosme_@{i}*rhosmebar_@{i}+rhosmebar_@{i}*(ysmebar_@{i}/(b_@{i}*(ksmebar_@{i}^vf_@{i})+(1-b_@{i})*(esmebar_@{i}^vf_@{i})))*(gamma-1)*(v^(1-gamma))*alpha_@{i}*b_@{i}*(ksmebar_@{i}^(vf_@{i}-1))*v+rhosmebar_@{i}*(v^(1-gamma))*(b_@{i}*((ksmebar_@{i}^vf_@{i})+((1-b_@{i})*(esmebar_@{i}^(vf_@{i}))))^(-1))*alpha_@{i}*b_@{i}*(ksmebar_@{i}^(vf_@{i}-1))*ysme_@{i}*ysmebar_@{i}+ksme_@{i}*(rhosmebar_@{i}*(v^(1-gamma))*b_@{i}*ysmebar_@{i}*((1/(b_@{i}*(ksmebar_@{i}^vf_@{i})+(1-b_@{i})*(esmebar_@{i}^vf_@{i})))*(vf_@{i}-1)*(ksmebar_@{i}^(vf_@{i}-1))-((b_@{i}*(ksmebar_@{i}^vf_@{i})+(1-b_@{i})*(esmebar_@{i}^vf_@{i}))^(-2))*b_@{i}*vf_@{i}*(ksmebar_@{i}^(2*vf_@{i}-1)))-theta_@{i}*((Ismebar_@{i}/ksmebar_@{i})^2))+(1-alpha_@{i})*Qsme_@{i}*Qsmebar_@{i}-Qsme_@{i}(-1)*Qsmebar_@{i}; //foc capital of sme country 2
r_@{i}*rbar_@{i}=v^(gamma-1)*ybfbar_@{i}/(b_@{i}*(kbfbar_@{i}^vf_@{i})+(1-b_@{i})*(ebfbar_@{i}^vf_@{i}))*alpha_@{i}*b_@{i}*(kbfbar_@{i}^(vf_@{i}-1))*rhobf_@{i}*rhobfbar_@{i}+rhobfbar_@{i}*(ybfbar_@{i}/(b_@{i}*(kbfbar_@{i}^vf_@{i})+(1-b_@{i})*(ebfbar_@{i}^vf_@{i})))*(gamma-1)*(v^(1-gamma))*alpha_@{i}*b_@{i}*(kbfbar_@{i}^(vf_@{i}-1))*v+rhobfbar_@{i}*(v^(1-gamma))*(b_@{i}*((kbfbar_@{i}^vf_@{i})+((1-b_@{i})*(ebfbar_@{i}^(vf_@{i}))))^(-1))*alpha_@{i}*b_@{i}*(kbfbar_@{i}^(vf_@{i}-1))*ybf_@{i}*ybfbar_@{i}+kbf_@{i}*(rhobfbar_@{i}*(v^(1-gamma))*b_@{i}*ybfbar_@{i}*((1/(b_@{i}*(kbfbar_@{i}^vf_@{i})+(1-b_@{i})*(ebfbar_@{i}^vf_@{i})))*(vf_@{i}-1)*(kbfbar_@{i}^(vf_@{i}-1))-((b_@{i}*(kbfbar_@{i}^vf_@{i})+(1-b_@{i})*(ebfbar_@{i}^vf_@{i}))^(-2))*b_@{i}*vf_@{i}*(kbfbar_@{i}^(2*vf_@{i}-1)))-theta_@{i}*((Ibfbar_@{i}/kbfbar_@{i})^2))+(1-alpha_@{i})*Qbf_@{i}*Qbfbar_@{i}-Qbf_@{i}(-1)*Qbfbar_@{i}; //foc capital of bf country 2
y_@{i}=((tau2*ybfbar_@{i}^((epsilon_@{i}-1)/epsilon_@{i})+(1-tau2)*ysmebar_@{i}^((epsilon_@{i}-1)/epsilon_@{i}))^(1/(epsilon_@{i}-1))*(tau2*ybfbar_@{i}^((epsilon_@{i}-1)/epsilon_@{i})*ybf_@{i}+(1-tau2)*ysmebar_@{i}^((epsilon_@{i}-1)/epsilon_@{i})*ysme_@{i}))/ybar_@{i}; //production funct of retailer country 2 (tau2);
(epsilon_@{i}-1)*MC_@{i}=(1/((tau2^epsilon_@{i})*(Pbfbar_@{i}^(1-epsilon_@{i}))+((1-tau2)^epsilon_@{i})*(Psmebar_@{i}^(1-epsilon_@{i}))))*(((-tau2^epsilon_@{i})*(1-epsilon_@{i})*(Pbfbar_@{i}^(1-epsilon_@{i}))*Pbf_@{i})-((1-tau2)^epsilon_@{i})*(1-epsilon_@{i})*(Psmebar_@{i}^(1-epsilon_@{i}))*Psme_@{i}); //marginal cost country 2 (depending on different values of tau between two countries);
pi1_@{i}=beta_@{i}*pi1_@{i}(+1)+eta_@{i}*MC_@{i}/sigma_@{i}; // Phillips curve country 2
@#endif
// Values of Monetary unit : inflation, output and relied value in steady state
pi_UM=(pi_1+pi_2)/2;
y_UM=(y_1+y_2)/2;
pibar_UM=(pi_1-pi_2)/2;
ybar_UM=(y_1-y_2)/2;
// Values of rpm
rpm= bet0*rpm(-1) + (1-bet0)*(bet1*pi_UM + bet2*y_UM) + Serpm;
z=v;
sebar=se_1-se_2;
sbbar=sb_1-sb_2;
end;
shocks;
var Serpm; stderr 1 //monetary shock ;
//var Seg; stderr 1 //government spending shock ;
//var Seasme; stderr 1 //technological shock for sme ;
//var Seabf; stderr 1 //technological shock for bf ;
//var See; stderr 1 //price of energy shock ;
end;
steady;
check;
stoch_simul (irf=20);
Ok thanks very much for helping me :).
Anyway, I’ve some other problems with this mod file since it’s very long. If you are available, could you check the file in order to find the errors? Obviously if you have free-time to spare :).
Thank you again!
There is a large first bracket enclosing variables, and that whole bracket is multiplied with another bracket containing variables. That yields a nonlinearity. Maybe it’s just a wrong bracket or the whole linearization is wrong.