Help with possible mistake in data?

Hi, I got this code, in order to estimate a basic NK model, which works well with a different datafile (an US one). When arranging a file with data from a different country (Japan, the attached one) I find the following error messages:
??? Error using ==> chol
Matrix must be positive definite.

Error in ==> metropolis_hastings_initialization at 52
d = chol(vv);

Error in ==> random_walk_metropolis_hastings at 58
ix2, ilogpo2, ModelName, MhDirectoryName, fblck, fline, npar, nblck, nruns,
NewFile, MAX_nruns, d ] = …

Error in ==> dynare_estimation_1 at 1106

Error in ==> dynare_estimation at 62

Error in ==> nkmbasic at 133

Error in ==> dynare at 132
evalin(‘base’,fname) ;

anyone could guide me to what exactly I’m doing wrong?? I’m nob enough to don’t notice it!!
Untitled2.m (4.62 KB)

Hi, this is most probably not a problem with the data. There are dozens of posts already discussing this issue. Ill-shaped Hessians occur fairly often after slight changes to the setup. Use mode_compute=6.

Thanks!! I’m trying with that tiny change… to be honest, almost everything on programming is new for me, so I have to I bet I’ll sweat blood in order to finish my thesis! :stuck_out_tongue:

Now it returns me to this weird situation, in which any value I plug isn’t valid:
Loading 129 observations from Untitled2.m

Initial value of the log posterior (or likelihood): -8767320096687087

Change in the covariance matrix = 3.0765.
Mode improvement = 8767319996687086
New value of jscale = 0.84121

Change in the covariance matrix = 38.167.
Mode improvement = 8.9407e-006

prior mean mode s.d. t-stat prior pstdev

sig 2.000 1.6210 0.3812 4.2527 norm 0.1000
eta 2.000 1.7276 0.3708 4.6593 norm 0.1000
beta 0.990 1.0000 0.0369 27.1283 norm 0.0100
omeg 0.750 0.9834 0.2664 3.6908 beta 0.1000
rho 0.750 0.7785 0.2446 3.1834 beta 0.1000
psi1 1.500 1.0847 0.6030 1.7987 norm 0.3000
psi2 0.125 1.8371 0.5511 3.3337 gamm 0.1000
rhou 0.500 0.0695 0.2685 0.2589 beta 0.1500
rhoz 0.500 0.5868 0.2957 1.9845 beta 0.1500
rhov 0.500 0.2524 0.2800 0.9013 beta 0.1500
standard deviation of shocks
prior mean mode s.d. t-stat prior pstdev

e_u 0.150 4.1078 3.9876 1.0301 invg 0.1500
e_z 0.150 8.4475 6.4239 1.3150 invg 0.1500
e_v 0.150 2.2820 5.6762 0.4020 invg 0.1500

Log data density [Laplace approximation] is -99999997.995301.

MH: Multiple chains mode.
MH: Old metropolis.log file successfully erased!
MH: Creation of a new metropolis.log file.
MH: Searching for initial values…
MH: I couldn’t get a valid initial value in 100 trials.
MH: You should Reduce mh_init_scale…
MH: Parameter mh_init_scale is equal to 0.400000.
MH: Enter a new value…

given that the mod file is the following, i suspect is something related with the estimation options…

close all;

var yy infl r u z v;
varexo e_u e_z e_v;
parameters sig eta beta omeg rho psi1 psi2 rhou rhoz rhov;

yy= yy(+1) - (1/sig)(r - infl(+1))+u;
infl= beta
infl(+1) + ((sig+eta)(1-omeg)(1-betaomeg)/omeg)yy + z;



stderr e_u, inv_gamma_pdf, 0.15,0.15;
stderr e_z, inv_gamma_pdf, 0.15,0.15;
stderr e_v, inv_gamma_pdf, 0.15,0.15;
sig, normal_pdf, 2,0.1;
eta, normal_pdf, 2,0.1;
beta, normal_pdf, 0.99,0.01;
omeg, beta_pdf, 0.75, 0.1;
rho, beta_pdf, 0.75, 0.1;
psi1, normal_pdf, 1.5 ,0.3;
psi2, gamma_pdf, 0.125 ,0.1;

rhou, beta_pdf, 0.5, 0.15;
rhoz, beta_pdf, 0.5, 0.15;
rhov, beta_pdf, 0.5, 0.15;

varobs yy infl r;
estimation(datafile=Untitled2, nobs=129,mh_replic=100000,mh_drop=0.2,mh_nblocks=5,mh_jscale=0.3,mode_compute=6,bayesian_irf,moments_varendo);

am I right??

Hi, it looks as if your model is non-stationary. The first equation seems to have a unit root. In this case, you need to specify lik_init=2 in the estimation command, see [Question about examples in the User Guide).

Hi, the problem is already solved, surprisingly, with this options:
varobs yy infl r;
estimation(datafile=japan,mode_compute=6,lik_init=2,mh_replic=5000, bayesian_irf)yy infl r;
and also using the data from an excel file instead of a “m” file seemed to help… don’t know why but it works well now
Anyway, thanks !!