Oo_.posterior_mean is missing

I get the following error (Dynare 4.3.3)

This is the content of oo_

Also, this is the set of optims that I call

Am I doing something wrong?



In which function does the crash happen? Unfortunately, you cut the message off.

your are right. It crashe in dynare_estimation_1.m . Look for "(‘mean’ " . I replaced it with ‘mode’ and it works.

Is this a bug? Is the posterior_mean normally produced?


If options_.mh_replic is not 0, then it should exist. It is created by GetPosteriorParametersStatistics. Did you really set

i.e. to 0?

The manual says

so I thought that load_mh_file would suffice (otherwise I have to run an MCMC every time I want to re-generate posterior moments)

Is this correct?

Have you tried leaving the mh_replic option out. My guess is that you specifying it at 0 overwrites the information in the loaded mode-file.

Thanks, but if I leave the option out, I guess I’ll get the default value [20K]
In any case I see that the chain are not overwritten (by the option load_mh_file)

I’ll try with the fs2000 example



I’ve successfully tried with fs2000.mod and the same options_ used in the model that does not produce “posterior_mean”.

Do you know where “posterior_mean” is generated? There must be something odd with the chains that prevent it to be constructed (the other posterior moments are there though)



Ok, we are getting closer. load_mh_file loads the previous draws and adds the number of draws specified in mh_replic at the end. However, posterior moments are only computed in dynare_estimation_1

if options_.mh_replic [marginal,oo_] = marginal_density(M_, options_, estim_params_, oo_); oo_ = GetPosteriorParametersStatistics(estim_params_, M_, options_, bayestopt_, oo_); if ~options_.nograph oo_ = PlotPosteriorDistributions(estim_params_, M_, options_, bayestopt_, oo_); end [oo_.posterior.metropolis.mean,oo_.posterior.metropolis.Variance] ... = GetPosteriorMeanVariance(M_,options_.mh_drop); else load([M_.fname '_results'],'oo_'); end
Thus, if you set mh_replic to 0, Dynare will load the previous results from the results-file and not create additional fields. But for some reason your previous results also did not compute and save the posterior mean field. As a quick hack, you could just set

if options_.mh_replic >=0

If you could describe the particular use you were intending, we might be able to get around this issue by implementing a solution.

The workaround seems to do its job. Thanks!

I’m trying to do some graphical analysis of the MCMC output after the chains have been generated in a cluster
in non-graphical mode.




I crossed this thread while trying to fix Github issue #544. From the details given in the first post of this thread, I infer that the MCMC draws were generated with an older version of dynare (I do not see other explanation). I guess that in this previous version of dynare there was no posterior_mean field in oo_… So this is a compatibility issue between 4.3.3 and older versions). Version compatibility is a recurrent problem in Dynare that we need to fix.

The fix proposed by Johannes works but you should not keep this patch (you only need this once to create the posterior_mean missing field), otherwise you will compute the posterior moments each time you call estimation with the load_mh_file option and mh_replic=0 which can be quite time consuming and is not necessary.