# Smets-Wouters model with OccBin with U.S. updated data

**URL:** <https://forum.dynare.org/t/smets-wouters-model-with-occbin-with-u-s-updated-data/27346>\
**Category:** Occbin\
**Created:** [23 March 2025 08:23 UTC](https://forum.dynare.org/t/smets-wouters-model-with-occbin-with-u-s-updated-data/27346 "2025-03-23T08:23:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ddiaze](https://forum.dynare.org/letter_avatar_proxy/v4/letter/d/d26b3c/32.png) [@ddiaze](https://forum.dynare.org/u/ddiaze)\
**Post date:** [23 March 2025 08:23 UTC](https://forum.dynare.org/t/smets-wouters-model-with-occbin-with-u-s-updated-data/27346/1 "2025-03-23T08:23:05Z")

</div>

Hello,  
I am working on updating the SW07 model without price indexation for the U.S. economy up to 2019 using the OccBin tool. I have updated the data using the [Fred data](https://fredaccount.stlouisfed.org/public/datalist/803) following the excel file in the replication file [usmodel\_data.xls](https://www.aeaweb.org/articles?id=10.1257/aer.97.3.586).

My Occbin block is:

%%OCCBIND  
[name=‘Notional rate Taylor rule’]  
r\_not = crpi\*(1-crr)_pinf  
+cry_(1-crr)_(y-yf)  
+crdy_(y-yf-y(-1)+yf(-1))  
+crr\*r\_not(-1)  
+ms ;

[name=‘Observed interest rate’, relax=‘zlb’]  
r = r\_not;  
[name=‘Observed interest rate’, bind=‘zlb’]  
r = -conster;

%%

I have a problem with the mod file, which struggles to converge around the 177 period (around the start of the 2008 crisis) saying that the piecewise Kalman filter has NaN or the Matrix is close to singular and never finds the mode.  
So far this is what I tried that has not worked out:

1. Estimate the SW up to 2019 without the Occbin to get the mode, then use that mode file with the Occbin setup.
2. Try different priors. The attached mod file has the original SW07 priors but I have considered the Professor Pfeifer priors on [here] ([DSGE\_mod/Smets\_Wouters\_2007/Smets\_Wouters\_2007\_45.mod at master · JohannesPfeifer/DSGE\_mod · GitHub](https://github.com/JohannesPfeifer/DSGE_mod/blob/master/Smets_Wouters_2007/Smets_Wouters_2007_45.mod)).
3. Explore different regimes on the Occbin specification. My baseline case is:

name ‘zlb’; bind r \< -(((1+constepinf/100)/((1/(1+constebeta/100))\*(1+ctrend/100)^(-csigma)))-1)_100 -1e-4; relax r\_not \> -(((1+constepinf/100)/((1/(1+constebeta/100))_(1+ctrend/100)^(-csigma)))-1)\*100 + 1e-4;

where the (((1+constepinf/100)/((1/(1+constebeta/100))\*(1+ctrend/100)^(-csigma)))-1)\*100 is the parameter conster, avoiding to call it as local parameter. To help buffering the Occbin constrain, I am setting a big ZLB value, r\_elb =0.5 because around the period 177 where the Kalmar filter struggles, the robs drops from 0.485 in the observation 245 to 0.045 in observation 247. Here I am using the trick shown here [here](https://forum.dynare.org/t/estimation-of-smets-and-wouters-2007-with-occbin/27102), on the mod file called [SW07\_SG.mod](https://forum.dynare.org/uploads/short-url/ylfy4BRobCc7NUC6AN2R2sXojrg.mod) to avoid stochastic singularity by setting the binding values of robs to NaN (see p. 87 in the Dynare manual). I also have consider a simpler constraint like:  
name ‘zlb’; bind robs \< r\_elb - 1e-6; relax robs \> r\_elb + 1e-6;

Any idea or suggestion would be really appreciated,  
Many thanks  
Best

[SW\_occbin.mod](https://forum.dynare.org/uploads/short-url/9dE8RTJKHJcp2sJsbO8jIK8oR47.mod) (10.3 KB)  
[usmodel\_data\_updated.mat](https://forum.dynare.org/uploads/short-url/5ql1DTltxLbBRIsDbARknVDkVA4.mat) (14.0 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:** [1 April 2025 12:57 UTC](https://forum.dynare.org/t/smets-wouters-model-with-occbin-with-u-s-updated-data/27346/2 "2025-04-01T12:57:44Z")

</div>

Sorry for the delay. Is the problem still current?

---

<div class="post-metadata">

**Author:** ![ddiaze](https://forum.dynare.org/letter_avatar_proxy/v4/letter/d/d26b3c/32.png) [@ddiaze](https://forum.dynare.org/u/ddiaze)\
**Post date:** [3 April 2025 20:10 UTC](https://forum.dynare.org/t/smets-wouters-model-with-occbin-with-u-s-updated-data/27346/3 "2025-04-03T20:10:02Z")

</div>

Hello Professor,  
Many thanks for your response. I have managed the following solution.

1. Estimate the SW07 model using data up to 2019, without occbin to get updated files of the mode and priors.
2. Use the above mode and prior data as input with the occbin implementation.

Please see the updated files. Doing this the model works, however I am concerned that it prints out 2 warnings.

1. Around period 177 the Kalman filter is not converging
2. Between periods 181 and 185 the occbin smoother is not converging as well.

Would this represent a problem? Is there any workaround this issue?  
Best

[SW\_updated\_occbin.mod](https://forum.dynare.org/uploads/short-url/CN5yK33JCS5L79rWTuKkZU9P5H.mod) (10.4 KB)  
[usmodel\_data\_updated.mat](https://forum.dynare.org/uploads/short-url/5ql1DTltxLbBRIsDbARknVDkVA4.mat) (14.0 KB)  
[usmodel\_mode.mat](https://forum.dynare.org/uploads/short-url/iowCB7YxPdhHuZ4Xj1P3uA5KQe0.mat) (8.0 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:** [4 April 2025 08:32 UTC](https://forum.dynare.org/t/smets-wouters-model-with-occbin-with-u-s-updated-data/27346/4 "2025-04-04T08:32:51Z")

</div>

To me that looks like output from

```auto
options_.debug=true; // see Dynare post on piecewise Kalman filter
options_.occbin.smoother.debug=1;

```

that is not critical.

---

<div class="post-metadata">

**Author:** ![ddiaze](https://forum.dynare.org/letter_avatar_proxy/v4/letter/d/d26b3c/32.png) [@ddiaze](https://forum.dynare.org/u/ddiaze)\
**Post date:** [6 May 2025 15:53 UTC](https://forum.dynare.org/t/smets-wouters-model-with-occbin-with-u-s-updated-data/27346/5 "2025-05-06T15:53:42Z")

</div>

Hello Professor Pfeifer,  
I am facing a problem when increasing the mh\_replic from 1000 (my test case) to 1,500,000.  
After completing the Metropolis-Hasting block (several days after) I am having the error:

unrecognized field name “linear\_smoother”. error in occbin.dsge\_smoother (line 140) etahat= oo\_.occbin.linear\_smoother.etahat; error in prior\_posterior\_statistics\_core (line 233) occbin.dsge\_smoother(deep,gend,y,data\_index,missing\_value,m\_,oo\_,opts\_local,bayestopt\_,estim\_params\_);

This error is not present with small mh\_replic numbers like 1000 but for 5000 it appers.  
I tested with the dynare 6.3 version but still the problem shows up.  
I would really appreciate any suggestion here to solve the issue  
Best

---

<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:** [7 May 2025 06:57 UTC](https://forum.dynare.org/t/smets-wouters-model-with-occbin-with-u-s-updated-data/27346/6 "2025-05-07T06:57:13Z")

</div>

Can you provide me with the files to replicate the issue, potentially via PM.
