I try to estimate a medium-scale DSGE model but I encounter the following warning:

[code]Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN.

In kalman_filter at 182
In dsge_likelihood at 646
In gmhmaxlik at 108
In dynare_estimation_1 at 418
In dynare_estimation at 89
In Bayes at 770
In dynare at 180
Warning: Matrix is singular to working precision.
In lyapunov_symm at 145
In dsge_likelihood at 374
In gmhmaxlik at 108
In dynare_estimation_1 at 418
In dynare_estimation at 89
In Bayes at 770
In dynare at 180 [/code]

This happens for each iteration. The model seems to be ok. When I run stoch.simul command with given values of parameteres, all variables converge to their st.st. values and the responses are as expected.

However, the estimation does not work. What can I do with this? Is there any solution? I would like to kindly ask you for a help. Please see the model code and data attached.

thank you very much for reply. Sorry for such a late answer. I was not able to respond.

I tried to estimate the model with all but one time series used in initial estimation. The estimation procedure looks fine now, there are no errors or warnings. However, the posterior distributions do not look good (please see attached file). What could be the reason behind? Can you guess?

I ran the estimation with the following specification: diffuse_filter, mode_check, mh_replic=10000, mh_nblocks=2, mh_drop=0.3, mh_jscale=0.4, mode_compute=6.

Should I try another optimization routine, or the problem lies elsewhere? Thank you very much for helping me!

Looking at your plots I have the impression that you should increase the number of iterations in the metropolis, clearly mh_replic=10000 is too small. So you should restart the estimation with the following options:

The last option is important. With this option Dynare sets as an initial condition the last state of the MCMC in the previous estimation. Without this option, the draws of the previous MCMC are discarded. You can also check the convergence diagnostics at the end of the estimation… And run again the estimation (with the same options) if more iterations are needed.