Error using chol and some other errors i get

hello dear prof. pfeifer.
I have some problems in my code, I have tried to solve them according to similar topics, But failed. my model is heterogeneous agent model with landa share of rule of thumb households.
here is the first note i got when running the model,

Note: numbers do not add up to 100 due to non-zero correlation of simulated shocks in small samples

You did not declare endogenous variables after the estimation/calib_smoother command.
Posterior IRFs will be computed for the 13 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.**

by choosing (1), i get several warnings including:
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate.

and n the end this is what i face:

MODE CHECK

Fval obtained by the minimization routine (minus the posterior/likelihood)): 2439.193557
Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate.
RCOND = NaN. **
> In dynare_estimation_1 (line 339)
** In dynare_estimation (line 105)

** In rgh_esfand (line 235)**
** In dynare (line 223) **

RESULTS FROM POSTERIOR ESTIMATION
parameters
** prior mean mode s.d. prior pstdev**

**landa 0.250 0.6702 NaN beta 0.1000 **
**rho_m 0.782 0.4031 NaN beta 0.0500 **
**rho_pi -1.245 -0.6265 NaN norm 0.1000 **
**rho_x -2.234 -1.5979 NaN norm 0.1000 **
**phi 3.000 0.8174 NaN gamm 0.5000 **
**beta 0.960 0.9788 NaN beta 0.0120 **
**rhoa 0.700 0.7607 NaN beta 0.1000 **

Log data density [Laplace approximation] is NaN.

Error using chol
Matrix must be positive definite.
Error in posterior_sampler_initialization (line 84)
d = chol(vv);
Error in posterior_sampler (line 60)
** posterior_sampler_initialization(TargetFun, xparam1, vv,**
** mh_bounds,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,oo_);**
Error in dynare_estimation_1 (line 447)
** posterior_sampler(objective_function,posterior_sampler_options.proposal_distribution,xparam1,posterior_sampler_options,bounds,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,oo_);**
** Error in dynare_estimation (line 105)**
** dynare_estimation_1(var_list,dname);**
Error in rgh_esfand (line 235)
oo_recursive_=dynare_estimation(var_list_);
Error in dynare (line 223)
**evalin(‘base’,fname) ; **
>> here are my code and data file, if needed
rgh_esfand.mod (2.0 KB)
rgh_amar.m (3.6 KB)

could you please help me? thank you

Your prior is too tight (and quite strange for the rho). Change the prior to something more sensible or at least use prior_trunc=0.

Thanks indeed, can you tell me more about prior_trunc? Or introduce a file so i could get some i formation about it?

See the Dynare manual.

Thank u very much

hello dear prof. and sorry for the disturb
when i use prior_trunc the model will be estimated, i have some questions:

  1. how can i understand if it is a good estimation? for example for landa (share of rule of thumb households) the prior mean is about 0.27, the posterior mean is more than 0.8! does it mean that my estimation is wrong or my priors are not proper?
  2. can i use the gained prior mean as my model priors (which u said is too tight)?
  3. what did you exactly mean be tight priors? i have studies some good articles of iran’s economy and reached them, how can i understand which are inappropriate?

You need to be more careful in your terminology.

proper priors

is a technical term with a different meaning.
Priors, as the name suggests, are subjective, i.e. you chose them. However, you need to be able to defend them. Although not recommended, it is usually a good idea to compare your priors to the ones used by other people, e.g. the Smets/Wouters (2007) paper.

Regarding the high RoT-share: that is hard to tell. Strange estimation results can come from various problems. If the posterior mean is that far from the prior, the problem is not the prior, but something else.

hello dear prof , i get the following error in my estimation, what can be the reason? what does NaN mean?

Log data density [Laplace approximation] is NaN.

Error using chol
Matrix must be positive definite.
Error in posterior_sampler_initialization (line 84)
d = chol(vv);
Error in posterior_sampler (line 60)
posterior_sampler_initialization(TargetFun, xparam1, vv,
mh_bounds,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,oo_);
Error in dynare_estimation_1 (line 447)
posterior_sampler(objective_function,posterior_sampler_options.proposal_distribution,xparam1,posterior_sampler_options,bounds,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,oo_);
Error in dynare_estimation (line 105)
dynare_estimation_1(var_list,dname);
Error in rgh97f (line 253)
oo_recursive_=dynare_estimation(var_list_);
Error in dynare (line 223)
evalin(‘base’,fname) ;

You should investigate the mode_check-plots

hello dear jpfeifer and thanks for the guide
I did use the mode check in my estimation part and placed mode_compute=6, and…
i dont know if it is a right thing to do but i tried to use the mode in mode_check plots as prior,

i didnt get any error after that… But I think that there is a problem with the graphs, I would send the picture of them, would you please take a look:

There is clearly a problem here. The red dots in the mode_check-plots indicate that the model cannot be solved for those parameters. You need to find out what is going on. Set
options_.debug=1 before estimation to see where the dots come from.

1 Like

thank you very much.
i checked it, and almost all of my parameters get:
mode_check:: could not solve model for parameter ,at value…, error code: 4!
i checked it in print_info.m and it says ‘Blanchard Kahn conditions are not satisfied:’ …
’ indeterminacy
what can i do about it? does my model has any problem? or is it the priors?

That is hard to tell. There may be an economic reason why the model moves to the boundary of the determinacy region. Have a look at the parameters. Is there anything unusual, i.e. are some parameter in regions that are strange given your prior?