# Problem in estimating the Preferred-Habitat term structure model

**URL:** https://forum.dynare.org/t/problem-in-estimating-the-preferred-habitat-term-structure-model/22451
**Category:** Estimation
**Created:** [16 May 2023 06:48 UTC](https://forum.dynare.org/t/problem-in-estimating-the-preferred-habitat-term-structure-model/22451 "2023-05-16T06:48:14Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![anshul](https://forum.dynare.org/letter_avatar_proxy/v4/letter/a/90db22/32.png) [@anshul](https://forum.dynare.org/u/anshul)
#### Post date: [16 May 2023 06:48 UTC](https://forum.dynare.org/t/problem-in-estimating-the-preferred-habitat-term-structure-model/22451/1 "2023-05-16T06:48:14Z")

</div>

Dear all,

I am new to DSGE estimation. I am trying to replicate “Preferred habitat and the term structure of interest rates in DSGE models” paper by Celso J. Costa. Code runs smoothly up to identification part but it fails for the estimation.  
I attach both mod file and the data file. Kindly suggest me how to proceed with the files for estimation.  
[term\_struc.zip](https://forum.dynare.org/uploads/short-url/lY5wF6M5Y7HxxqCggpYLeIJYEn9.zip) (25.7 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: [16 May 2023 13:31 UTC](https://forum.dynare.org/t/problem-in-estimating-the-preferred-habitat-term-structure-model/22451/2 "2023-05-16T13:31:23Z")

</div>

There is a myriad of issues. I fixed some of them in the attached file. Now the issue is that there are two variables with the same name in the Excel file.  
[term\_struc\_1.mod](https://forum.dynare.org/uploads/short-url/jNCS0DxG2vdyrLnPA1aqx3FnUT8.mod) (8.6 KB)  
[term\_struc\_data1.xlsx](https://forum.dynare.org/uploads/short-url/pIdy48CIGcQFW2htM4K7BH5fKWo.xlsx) (24.1 KB)

---

<div class="post-metadata">

### Author: ![anshul](https://forum.dynare.org/letter_avatar_proxy/v4/letter/a/90db22/32.png) [@anshul](https://forum.dynare.org/u/anshul)
#### Post date: [16 May 2023 13:47 UTC](https://forum.dynare.org/t/problem-in-estimating-the-preferred-habitat-term-structure-model/22451/3 "2023-05-16T13:47:22Z")

</div>

Dear Prof, thanks a lot for your reply and fixing the errors.  
Yes, I also noticed it later. The second variable named I is actually inflation (PI). I have changed it in the attached data file.  
Kindly see if it can be fixed now.

---

<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 May 2023 14:07 UTC](https://forum.dynare.org/t/problem-in-estimating-the-preferred-habitat-term-structure-model/22451/4 "2023-05-16T14:07:08Z")

</div>

There is no file attached. Also, the names of the variables in the data file do not match the declared `varobs`.

---

<div class="post-metadata">

### Author: ![anshul](https://forum.dynare.org/letter_avatar_proxy/v4/letter/a/90db22/32.png) [@anshul](https://forum.dynare.org/u/anshul)
#### Post date: [16 May 2023 14:38 UTC](https://forum.dynare.org/t/problem-in-estimating-the-preferred-habitat-term-structure-model/22451/5 "2023-05-16T14:38:07Z")

</div>

Apologies for previous mistake!  
This is the updated datafile.  
Many thanks for your patience.  
[term\_struc\_data1.xlsx](https://forum.dynare.org/uploads/short-url/gvlLzfIcT8bhgVjClf8Pt0YzUD9.xlsx) (24.4 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: [16 May 2023 14:48 UTC](https://forum.dynare.org/t/problem-in-estimating-the-preferred-habitat-term-structure-model/22451/6 "2023-05-16T14:48:07Z")

</div>

You cannot encode missing values with a minus sign. Use  
[term\_struc\_data1.xlsx](https://forum.dynare.org/uploads/short-url/gmVEl4HjjBLCM8XGiorO4UYxD9K.xlsx) (24.4 KB)  
Then see

> [@DSGE modelling: The forecast error variance in the multivariate Kalman filter became singular](https://forum.dynare.org/t/dsge-modelling-the-forecast-error-variance-in-the-multivariate-kalman-filter-became-singular/21749/4):
>
> You have standard stochastic singularity. Try dropping one variable at a time. Search the forum for details.

---

<div class="post-metadata">

### Author: ![anshul](https://forum.dynare.org/letter_avatar_proxy/v4/letter/a/90db22/32.png) [@anshul](https://forum.dynare.org/u/anshul)
#### Post date: [16 May 2023 15:05 UTC](https://forum.dynare.org/t/problem-in-estimating-the-preferred-habitat-term-structure-model/22451/7 "2023-05-16T15:05:51Z")

</div>

Thank you Prof.
