Matrix of variance-covariance of posterior distribution of estimated parameters

After your metropolis (that is after the estimation command in the mod file) you just have to write :

compute_mh_covariance_matrix;

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.

I save the inverse of the estimated covariance matrix and not the covariance matrix itself because I often use this _mh_mode file to restart a new metropolis (with, hopefully, a better estimate of the covariance matrix).

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.