# An error after the MCMC

**URL:** <https://forum.dynare.org/t/an-error-after-the-mcmc/4222>\
**Category:** Dynare help (legacy posts)\
**Created:** [12 October 2014 05:17 UTC](https://forum.dynare.org/t/an-error-after-the-mcmc/4222 "2014-10-12T05:17:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Econbee](https://forum.dynare.org/letter_avatar_proxy/v4/letter/e/c57346/32.png) [@Econbee](https://forum.dynare.org/u/Econbee)\
**Post date:** [12 October 2014 05:17 UTC](https://forum.dynare.org/t/an-error-after-the-mcmc/4222/1 "2014-10-12T05:17:45Z")

</div>

Dear all,

I recently encountered an everytime when I run the MCMC. I used the Dynare unstable version 2014-10-11. The error message is as follows. I have also attached the code for replicating the problem. It seems that when I set mh\_replic as a small number, such as 2000, there is no problem. When mh\_replic is relatively large, such as 20000, the problem arises. I changed to other unstable versions and the problem is still there. I am not sure if this is a bug in Dynare or something else.

Estimation::marginal density: I’m computing the posterior mean and covariance… Undefined function or variable “m1”.  
Error in recursive\_moments (line 50)  
mu = m1;  
Error in compute\_mh\_covariance\_matrix (line 71)  
[posterior\_mean,posterior\_covariance,offset] = recursive\_moments(posterior\_mean,posterior\_covariance,x2(first\_line:end,:),offset);  
Error in marginal\_density (line 53)  
[posterior\_mean,posterior\_covariance,posterior\_mode,posterior\_kernel\_at\_the\_mode] = compute\_mh\_covariance\_matrix();  
Error in dynare\_estimation\_1 (line 767)  
[marginal,oo\_] = marginal\_density(M\_, options\_, estim\_params\_, …  
Error in dynare\_estimation (line 89)  
dynare\_estimation\_1(var\_list,dname);  
Error in US\_small\_110\_modefile (line 349)  
dynare\_estimation(var\_list\_);  
Error in dynare (line 185)  
evalin(‘base’,fname) ;  
Error in RunDynare\_US\_small\_824to082\_110\_modefile (line 14)  
dynare US\_small\_110\_modefile.mod

Thanks a lot!  
[Question in Dynare.rar](https://forum.dynare.org/uploads/default/original/2X/1/1be157c2d35e705df3388b163ae3be67323517d7.rar) (37.9 KB)

---

<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:** [12 October 2014 09:08 UTC](https://forum.dynare.org/t/an-error-after-the-mcmc/4222/2 "2014-10-12T09:08:08Z")

</div>

Thanks for reporting this bug. Replace your the file CutSample.m in the Dynare matlab-folder with the attached one and it should run.  
[CutSample.m](https://forum.dynare.org/uploads/default/original/2X/0/02353ef7209793c276cf8595445d5441948cf911.m) (2.99 KB)

---

<div class="post-metadata">

**Author:** ![Econbee](https://forum.dynare.org/letter_avatar_proxy/v4/letter/e/c57346/32.png) [@Econbee](https://forum.dynare.org/u/Econbee)\
**Post date:** [13 October 2014 02:14 UTC](https://forum.dynare.org/t/an-error-after-the-mcmc/4222/3 "2014-10-13T02:14:34Z")

</div>

Dear Johannes,

It works now. Thank you for providing the bug-fixing file.
