Page 1 of 2
error file mod
Posted:
Fri Aug 29, 2014 11:48 am
by Ina
Hi, I am trying to work with dynare. My file mod is the following
// .mod file for estimating model
var pi, y, r, u, epspi, epsr, epsy, epsu, inflobs, outputobs, ffrobs, uobs; % endogenous variables and exogenous latent AR(1)processes
varexo eepspi, eepsy, eepsr, eepsu; % shocks
parameters beta, alpha, k, h, tau, phipi, phiy, phir, rhopi, rhor, rhoy, rhou;
//initial values for the parameter vector
//quarterly data(no annualization)
//fixed/steady state parameters
beta = 0.99;
rhopi=0.6;
//structural model
alpha=0.99;
h=0.9;
k=0.1;
tau=0.15;
phipi=1.5;
phiy=0.25;
phir=0.9;
rhopi=0.6;
rhor=0.5;
rhoy=0.5;
rhou=0.1;
model;
// state space
pi=beta*pi(1)+k*y+u+epspi;
y=(1/(1+h))*y(1)+(h/(1+h))*y(-1)-tau*(r-pi(1))+epsy;
r=(1-phir)*(phipi*pi+phiy*y)+phir*r(-1)+epsr;
u=rhou*u(-1)+alpha*y+epsu;
epspi=rhopi*epspi(-1)+eepspi;
epsy=rhoy*epsy(-1)+eepsy;
epsr=rhor*epsr(-1)+eepsr;
epsu=rhou*epsu(-1)+eepsu;
//measurement equation
inflobs=pi;
outputobs=y;
ffrobs=r;
uobs=u;
end;
steady(solve_algo=0);check;
estimated_params;
beta, beta_pdf, 0.4,0.1;
alpha, beta_pdf, 0.9,0.03;
k, 0.04,0.001,1,gamma_pdf,0.1,0.02;
h, 0.62,beta_pdf,0.5,0.1;
tau, 0.10,gamma_pdf,0.1,0.05;
phipi,1.99, normal_pdf,1.5,0.2;
phiy,0.15,gamma_pdf,0.3, 0.2;
phir, 0.75,beta_pdf,0.5,0.2;
rhopi,0.5,beta_pdf,0.6,0.1;
rhor,0.5,beta_pdf,0.6,0.1;
rhoy,0.5,beta_pdf,0.6,0.1;
rhou,0.5,beta_pdf,0.6,0.1;
// shocks, stdevs
stderr eepspi,0.10,inv_gamma_pdf,0.3,3;
stderr eepsy,0.50,inv_gamma_pdf,0.3,3;
stderr eepsr,0.22,inv_gamma_pdf,0.3,3;
stderr eepsu,0.25,inv_gamma_pdf,0.3,3;
end;
varobs inflobs outputobs ffrobs uobs;//
//sample: 1982q1-2012q2
estimation(datafile=fyhu1_data,prefilter=1,first_obs=1, mode_compute=4,mode_check,mh_replic=0);% ycbo seems to work better
estimation(datafile=fyhu1_data,prefilter=1,first_obs=1,mh_jscale=0.65,mh_drop=0.05,mode_compute=4,mh_nblocks=2,bayesian_irf,filtered_vars,conf_sig=0.90,mh_replic=200000); % ycbo seems to work better
BUT, the only grafics shows are the priors and then the respose of Matlab is the sequence:
You did not declare endogenous variables after the estimation/calib_smoother command.
Error using fyhu1_data (line 1)
Error using vertcat
Dimensions of matrices being concatenated are not consistent.
Error in read_variables (line 72)
eval(basename);
Error in initialize_dataset (line 32)
rawdata = read_variables(datafile,varobs,[],xls.sheet,xls.range);
Error in dynare_estimation_init (line 471)
dataset_ =
initialize_dataset(options_.datafile,options_.varobs,options_.first_obs,options_.nobs,transformation,options_.prefilter,xls);
Error in dynare_estimation_1 (line 81)
[dataset_,xparam1, hh, M_, options_, oo_, estim_params_,bayestopt_] =
dynare_estimation_init(var_list_, dname, [], M_, options_, oo_,
estim_params_, bayestopt_);
Error in dynare_estimation (line 89)
dynare_estimation_1(var_list,dname);
Error in fusa1 (line 220)
dynare_estimation(var_list_);
Error in dynare (line 180)
evalin('base',fname) ;
Error in read_variables (line 72)
eval(basename);
Error in initialize_dataset (line 32)
rawdata = read_variables(datafile,varobs,[],xls.sheet,xls.range);
Error in dynare_estimation_init (line 471)
dataset_ =
initialize_dataset(options_.datafile,options_.varobs,options_.first_obs,options_.nobs,transformation,options_.prefilter,xls);
Error in dynare_estimation_1 (line 81)
[dataset_,xparam1, hh, M_, options_, oo_, estim_params_,bayestopt_] =
dynare_estimation_init(var_list_, dname, [], M_, options_, oo_,
estim_params_, bayestopt_);
Error in dynare_estimation (line 89)
dynare_estimation_1(var_list,dname);
Error in fusa1 (line 220)
dynare_estimation(var_list_);
Error in dynare (line 180)
evalin('base',fname) ;
I can not find where is the problem. I need some help.Thanks
Re: error file mod
Posted:
Fri Aug 29, 2014 11:52 am
by jpfeifer
This is a problem with the data-file. Please post it.
Re: error file mod
Posted:
Mon Sep 01, 2014 9:54 am
by Ina
Here is the file
Re: error file mod
Posted:
Mon Sep 01, 2014 11:54 am
by jpfeifer
There are three lines in the datafile
- Code: Select all
-0.143358057-6.983381265 0.18 0.950410312 58.3
-0.962194211-7.456792282 0.18 1.937704542 68.2
-1.617604064-7.49921989 0.16 1.701094579 68.4
where the first two entries are not separated by a space. Fix this. To see the problem, execute the datafile separately in Matlab using F5
Re: error file mod
Posted:
Wed Sep 03, 2014 3:03 pm
by Ina
Hi,
thanks for your help. It works better in sense that it coms out same more graphs like mode check plot,smoothed and mode but not the estimate and the irf. In fact it comes out the sequense:
Error using chol
Matrix must be positive definite.
Error in metropolis_hastings_initialization (line 68)
d = chol(vv);
Error in random_walk_metropolis_hastings (line 62)
[ ix2, ilogpo2, ModelName, MetropolisFolder, fblck, fline, npar, nblck, nruns, NewFile, MAX_nruns, d
] = ...
Error in dynare_estimation_1 (line 782)
feval(options_.posterior_sampling_method,objective_function,options_.proposal_distribution,xparam1,invhess,bounds,dataset_,options_,M_,estim_params_,bayestopt_,oo_);
Error in dynare_estimation (line 89)
dynare_estimation_1(var_list,dname);
Error in fusa1 (line 234)
dynare_estimation(var_list_);
Error in dynare (line 180)
evalin('base',fname) ;
What should I do know?
Re: error file mod
Posted:
Wed Sep 03, 2014 3:39 pm
by jpfeifer
Search the forum. There are a variety of issues that can lead to this problem (most often there is an identifcation issue or the data do not match the observation equation). See e.g.
http://www.dynare.org/phpBB3/viewtopic.php?f=1&t=5417
Re: error file mod
Posted:
Sun Sep 07, 2014 10:10 am
by Ina
Ok,done. Thanks a lot for your help.
Re: error file mod
Posted:
Fri Sep 12, 2014 12:09 pm
by Ina
Hi,
I am trying to do another example with the same data and this time the mod file is the sequence:
// .mod file for estimating model
var pi, y, r, u, e, epspi, epsy, epsr, epsu, epse, inflobs, outputobs, ffrobs, uobs, eobs; % endogenous variables and exogenous latent AR(1)processes
varexo eepspi, eepsy, eepsr, eepsu, eepse; % shocks
parameters beta, alpha, alphae, gamma, gammau, h, k, tau, phipi, phiy, phir, rhopi, rhor, rhoy, rhou rhoe;
//initial values for the parameter vector
//quarterly data(no annualization)
//fixed/steady state parameters
beta = 0.99;
rhopi=0.6;
//structural model
alpha=0.99;
alphae=0.99;
h=0.9;
k=0.1;
tau=0.15;
phipi=1.5;
phiy=0.25;
phir=0.9;
rhopi=0.6;
rhor=0.5;
rhoy=0.5;
rhou=0.5;
rhoe=0.5;
gamma=0.5;
gammau=0.5;
model;
// state space
pi=beta*(gamma*pi(1)+(1-gamma)*e)+k*y+u+epspi;
y=(1/(1+h))*(gammau*y(1)+(1-gammau)*u)+(h/(1+h))*y(-1)-tau*(r-pi(1))+epsy;
r=(1-phir)*(phipi*pi+phiy*y)+phir*r(-1)+epsr;
u=rhou*u(-1)+alpha*y(-1)+epsu;
e=rhoe*u(-1)+alphae*y(-1)+epse;
epspi=rhopi*epspi(-1)+eepspi;
epsy=rhoy*epsy(-1)+eepsy;
epsr=rhor*epsr(-1)+eepsr;
epsu=rhou*epsu(-1)+eepsu;
epse=rhoe*epse(-1)+eepse;
//measurement equation
inflobs=pi;
outputobs=y;
ffrobs=r;
uobs=u;
eobs=e;
end;
steady(solve_algo=0);check;
estimated_params;
k, 0.04,0.001,1,gamma_pdf,0.1,0.02;
h, 0.62,beta_pdf,0.5,0.1;
tau, 0.10,gamma_pdf,0.1,0.05;
phipi,1.99, normal_pdf,1.5,0.2;
phiy,0.15,gamma_pdf,0.3, 0.2;
phir, 0.75,beta_pdf,0.5,0.2;
rhopi,0.5,beta_pdf,0.6,0.1;
rhor,0.5,beta_pdf,0.6,0.1;
rhoy,0.5,beta_pdf,0.6,0.1;
rhou,0.5,beta_pdf,0.6,0.1;
rhoe,0.5,beta_pdf,0.6,0.1;
gamma, beta_pdf, 0.5,0.2;
gammau, beta_pdf, 0.5,0.2;
//shocks,stdevs
stderr eepspi,0.10,inv_gamma_pdf,0.3,2;
stderr eepsy,0.50,inv_gamma_pdf,0.3,2;
stderr eepsr,0.22,inv_gamma_pdf,0.3,2;
stderr eepsu,0.25,inv_gamma_pdf,0.3,2;
stderr eepse,0.25,inv_gamma_pdf,0.3,2;
end;
varobs inflobs outputobs ffrobs uobs eobs;//
//sample: 1982q1-2012q2
estimation(datafile=fyhu1_data,prefilter=1,first_obs=1, mode_compute=4,mode_check,mh_replic=0);% ycbo seems to work better
estimation(datafile=fyhu1_data,prefilter=1,first_obs=1,conf_sig=0.90,mh_nblocks=5,mh_jscale=0.2,mh_drop=0.5,mode_compute=4,mode_check,bayesian_irf,filtered_vars,forecast=40,mh_replic=200000); % ycbo seems to work better
But, it comes out only the priors and the response from matlab is:
Error in computing likelihood for initial parameter values
ESTIMATION_CHECKS: There was an error in computing the likelihood for initial parameter values.
ESTIMATION_CHECKS: You should try using the calibrated version of the model as starting values. To do
ESTIMATION_CHECKS: this, add an empty estimated_params_init-block with use_calibration option immediately before the estimation
ESTIMATION_CHECKS: command (and after the estimated_params-block so that it does not get overwritten):
Error using print_info (line 42)
Blanchard Kahn conditions are not satisfied: no stable equilibrium
Error in print_info (line 42)
error(['Blanchard Kahn conditions are not satisfied: no stable' ...
Error in initial_estimation_checks (line 69)
print_info(info, DynareOptions.noprint, DynareOptions)
Error in dynare_estimation_1 (line 179)
oo_ =
initial_estimation_checks(objective_function,xparam1,dataset_,M_,estim_params_,options_,bayestopt_,oo_);
Error in dynare_estimation (line 89)
dynare_estimation_1(var_list,dname);
Error in teza (line 257)
dynare_estimation(var_list_);
Error in dynare (line 180)
evalin('base',fname) ;
Which is the problem?
An element of the Jacobian is not finite or NaN
Posted:
Fri Sep 12, 2014 10:27 pm
by lilianagnr
Hii!
This is my code, i dont know why told me "An element of the Jacobian is not finite or NaN"
var y i k n c z ke ce ne ye ie;
predetermined_variables ke;
varexo eps;
parameters beta delta alpha sigma zsigma rho eta kss css nss yss iss;
beta=.99;
delta =.025;
alpha =.36;
sigma = 2;
rho = 0.95;
eta = 2.008;
kss = 11.3977;
css = 0.8263;
nss = 0.30;
yss = 1.1113;
iss = 0.2849;
zsigma=0.007;
model;
z*(1-alpha)*(kss*ke)^alpha*(nss*ne)^(-alpha)=eta*css*ce/(1-nss*ne);
(1-nss*ne)^eta/(css*ce*(1-nss*ne)^eta)^sigma=beta*((1-nss*(ne(+1)))^eta/(css*(ce(+1)))*((1-nss*(ne(+1)))^eta)^sigma*(z(+1)*alpha*(kss*(ke(+1)))^(alpha-1)*(nss*(ne(+1)))^(1-alpha)+1-delta));
z*(kss*ke)^alpha*(nss*ne)^(1-alpha)= (css*ce)+(kss*(ke(+1)))-(1-delta)*(kss*ke);
z=rho*z(-1)+eps;
(yss*ye)=z*(kss*ke)^alpha*(nss*ne)^(1-alpha);
(iss*ie)=(kss*ke(+1))-(1-delta)*(kss*ke);
ke=exp(k);
ne=exp(n);
ce=exp(c);
ye=exp(y);
ie=exp(i);
end;
set_dynare_seed(10000);
initval;
k=6.7677;
c=6.7677;
n=6.7677;
z=6.7677;
y=6.7677;
i=6.7677;
end;
steady(solve_algo=0);
shocks;
var eps = zsigma^2;
end;
set_dynare_seed(10000);
stoch_simul(order=3, irf=200,periods=2100);
THANKX!
Re: error file mod
Posted:
Sat Sep 13, 2014 7:43 am
by jpfeifer
@Ina
Add
- Code: Select all
estimated_params_init(use_calibration);
end;
before the estimation command. Your prior mean, which is taken as the intial parameter values when you don't specify anyhting else, is not BK stable.
@lilianagr
- Code: Select all
z=rho*z(-1)+eps;
says the steady state of z is 0, but this conflicts with
- Code: Select all
z*(1-alpha)*(kss*ke)^alpha*(nss*ne)^(-alpha)=eta*css*ce/(1-nss*ne);
You need to put z into exp() for all other equations.
Re: error file mod
Posted:
Mon Sep 15, 2014 8:49 am
by Ina
Hi,
I have try to add the comand but it doesn't work and it comes out the same thing as before:
ESTIMATION_CHECKS: There was an error in computing the likelihood for initial parameter values.
ESTIMATION_CHECKS: You should try using the calibrated version of the model as starting values. To do
ESTIMATION_CHECKS: this, add an empty estimated_params_init-block with use_calibration option immediately before the estimation
ESTIMATION_CHECKS: command (and after the estimated_params-block so that it does not get overwritten):
Re: error file mod
Posted:
Mon Sep 15, 2014 9:03 am
by jpfeifer
That's because your model does not run with your calibration. Check your timing and make sure you get your calibrated model to run before proceeding with estimation. The check command already says
EIGENVALUES:
Modulus Real Imaginary
0.2232 0.2232 0
0.5 0.5 0
0.5 0.5 0
0.5 0.5 0
0.5 0.5 0
0.6 0.6 0
1.023 1.023 0
1.309 0.9591 0.8902
1.309 0.9591 -0.8902
4.185 4.185 0
There are 4 eigenvalue(s) larger than 1 in modulus
for 2 forward-looking variable(s)
The rank condition ISN'T verified!
Re: error file mod
Posted:
Mon Oct 12, 2015 12:37 pm
by dominik
Hi
I have a similar problem.
If I run the estrimation 1st order it goes through nicely.
The code attached sets theparameters and the initial values to the mode of the linear estimation. Pruning is on. (using the calibrated parameter initial values option didn't help either)
If I go to 2nd order I get the error below.
Im using dynare 4.4.3 Any ideas? Many thanks!!
ESTIMATION_CHECKS: There was an error in computing the likelihood for initial parameter values.
ESTIMATION_CHECKS: You should try using the calibrated version of the model as starting values. To do
ESTIMATION_CHECKS: this, add an empty estimated_params_init-block with use_calibration option immediately before the estimation
ESTIMATION_CHECKS: command (and after the estimated_params-block so that it does not get overwritten):
Error using chol
Matrix must be positive definite.
Error in sequential_importance_particle_filter (line 125)
Q_lower_triangular_cholesky = chol(Q)';
Error in non_linear_dsge_likelihood (line 322)
LIK = feval(DynareOptions.particle.algorithm,ReducedForm,Y,start,DynareOptions);
Error in initial_estimation_checks (line 47)
[fval,junk1,junk2,a,b,c,d] =
feval(objective_function,xparam1,DynareDataset,DynareOptions,Model,EstimatedParameters,BayesInfo,DynareResults);
Error in dynare_estimation_1 (line 179)
oo_ = initial_estimation_checks(objective_function,xparam1,dataset_,M_,estim_params_,options_,bayestopt_,oo_);
Error in dynare_estimation (line 89)
dynare_estimation_1(var_list,dname);
Error in EST_LEV_XIshock_8807old52 (line 1070)
dynare_estimation(var_list_);
Error in dynare (line 180)
evalin('base',fname) ;
Re: error file mod
Posted:
Mon Oct 12, 2015 12:40 pm
by jpfeifer
Please try the unstable version and then report back.
Re: error file mod
Posted:
Mon Oct 12, 2015 12:53 pm
by dominik
Using the unstable version, I get the same error.
ESTIMATION_CHECKS: There was an error in computing the likelihood for initial parameter values.
ESTIMATION_CHECKS: You should try using the calibrated version of the model as starting values. To do
ESTIMATION_CHECKS: this, add an empty estimated_params_init-block with use_calibration option immediately before the estimation
ESTIMATION_CHECKS: command (and after the estimated_params-block so that it does not get overwritten):
Error using chol
Matrix must be positive definite.
Error in sequential_importance_particle_filter (line 84)
Q_lower_triangular_cholesky = chol(Q)';
Error in non_linear_dsge_likelihood (line 298)
LIK = feval(DynareOptions.particle.algorithm,ReducedForm,Y,start,DynareOptions.particle,DynareOptions.threads);
Error in initial_estimation_checks (line 120)
[fval,junk1,junk2,a,b,c,d] =
feval(objective_function,xparam1,DynareDataset,DatasetInfo,DynareOptions,Model,EstimatedParameters,BayesInfo,BoundsInfo,DynareResults);
Error in dynare_estimation_1 (line 157)
oo_ =
initial_estimation_checks(objective_function,xparam1,dataset_,dataset_info,M_,estim_params_,options_,bayestopt_,bounds,oo_);
Error in dynare_estimation (line 104)
dynare_estimation_1(var_list,dname);
Error in EST_LEV_XIshock_8807old52 (line 1163)
oo_recursive_=dynare_estimation(var_list_);
Error in dynare (line 223)
evalin('base',fname) ;