Running MCMC Metropolis Hastings, we can obtain the marginal posterior density for each estimate parameter from “oo_.posterior_density”. Is it possible to retrieve the joint posterior density for all estimated parameters in Dynare after MCMC estimation?
Thanks in advance!
The point is that the MH algorithm will generate draws from the joint posterior.
But from the point of view of a single parameter (integrating all other parameters out) the joint draws are also draws from the marginal distributions.
So you already have what you want. The reason why you obtain the plots of the marginal posteriors and not the joint posterior is simply for graphical reasons.
Thanks a lot for your help. I understand your point that posterior density of a single parameter is the marginal distributions that integrating all other parameters out from the joint posterior distribution.
In dynare, “oo_.posterior_density” produce two column vectors that capture the marginal posterior density of a single parameter. I am looking for the dynare code for exporting the joint posterior, which should be the stationary distribution of the Markovian Chain.
Could you offer further help?
@Andy_zhao This would be a very high-dimensional object to store. So Dynare does not compute or save it. You would need to compute it yourself using the saved posterior draws on the hard-disk.
Thank you so much for your help! Now I see. Dynare actually does not save the posterior draws.
To be honest, I have no idea how to save the posterior draws from MCMC estimation on my own hard-disk. Would it be possible for you to offer some further guidance?
Unfortunately, the Manual is not explicit about the information stored in the structure
Variable set by the estimation command, if it is used with
mh_replic > 0 or
load_mh_file option. Fields are of the form:
What exactly is stored in this structure? I initially thought it would store the draws of the MH-algorithm from the posterior, but this seems to be not the case.
My second guess was that the posterior draws from the MH-algorithm are stored in the metropolis subfolder. But the files
File_Name_posterior_draws2 do not store the posterior draws. So, what are these
.mat files good for? And where do I get the posterior draws?
Thank you so much for your clear explanation! Now it become more clear to me where to find the posterior draws.
one follow up question is where can I find “posterior_draws*.mat" -files, is it stored under "oo.”?
Thank you very much for the answer.
I have some open questions.
- In the manual I found the following
posterior_sampler_options = (NAME, VALUE, …)
Save the MCMC draws into a
_mh_tmp_blck file at the refresh rate of the status
bar instead of just saving the draws when the current
_mh*_blck file is full.
What is meant by " just saving the draws when the current
_mh*_blck file is full "?
Which value is required to tell Dynare to store the draws in the
(I assume the default 0 means something like “do not store”?)
Under which conditions is it reasonable to use this ‘
save_tmp_file’ option instead of using the
_mh1_blck*.mat -files in the
Could you offer more details about the idea behind the
Because this file contains the cell array called
"pdraws" which in turn encompasses a lot of information, it is not straightforward to get the idea from the file itself. Is there any further documentation?
It seems to be the case that
oo_.posterior_density.parameters.PARAMETER_NAME(:,1) stores 512 grid points and
oo_.posterior_density.parameters.PARAMETER_NAME(:,2) stores the respective 512 estimates of the posterior density at that grid points.
Which kernel density estimator is used for the density estimation and what about the bandwidth selection? Why is the density estimate sometimes turning (weakly) negative?
You can find the
_posterior_draws*.mat -files in the
Thanks a lot. However, I can not find ‘_posterior_draws*.mat’ -files in the ‘metropolis’ subfolder.
I am running MCMC using dynare 4.4.3, and I set mh_replic = 1000000. What had stored in the ‘metropolis’ subfolder are:
(3), modname_mh1_blck1.mat to modname_mh288_blck1.mat: (overall 288 mat files)
(4), modname_mh1_blck2.mat to modname_mh288_blck2.mat: (overall 288 mat files)
Why does not ‘_posterior_draws*.mat’ -files show up in the ‘metropolis’ subfolder? is it because the version of dynare I am using? or maybe because I miss some command code in “estimation” at the time of conducting MCMC Bayesian estimation?
_posterior_draws*.mat-files should only be there is subdraws are required, e.g. because of
Thanks for your help and patience!
May I have one additional question:
I am running MCMC using dynare 4.4.3, and set mh_replic = 1000000, mh_nblocks =2. In the ‘metropolis’ subfolder, I do find the raw posterior draws following your suggestion for the two chain block, which are stored from “modname_mh1_blck1.mat” to “modname_mh288_blck1.mat” (overall 288 mat files) for MCMC chain 1 and from “modname_mh1_blck2.mat” to “modname_mh288_blck2.mat”: (overall 288 mat files) for MCMC chain 2. Base on these results, I am able to collect all raw posterior draw, which is a matrix A with size [1000000*34] as 34 parameters are estimated.
If only a single parameter is estimated, the posterior distribution is one dimension, we can simply use the matlab function"hist" to infer the posterior distribution. However, now I have 34 estimated parameters and the joint posterior distribution should be multi-dimensional. My question is how can I back out the joint posterior distribution based on the raw posterior draw with size [1000000*34]. Could you offer further guidance?