Page 1 of 1

can you help me?

PostPosted: Sun Dec 01, 2013 2:23 pm
by yysun1986
I have a problem with dynare.
This is my code:

// code

var c rn pi q rk i k u l w y z_b z_i z_g z_w z_p z_r lambda
mc z_z ypot dy_obs dc_obs di_obs dw_obs l_obs pi_obs rn_obs;

varexo e_b e_i e_g e_w e_p e_r e_z;

parameters delta alpha gyss lambdaw lambdap sigma theta chi
zetainv mu phi gammaw xiw gammap xip phir phipi phiy rho_z
rho_b rho_i rho_g rho_w rho_p rho_r zstar lstar pistar rstar;

//fixed parameters
delta = 0.025/4; //depreciation rate, Sugo-Ueda (2008)
alpha = 0.36; //capital share, Sugo-Ueda (2008)
gyss = 0.362; //external demand-output ratio, data mean
lambdaw = 0.20; //wage markup, Sugo-Ueda (2008)

model(linear);

#rss = 1+rstar/100;
#zss = 1+zstar/100;
#beta = zss^sigma/rss;
#wss = (1-alpha)*(1/(1+lambdap))^(1/(1-alpha))
*((zss^sigma/beta-1+delta)/alpha)^(-alpha/(1-alpha));
#rkss = zss^sigma/beta-1+delta;
#klss = zss*alpha*wss/((1-alpha)*rkss);
#kyss = (1+phi)*zss^alpha*klss^(1-alpha);
#iyss = (1-(1-delta)/zss)*kyss;
#cyss = 1-iyss-gyss;

//marginal utility of consumption
(1-theta/zss)*(1-theta/rss)*lambda
= -sigma*(c-theta/zss*(c(-1)-z_z)) + (1-theta/zss)*z_b
+ theta/rss*(sigma*(c(+1)+z_z(+1)-theta/zss*c)
-(1-theta/zss)*z_b(+1));

//Euler equation
lambda = lambda(+1) - sigma*z_z(+1) + rn - pi(+1);

//wage
w - w(-1) + pi - gammaw*pi(-1) + z_z
= zss/rss*(w(+1)-w+pi(+1)-gammaw*pi+z_z(+1))
+ (1-xiw)*(1-xiw*zss/rss)*lambdaw
/(xiw*(lambdaw+chi*(1+lambdaw)))
*(chi*l-lambda-w+z_b) + z_w;

//capital
k = (1-delta)/zss*(k(-1)-z_z) - rkss/zss*u
+ (1-(1-delta)/zss)*i;

//investment
zetainv*(i-i(-1)+z_z+z_i)
= q + zetainv*zss/rss*(i(+1)-i+z_z(+1)+z_i(+1));

//capital utilization
u = mu*(rk-q);

//Tobin's q
q = lambda(+1) - lambda - sigma*z_z(+1)
+ 1/rss*(rkss*rk(+1)+(1-delta)*q(+1));

//market clearing condition
y = cyss*c + iyss*i + gyss*z_g;

//marginal cost
mc = (1-alpha)*w + alpha*rk;

//cost minimization
w - rk = u + k(-1) - l - z_z;

//production function
y = (1+phi)*((1-alpha)*l + alpha*(u+k(-1)-z_z));

//price
pi - gammap*pi(-1) = zss/rss*(pi(+1)-gammap*pi)
+ (1-xip)*(1-xip*zss/rss)/xip*mc + z_p;

// policy rule, r is a nominal interest rate
rn = phir*rn(-1) + (1-phir)*(phipi*(pi+pi(-1)+pi(-2)+pi(-3))/4
+ phiy*(y-ypot)) + z_r;

//potential output
ypot = -(1+phi)*alpha*z_z;

//exogenous shock processes
z_z = rho_z*z_z(-1) + e_z;
z_b = rho_b*z_b(-1) + e_b;
z_i = rho_i*z_i(-1) + e_i;
z_g = rho_g*z_g(-1) + e_g;
z_w = rho_w*z_w(-1) + e_w;
z_p = rho_p*z_p(-1) + e_p;
z_r = rho_r*z_r(-1) + e_r;

// observation equations
dy_obs = zstar + z_z + y - y(-1);
dc_obs = zstar + z_z + c - c(-1);
di_obs = zstar + z_z + i - i(-1);
dw_obs = zstar + z_z + w - w(-1);
l_obs = lstar + l;
pi_obs = pistar + pi;
rn_obs = rstar + pistar + rn;

end;

estimated_params;
sigma, 1.5,,,gamma_pdf, 1, 0.375; //Sugo-Ueda (2008)
theta, 0.4,,,beta_pdf, 0.5, 0.2; //Sugo-Ueda (2008)
chi, 4.4,,,gamma_pdf, 1.75, 0.75; //Sugo-Ueda (2008)
zetainv, 7.1,,,gamma_pdf, 0.5, 0.5; //Sugo-Ueda (2008)
mu, 2.1,,,gamma_pdf, 1,1; //Sugo-Ueda (2008)
phi, 0.1,,,gamma_pdf, 0.075, 0.0125; //Sugo-Ueda (2008)
gammaw, 0.3,,,beta_pdf, 0.5, 0.2; //Sugo-Ueda (2008)
xiw, 0.5,,,beta_pdf, 0.7, 0.15; //Sugo-Ueda (2008)
gammap, 0.6,,,beta_pdf, 0.5, 0.2; //Sugo-Ueda (2008)
xip, 0.7,,,beta_pdf, 0.7, 0.1; //Sugo-Ueda (2008)
lambdap, 0.15,,,gamma_pdf, 0.15, 0.05; //Justiniano et al. (2010)
zstar, ,,, normal_pdf, 0.70, 0.3;
lstar, ,,,normal_pdf, 0.0, 0.05;
pistar, ,,,gamma_pdf, 3, 2;
rstar, ,,,gamma_pdf, 0.5, 0.2;
phir, 0.7,,,beta_pdf, 0.8, 0.1; //Iiboshi et al. (2006)
phipi, 1.7,,, normal_pdf, 1.5, 0.05; //Iiboshi et al. (2006)
phiy, 0.08,,, normal_pdf, 0.125, 0.05; // Iiboshi et al. (2006)
rho_z, 0.1,,,beta_pdf, 0.8, 0.1;
rho_b, 0.7,,,beta_pdf, 0.8, 0.1;
rho_i, 0.5,,,beta_pdf, 0.8, 0.1;
rho_g, 0.9,,,beta_pdf, 0.8, 0.1;
rho_w, 0.2,,,beta_pdf, 0.8, 0.1;
rho_p, 0.9,,,beta_pdf, 0.8, 0.1;
rho_r, 0.5,,,beta_pdf, 0.75, 0.1;
stderr e_z, 1.6,,,inv_gamma_pdf, 0.005, 0.1;
stderr e_b, 3.1,,,inv_gamma_pdf, 0.005, 0.1;
stderr e_i, 4.8,,,inv_gamma_pdf, 0.005, 0.1;
stderr e_g, 0.4,,,inv_gamma_pdf, 0.005, 0.1;
stderr e_w, 0.5,,,inv_gamma_pdf, 0.005, 0.1;
stderr e_p, 0.2,,,inv_gamma_pdf, 0.005, 0.1;
stderr e_r, 0.1,,,inv_gamma_pdf, 0.005, 0.1;
end;

varobs dy_obs dc_obs di_obs dw_obs l_obs pi_obs rn_obs;

estimation(datafile = jpdat, mode_check, mh_replic = 200000,
mh_nblocks = 2, mh_jscale = 0.35, mode_compute=9, bayesian_irf, smoother);

stoch_simul;

shock_decomposition(parameter_set=posterior_mean) dy_obs;
shock_decomposition(parameter_set=posterior_mean) dc_obs;
shock_decomposition(parameter_set=posterior_mean) di_obs;
shock_decomposition(parameter_set=posterior_mean) dw_obs;
shock_decomposition(parameter_set=posterior_mean) l_obs;
shock_decomposition(parameter_set=posterior_mean) pi_obs;
shock_decomposition(parameter_set=posterior_mean) rn_obs;

This is the problem :
Configuring Dynare ...
[mex] Generalized QZ.
[mex] Sylvester equation solution.
[mex] Kronecker products.
[mex] Sparse kronecker products.
[mex] Local state space iteration (second order).
[mex] Bytecode evaluation.
[mex] k-order perturbation solver.
[mex] k-order solution simulation.
[mex] Quasi Monte-Carlo sequence (Sobol).
[mex] Markov Switching SBVAR.

Starting Dynare (version 4.3.3).
Starting preprocessing of the model file ...
Substitution of endo lags >= 2: added 2 auxiliary variables and equations.
Found 30 equation(s).
Evaluating expressions...done
Computing static model derivatives:
- order 1
Computing dynamic model derivatives:
- order 1
- order 2
Processing outputs ...done
Preprocessing completed.
Starting MATLAB/Octave computing.


You did not declare endogenous variables after the estimation/calib_smoother command.
Posterior IRFs, smoothed variables will be computed for the 30
endogenous variables of your model, this can be very long....


Choose one of the following options:

[1] Consider all the endogenous variables.
[2] Consider all the observed endogenous variables.
[3] Stop Dynare and change the mod file.

options [default is 1] = 2

ans =

26


ans =

Empty matrix: 0-by-1

Error using dynare_estimation_init (line 145)
Initial parameter values are outside parameter bounds

Error in dynare_estimation_1 (line 59)
[dataset_,xparam1, M_, options_, oo_, estim_params_,bayestopt_] = dynare_estimation_init(var_list_,
dname, [], M_, options_, oo_, estim_params_, bayestopt_);

Error in dynare_estimation (line 70)
dynare_estimation_1(var_list,dname);

Error in bkk (line 292)
dynare_estimation(var_list_);

Error in dynare (line 120)
evalin('base',fname) ;

I do not know where is the wrong. Can you help me? Thank you very much!

From Japan Yo

Re: can you help me?

PostPosted: Sun Dec 01, 2013 7:16 pm
by costa
Running model diagostics I think you got a problem with the initial parameter values:
I think this post is related with you doubt:
viewtopic.php?f=1&t=2240

Re: can you help me?

PostPosted: Mon Dec 02, 2013 2:42 pm
by jpfeifer
The recent snapshot says
Error using check_prior_bounds (line 39)
Initial value(s) of rho_z are outside parameter bounds. Potentially, you should set prior_trunc=0. If you used the mode_file-option, check whether your mode-file is consistent with
the priors.

The reason is that 0.1 as the starting value for rho_z is very unlikely given the assumed distribution. Setting
Code: Select all
prior_trunc=0

in the estimation command solves the issue.