# Problem in running a code in dynare

Hello everyone,

I am beginner and after going through all the example of user guide and practicing 2 examples from the book of Gali, I am trying to replicate a paper. I am trying hard to write the code properly but still there is an error in executing the code. Could someone help me by pointing out the mistakes. The link of the paper is bis.org/publ/work372.pdf . mode file is also attached.

Regard,
Tehseen Iqbal

[code] var c i pi mc yf yi wf wi nf ni q gf gi xf xi hf hi y n a d;

varexo e_a e_d;

parameters chi beta epsilon delta gamma tech alpha_f alpha_i beta_f beta_i lamda phi_pi phi_y theta eta rho_a rho_d kappa phi phi_f phi_i mu Wu omega_f omega_i gff gii A sii Y N Wf Wi Yf Yi Xf Xi Gf Gi ;

% Calibration.

beta =0.99; // discount factor
chi =1; // preference parameter
epsilon = 6; // elasticity of substituion
delta = 0.2; // seperation rate
gamma = 0.95; // tech
tech = 1; // tech
alpha_f = 1.5; // elasticity of hiring cost of formal labor w.r.t market tightness
alpha_i = 0.75; // elasticity of hiring cost of informal labor w.r.t market tightness
beta_f = 2.5; //
beta_i = 0.5; //
lamda = 0.5; // bargaining powe of labor
phi_pi = 1.5; // policy parameter related to inflation
phi_y = 0.5; // policy parameter related to output
theta = 2/3; // number of firms who can’t adjust prices
//eta = ? //
mu = epsilon/(epsilon-1);
kappa = (1-theta)(1-thetabeta)/theta;
phi_f = A/Wfmu;
A =1;
Phi_i = (gamma
A)/Wimu;
sii =0.75;
Wu = sii
(gammaA/mu);
omega_f = (chi
cN^eta)/Wf;
omega_i = (chi
c*N^eta)/Wi;

rho_d = 0.95;
rho_a = 0.95;

Y = Yf+Yi;
N = Nf+Ni;
Wf = A*(1/mu)-Gf*(1-beta*(1-sigma)); // labor demand of formal sector
Wi = gammaA(1/mu)-Gi*(1-beta*(1-sigma)); // labor demand of informal sector
Wf = chiCN^phi+Wu+lamda*(Gf-beta*(1-sigma)((1-Xf)Gf-XiGi)); // labor supply of formal sector
Wi = chi
CN^phi+Wu+lamda(Gi-beta*(1-sigma)((1-Xi)Gi-XfGf)); // labor supply of informal sector
Y = C+sigma
Gf+Nf+sigmaGiN-Wu*(1-N); // aggregate budjet condition
Yf = ANf; // production function formal sector
Yi = gamma
ANi; // production function informal sector
Xf = sigma
Nf/(1-(1-sigma)N); // labor tightness of formal sector
Xi = sigma
Ni/(1-(1-sigma)N); // labor tightness of informal sector
Gf = betai
AX^alpha_f; // Hiring cost informal sector
Gi = betaf
A*X^alpha_i; // Hiring cost formal sector

//Linear
Model(linear);
//c = c(+1)-(i-(pi(+1)); // Euler equation
gf = a + alpha_fxf; // hiring cost
gi = a + alpha_i
xi; // hiring cost

nf = (1-delta)nf(-1)+deltahf; // evolution of labor
ni = (1-delta)ni(-1)+deltahi; // evolution of labor

xf = hf +((1-delta)*n/1-(1-delta))*n(-1); // labor market tightness
xi = hi +((1-delta)*n/1-(1-delta))n(-1); // labor market tightness
pi = kappa
mc+pi(+1); // phillips curve.

y = (Yf/Y)*yf+(Yi/Y)*yi;
yf = a + nf;
yi = a+ni;

wf = phi_f*(a+mc)+(Gf-Gf(-1)/Wf)(gff); // labor demand
wi = phi_i
(a+mc)+(Gi-Gi(-1)/Wi)*(gii); // labor demand

q(+1) = c-c(+1);

wf = omega_f*(c+etan)+lamda(Gf/Wf)gff+((1-delta)betalamda/Wf)(GfXf(q(+1)+gf(+1)+xf(+1))GiXi*(q(+1)+gi(+1)+xi(+1)));
wi = omega_i*(c+etan)+lamda(Gi/Wi)gii+((1-delta)betalamda/Wi)(GfXf(q(+1)+gf(+1)+xi(+1))GiXi*(q(+1)+gi(+1)+xi(+1)));
gff = gf-(1-delta)beta(q(+1)+gf(+1));
gii = gi-(1-delta)beta(q(+1)+gi(+1));
//n = (Ni/N)ni + (Nf/N)nf;
mc = (mu/A)
((1+lamda)/(1-gamma))
(Gf-Gf(-1))gff-(Gi-Gi(-1)gii)-a;
i = phi_pi
pi + phi_y
y; //monetary policy rule
a = rho_aa(-1)+e_a;
d = rho_d
d(-1)+e_d;
end;
check;

shocks;
var e_a; stderr .005;
var e_d; stderr .005;
end;

//Computation
check;
stoch_simul(irf=30) pi yi yf;
]
rep1.mod (3.76 KB)

The unstable version returns

[quote]ERROR: If the model is declared linear the second derivatives must be equal to zero.
The following equations had non-zero second derivatives:
* Eq # 5
* Eq # 6
* Eq # 14
* Eq # 15[/quote]

Please check those equations. In equation 5 there is for example a product of n and n(-1), which maybe comes from wrong bracketing

Dear jpfeifer,

Thanks for your help. You are right there were some mistakes in writing these four equation. I have made them correct but despite this code isn’t working. I am writing the correct form of these equations and attaching the new mod file. Kindly assist me

Regard
Tehseen Iqbal

[code][xf = hf + ((1-delta)*N)/(1-(1-delta)*N)*n(-1); // labor market tightness
xi = hi + ((1-delta)*N)/(1-(1-delta)*N)*n(-1); // labor market tightness

wf = omega_f*(c+etan)+lamda(Gf-Gf(-1)/Wf)gff+((1-delta)betalamda/Wf)(GfXf(q(+1)+gf(+1)+xf(+1))+GiXi(q(+1)+gi(+1)+xi(+1)));
wi = omega_i*(c+etan)+lamda(Gi-Gi(-1)/Wi)gii+((1-delta)betalamda/Wi)(GfXf(q(+1)+gf(+1)+xi(+1))+GiXi(q(+1)+gi(+1)+xi(+1)));]
rep1.mod (3.81 KB)

You are using a

that has nowhere been defined. In the future, please always post the full error message you get.

Dear jpfeifer,

[quote][STEADY: numerical initial values or parameters incompatible with the following equations
8 11 12 14 15 16 17 18

Check whether your model in truly linear
Error using print_info (line 80)
The steady state contains NaN or Inf

Error in check (line 76)
print_info(info, 0, options);

Error in reprep1 (line 365)
oo_.dr.eigval = check(M_,options_,oo_);

Error in dynare (line 180)
evalin(‘base’,fname) ;

]

Kindly advice me what does this mean and how to improve my knowledge of dynare.
Thanks
Regard
Tehseen iqbal[/quote]

reprep1.mod (4.3 KB)

Your parameter initializations are not recursive. In Matlab, you can execute any Matlab code statement (the parameter definitions and the content within the initval-block are Matlab compatible code) by selecting it using your mouse and the either right-click and choose “Evaluate selection” or pressing the shortcut F9. Try using F9 to execute the initializations before the model-block to see that phi_f uses A in its definition, but A is only defined later on.

Thank you Prof., I’ll do that and give you a feedback as soon as possible.