Posterior covariance matrix of the estimated parameters
After the metropolis (that is after the estimation command in the mod file) you just have to write:
This matlab routine will estimate the mode, the mean and the covariance matrix of the posterior distribution from the MCMC draws. The estimated mode (xparam1), the logged posterior density at the mode (fval) and the inverse of the estimated covariance matrix (hh) are saved in a matlab *.mat file called :
<THE NAME OF YOUR MOD FILE>_mh_mode.mat
You can load this file and get the estimated covariance matrix by inversing hh. The inverse of the posterior covariance matrix is saved and not the covariance matrix itself because it may help to use this _mh_mode file to restart a new metropolis (hopefully, with a better estimate of the posterior covariance matrix of the parameters).
If the following syntax is used:
[ M, S ] = compute_mh_covariance_matrix;
then M and S are the posterior mean and covariance matrix.
As described in MonteCarloOptimization, a recursive approach is used to estimate the covariance matrix so we don't have to load all the draws of the MCMC at once.