# Bayesian estimation \_ mode\_computation

**URL:** <https://forum.dynare.org/t/bayesian-estimation---mode-computation/5857>\
**Category:** Dynare help (legacy posts)\
**Created:** [2 November 2016 15:14 UTC](https://forum.dynare.org/t/bayesian-estimation---mode-computation/5857 "2016-11-02T15:14:39Z")\
**Posts on this page:** 7\
**Page:** 2

<div class="post-metadata">

**Author:** ![KKLS](https://forum.dynare.org/letter_avatar_proxy/v4/letter/k/ecd19e/32.png) [@KKLS](https://forum.dynare.org/u/KKLS)\
**Post date:** [30 November 2016 10:16 UTC](https://forum.dynare.org/t/bayesian-estimation---mode-computation/5857/21 "2016-11-30T10:16:29Z")

</div>

> [@](#):
>
> by jpfeifer » Tue Nov 29, 2016 8:53 pm
> 
> Not exactly. What you see in those two graphs is an example of bimodality, where the MCMC correctly explores both regions. You still might want to use a longer chain to properly sample from both modes. But there is nothing here to suggest that the chain has not yet converged to its ergodic distribution.  
> Have you looked at a trace\_plot of the posterior density?

Yes I have. and I have included them in the zip folder that i attached.

There is small drift in the middle of the replications horizon for few of the parameters.  
I will keep raising it though. Thanks.

One final question, : in the estimation command can i put all the options that go with stoch\_simul (i.e order=1, hpfilter=1600, irf=40 ) ???

Many many thanks gain for your time Prof. Pfeifer.

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [30 November 2016 10:36 UTC](https://forum.dynare.org/t/bayesian-estimation---mode-computation/5857/22 "2016-11-30T10:36:31Z")

</div>

No, you included the trace\_plot for the parameters, but not the one for the posterior density itself, i.e. the result from

```auto

```

No, you cannot put all the same options there. The manual tells you what is allowed. For example, the `hp_filter` does not work with estimation

---

<div class="post-metadata">

**Author:** ![KKLS](https://forum.dynare.org/letter_avatar_proxy/v4/letter/k/ecd19e/32.png) [@KKLS](https://forum.dynare.org/u/KKLS)\
**Post date:** [3 December 2016 18:08 UTC](https://forum.dynare.org/t/bayesian-estimation---mode-computation/5857/23 "2016-12-03T18:08:01Z")

</div>

Hi Prof. Pfeifer and all ,  
I tried several times to follow up on Prof. Pfeifer advise (see quote below) regarding the trace plot :

> [@](#):
>
> by jpfeifer » Wed Nov 30, 2016 10:36 am  
> No, you included the trace\_plot for the parameters, but not the one for the posterior density itself, i.e. the result from  
> Code: Select all  
> trace\_plot(options\_,M\_,estim\_params\_,‘PosteriorDensity’,1)

so after the \*\*estimation \*\* command i set these commands :

> [@](#):
>
> trace\_plot(options\_,M\_,estim\_params\_,‘PosteriorDensity’,1);  
> trace\_plot(options\_,M\_,estim\_params\_,‘PosteriorDensity’,2);

… but I was not able to get the trace plot . I am getting an error as below.

> [@](#):
>
> Estimation::mcmc: Posterior (dsge) IRFs…  
> Estimation::mcmc: Posterior IRFs, done!  
> Not enough input arguments.
> 
> Error in trace\_plot (line 39)  
> column = name2index(options\_, M\_, estim\_params\_, type, name1);
> 
> Error in BggGKlinear (line 1250)  
> trace\_plot(options\_,M\_,estim\_params\_,‘PosteriorDensity’,1);
> 
> Error in dynare (line 180)  
> evalin(‘base’,fname) ;

Ps.  
I tried only for block one,i.e:

> [@](#):
>
> trace\_plot(options\_,M\_,estim\_params\_,‘PosteriorDensity’,1);

… and I tried writing the command above after I had asked for trace plot of individual estimated parameters (and shocks)

> [@](#):
>
> trace\_plot(options\_,M\_,estim\_params\_,‘StructuralShock’,2,‘epsA’);  
> …  
> all shocks and parameters  
> …
> 
> trace\_plot(options\_,M\_,estim\_params\_,‘PosteriorDensity’,1);

I get the same error ( Dynare produces the trace plot for individual parameters but not the one for the posterior density) . Did I miss something pls ?

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [4 December 2016 08:55 UTC](https://forum.dynare.org/t/bayesian-estimation---mode-computation/5857/24 "2016-12-04T08:55:48Z")

</div>

That command only works in the unstable version of Dynare, to be released as Dynare 4.5.

---

<div class="post-metadata">

**Author:** ![KKLS](https://forum.dynare.org/letter_avatar_proxy/v4/letter/k/ecd19e/32.png) [@KKLS](https://forum.dynare.org/u/KKLS)\
**Post date:** [15 December 2016 18:25 UTC](https://forum.dynare.org/t/bayesian-estimation---mode-computation/5857/25 "2016-12-15T18:25:36Z")

</div>

Hi to Prof. Pfeifer and all,

I have read the previous posts regarding the model comparisons via likelihoods ratio (and odds ratio) .

From one post of Prof. Pfeifer it seems that to compare to models estimated on different data sets , the odds ratio comparisons are not vaild (see the quote below) .

My question that follows is:  
if I got two models A and B where one is a nested version of the other, and where

- for the smaller model I use a data series X and Y (plus some other data which are the same in the two models)
- for the bigger model I use a data series Z = X+Y (that is Z is the sum of X and Y).

The reason I do not use the extra data series on the smaller model is that the smaller model provides a variable which is counterpart to Z only (but no info on its components X or Y).

1. Can I still use the odds ratio comparison based on marginal densities (Laplace and ModifiedHarmonicMean) ?
2. Is there an alternative way of comparing these models ?

Many thanks again Profesor

Ps.

[quote]  
Re: Model Comparison Bayesian Estimation (again)  
Postby jpfeifer » Fri Apr 04, 2014 9:04 am  
Basically all your answers are in Koop’s 2003 textbook “Bayesian Econometrics” on pages 4-5.

1. For Bayesian model comparison models do not need to be nested and there is a natural degrees of freedom correction. \*\*Hence, as long as you use the same data having different parameters does not matter at all.  
\*\*[/quote]

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [16 December 2016 07:54 UTC](https://forum.dynare.org/t/bayesian-estimation---mode-computation/5857/26 "2016-12-16T07:54:28Z")

</div>

The odds ratio is based on the marginal data density. That is the “likelihood” of observing the data given the model. A meaningful comparison involves keeping the data fixed and varying the model. Simultaneously changing the model and the data does not allow for a sensible comparison. Thus, the answer is no. Having Z being the sum of X and Y does not help, because the model only needs to account for this sum, not for the series individually.  
To get some intuition, think about the models having k parameters and there being T observations. Then the bigger model with X and Y observed will have 2\*T-k degrees of freedom while the smaller on with Z will only have T-k.

---

<div class="post-metadata">

**Author:** ![KKLS](https://forum.dynare.org/letter_avatar_proxy/v4/letter/k/ecd19e/32.png) [@KKLS](https://forum.dynare.org/u/KKLS)\
**Post date:** [16 December 2016 16:28 UTC](https://forum.dynare.org/t/bayesian-estimation---mode-computation/5857/27 "2016-12-16T16:28:10Z")

</div>

Many thanks for confirming it Prof. Pfeifer,

A technical question: When I try to find the mode (given that I already have a ‘‘FILENAME\_mode.mat’’)

I get a warning like this:

> [@](#):
>
> The steady state file internally changed the values of the following estimated parameters:

Is there a warning I should care about (indeed when I get this warning, I get a \*\*‘‘non-positive definite Hessian matrix’’ \*\* problem .  
Where would I look to fix that problem please ?

Ps. I googled a bit and I found a script on your github (initial\_estimation\_checks.m ) but it is not clear to me what the problem is in this case.

[Previous page](https://forum.dynare.org/t/bayesian-estimation---mode-computation/5857.md?page=1)
