# Iterative OLS for PAC equation

**URL:** <https://forum.dynare.org/t/iterative-ols-for-pac-equation/21379>\
**Category:** Semistructural Modeling\
**Created:** [9 November 2022 05:49 UTC](https://forum.dynare.org/t/iterative-ols-for-pac-equation/21379 "2022-11-09T05:49:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sikang](https://forum.dynare.org/letter_avatar_proxy/v4/letter/s/b5a626/32.png) [@sikang](https://forum.dynare.org/u/sikang)\
**Post date:** [9 November 2022 05:49 UTC](https://forum.dynare.org/t/iterative-ols-for-pac-equation/21379/1 "2022-11-09T05:49:48Z")

</div>

Hi, I am constructing a FRB/US type semi-structure model and using DYNARE to estimate a PAC equation. [PAC\_EST.mod](https://forum.dynare.org/uploads/short-url/lTm0PNhRaZHiXT9AvsA7Teb8sX3.mod) (1.9 KB)

However, I found that the iterative OLS method is only applicable with trend\_component\_model, but it makes a following error with var\_model.  
Strange thing is that it works perfectly well with nls method.

* * *

Error using strfind  
Not enough input arguments.

Error in pac.estimate.iterative\_ols (line 130)  
if isempty(strfind(match.var, ‘(-1)’))

Error in PAC\_EST.driver (line 366)  
pac.estimate.iterative\_ols(‘pac\_equation’, eparams, edata, dates(‘2005Q1’):dates(‘2005Q1’)+4000);

Error in dynare (line 281)  
evalin(‘base’,[fname ‘.driver’]);

* * *

Does Dynare provide iterative\_ols method only for the trend\_component model case?  
Of course, I can work with the non-linear least squre method, still this issue lingers on my mind.  
Thank you in advance.

Best,  
Seokil

---

<div class="post-metadata">

**Author:** ![stepan-a](https://forum.dynare.org/user_avatar/forum.dynare.org/stepan-a/32/6652_2.png) [@stepan-a](https://forum.dynare.org/u/stepan-a)\
**Post date:** [24 November 2022 15:49 UTC](https://forum.dynare.org/t/iterative-ols-for-pac-equation/21379/2 "2022-11-24T15:49:33Z")

</div>

Dear Seokil,

This is a bug, thanks for reporting it. I simply forgot to update the iterative OLS routine when I added the possibility to have a constant in the auxiliary model. I have pushed a patch fixing the issue, it will be available in the next minor release. You can have a look at the patch here:

> **[Fix pac.estimate.iterate\_ols. (3aeb1ff7) · Commits · Dynare / dynare · GitLab](https://git.dynare.org/Dynare/dynare/-/commit/3aeb1ff7e38e93c0f248b77567189e5d4cfbef0d)**
>
> Was crashing if the auxiliary model contains a constant. See https://forum.dynare.org/t/iterative-ols-for-pac-equation/21379.

As a general rule, I discourage the use of iterative OLS which is less robust, and doesn’t have (to my knowledge) clear properties about bias and efficiency. Also by construction it will deliver a greater sum of squared residual.

Best,  
Stéphane.

---

<div class="post-metadata">

**Author:** ![sikang](https://forum.dynare.org/letter_avatar_proxy/v4/letter/s/b5a626/32.png) [@sikang](https://forum.dynare.org/u/sikang)\
**Post date:** [28 November 2022 06:45 UTC](https://forum.dynare.org/t/iterative-ols-for-pac-equation/21379/3 "2022-11-28T06:45:06Z")

</div>

Dear Stéphane,

Thank you very much for the update.  
I have one more question though.  
Where can I find the estimates of the pac\_expectation, the infinite sum part?  
I presume that Dynare would compute the stationary and nonstationary part of the infinite sum, but I could not find any of them.

Best,  
Seokil

---

<div class="post-metadata">

**Author:** ![stepan-a](https://forum.dynare.org/user_avatar/forum.dynare.org/stepan-a/32/6652_2.png) [@stepan-a](https://forum.dynare.org/u/stepan-a)\
**Post date:** [28 November 2022 07:09 UTC](https://forum.dynare.org/t/iterative-ols-for-pac-equation/21379/4 "2022-11-28T07:09:40Z")

</div>

Dear Seokil,

I have the impression that we do not save it. Dynare creates an auxiliary variable for the PAC expectation term (named `pac_expectation_pacman`, replace `pacman` by the name of your PAC expectation model as declared in your `.mod` file). You can see the equation in the JSON generated file. You just have to evaluate the RHS of this equation.

Best,  
Stéphane.

---

<div class="post-metadata">

**Author:** ![sikang](https://forum.dynare.org/letter_avatar_proxy/v4/letter/s/b5a626/32.png) [@sikang](https://forum.dynare.org/u/sikang)\
**Post date:** [12 December 2022 06:46 UTC](https://forum.dynare.org/t/iterative-ols-for-pac-equation/21379/5 "2022-12-12T06:46:58Z")

</div>

Thank you again for the comment.  
Nevertheless, would there be any other ways to recover the h\_0, h\_1 vector for the expectation term?
