problem in running a code in dynare

This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location where you will have to reset your password.
Forum rules
This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location (https://forum.dynare.org) where you will have to reset your password.

problem in running a code in dynare

Postby Tehseen Iqbal » Tue Oct 18, 2016 2:32 pm

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 http://www.bis.org/publ/work372.pdf . mode file is also attached.

Thanks in advance.
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-theta*beta)/theta;
phi_f = A/Wf*mu;
A =1;
Phi_i = (gamma*A)/Wi*mu;
sii =0.75;
Wu = sii*(gamma*A/mu);
omega_f = (chi*c*N^eta)/Wf;
omega_i = (chi*c*N^eta)/Wi;

rho_d = 0.95;
rho_a = 0.95;
// Steady state

Y = Yf+Yi;
N = Nf+Ni;
Wf = A*(1/mu)-Gf*(1-beta*(1-sigma)); // labor demand of formal sector
Wi = gamma*A*(1/mu)-Gi*(1-beta*(1-sigma)); // labor demand of informal sector
Wf = chi*C*N^phi+Wu+lamda*(Gf-beta*(1-sigma)*((1-Xf)*Gf-Xi*Gi)); // labor supply of formal sector
Wi = chi*C*N^phi+Wu+lamda*(Gi-beta*(1-sigma)*((1-Xi)*Gi-Xf*Gf)); // labor supply of informal sector
Y = C+sigma*Gf+Nf+sigma*Gi*N-Wu*(1-N); // aggregate budjet condition
Yf = A*Nf; // production function formal sector
Yi = gamma*A*Ni; // 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*A*X^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_f*xf; // hiring cost
gi = a + alpha_i*xi; // hiring cost

nf = (1-delta)*nf(-1)+delta*hf; // evolution of labor
ni = (1-delta)*ni(-1)+delta*hi; // 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+eta*n)+lamda*(Gf/Wf)*gff+((1-delta)*beta*lamda/Wf)*(Gf*Xf*(q(+1)+gf(+1)+xf(+1))*Gi*Xi*(q(+1)+gi(+1)+xi(+1)));
wi = omega_i*(c+eta*n)+lamda*(Gi/Wi)*gii+((1-delta)*beta*lamda/Wi)*(Gf*Xf*(q(+1)+gf(+1)+xi(+1))*Gi*Xi*(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_a*a(-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;
]
Attachments
rep1.mod
(3.76 KiB) Downloaded 107 times
Tehseen Iqbal
 
Posts: 6
Joined: Fri Sep 30, 2016 12:18 pm

Re: problem in running a code in dynare

Postby jpfeifer » Tue Oct 18, 2016 7:41 pm

The unstable version returns
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

Please check those equations. In equation 5 there is for example a product of n and n(-1), which maybe comes from wrong bracketing
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: problem in running a code in dynare

Postby Tehseen Iqbal » Tue Oct 18, 2016 9:11 pm

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+eta*n)+lamda*(Gf-Gf(-1)/Wf)*gff+((1-delta)*beta*lamda/Wf)*(Gf*Xf*(q(+1)+gf(+1)+xf(+1))+Gi*Xi*(q(+1)+gi(+1)+xi(+1)));
wi = omega_i*(c+eta*n)+lamda*(Gi-Gi(-1)/Wi)*gii+((1-delta)*beta*lamda/Wi)*(Gf*Xf*(q(+1)+gf(+1)+xi(+1))+Gi*Xi*(q(+1)+gi(+1)+xi(+1)));]
Attachments
rep1.mod
(3.81 KiB) Downloaded 92 times
Tehseen Iqbal
 
Posts: 6
Joined: Fri Sep 30, 2016 12:18 pm

Re: problem in running a code in dynare

Postby jpfeifer » Wed Oct 19, 2016 9:28 am

You are using a
Code: Select all
sigma

that has nowhere been defined. In the future, please always post the full error message you get.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: problem in running a code in dynare

Postby Tehseen Iqbal » Fri Oct 28, 2016 2:41 pm

Dear jpfeifer,

Thanks for your help. I have incorporated your comments but still getting the following error message.

[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
Attachments
reprep1.mod
(4.3 KiB) Downloaded 98 times
Tehseen Iqbal
 
Posts: 6
Joined: Fri Sep 30, 2016 12:18 pm

Re: problem in running a code in dynare

Postby jpfeifer » Fri Oct 28, 2016 4:51 pm

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.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany


Return to Dynare help

Who is online

Users browsing this forum: Google [Bot] and 7 guests