# Jpfeifer code for Smets/Wouters (2007)

**URL:** <https://forum.dynare.org/t/jpfeifer-code-for-smets-wouters-2007/6311>\
**Category:** Replication Attempts\
**Created:** [29 June 2017 13:09 UTC](https://forum.dynare.org/t/jpfeifer-code-for-smets-wouters-2007/6311 "2017-06-29T13:09:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhwqueen](https://forum.dynare.org/letter_avatar_proxy/v4/letter/z/9fc348/32.png) [@zhwqueen](https://forum.dynare.org/u/zhwqueen)\
**Post date:** [29 June 2017 13:09 UTC](https://forum.dynare.org/t/jpfeifer-code-for-smets-wouters-2007/6311/1 "2017-06-29T13:09:16Z")

</div>

Dear all  
Hi, I am using Dynare 4.3 version now. I want to replicate the model of Smets and Wouters(2007) . In table 2, the marginal likelihood of DSGE model is -905.8. AND jpfeifer explained it in one topic that it is as the difference between the marginal data density from the full sample minus the one of the training sample: -1166.524959-(-260.677257)= -905.8477. But I run the code from JohannesPfeifer’s website and I find the Log data density [Laplace approximation] is -1571.472030 .It have  
a large difference from -1166.524959. Is there something wrong? Does -1166.524959 refer to the Log data density [Laplace approximation] for the full data?

---

<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:** [29 June 2017 13:34 UTC](https://forum.dynare.org/t/jpfeifer-code-for-smets-wouters-2007/6311/2 "2017-06-29T13:34:08Z")

</div>

Have you checked the respective samples? I relied on the SW 2007 replication code, which has the sample and the mode-file set to a different case than the baseline.

---

<div class="post-metadata">

**Author:** ![zhwqueen](https://forum.dynare.org/letter_avatar_proxy/v4/letter/z/9fc348/32.png) [@zhwqueen](https://forum.dynare.org/u/zhwqueen)\
**Post date:** [30 June 2017 04:00 UTC](https://forum.dynare.org/t/jpfeifer-code-for-smets-wouters-2007/6311/3 "2017-06-30T04:00:50Z")

</div>

Thanks a lot, professor. I have check the datafile and find that they are both the same。 AND I find that in SW2007 replication code the first\_obs is 71 while your code is 1. The data has 230 samples. I thought that the full sample 1966:1-2004:4 corresponding the first\_obs [71.At](http://71.At) this time the Log data density [Laplace approximation] is -923.052692. It is similar to -905.8. First question: whether the result -905 in SW paper corresponding to the Log data density for sample 1966:1-2004:4?  
Second one : for the mode file . It refer to the file containing previous value for the mode. I wonder where do they come from? In SW2007 the mode file.xparam1 equal to the posterior mode.

---

<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 June 2017 09:09 UTC](https://forum.dynare.org/t/jpfeifer-code-for-smets-wouters-2007/6311/4 "2017-06-30T09:09:33Z")

</div>

You need to use the respective mode-files for the respective samples to replicate the results. They are available at the AER’s homepage.

---

<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:** [19 February 2025 11:18 UTC](https://forum.dynare.org/t/jpfeifer-code-for-smets-wouters-2007/6311/5 "2025-02-19T11:18:17Z")

</div>

3 posts were split to a new topic: [Smets/Wouters 2007: marginal likelihood](https://forum.dynare.org/t/smets-wouters-2007-marginal-likelihood/27197)

---

<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:** [19 February 2025 12:48 UTC](https://forum.dynare.org/t/jpfeifer-code-for-smets-wouters-2007/6311/6 "2025-02-19T12:48:29Z")

</div>

A post was merged into an existing topic: [Smets/Wouters 2007: marginal likelihood](https://forum.dynare.org/t/smets-wouters-2007-marginal-likelihood/27197/4)
