# Perfect Foresight in the OLG model with endogenous growth

**URL:** <https://forum.dynare.org/t/perfect-foresight-in-the-olg-model-with-endogenous-growth/27187>\
**Category:** Perfect foresight simulations\
**Created:** [17 February 2025 15:34 UTC](https://forum.dynare.org/t/perfect-foresight-in-the-olg-model-with-endogenous-growth/27187 "2025-02-17T15:34:21Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![olg](https://forum.dynare.org/letter_avatar_proxy/v4/letter/o/cab0a1/32.png) [@olg](https://forum.dynare.org/u/olg)\
**Post date:** [17 February 2025 15:34 UTC](https://forum.dynare.org/t/perfect-foresight-in-the-olg-model-with-endogenous-growth/27187/1 "2025-02-17T15:34:21Z")

</div>

Dear all,

I’m trying to solve the perfect foresight problem, but it fails. The following error appears:

Warning: Matrix is singular to working precision.  
Failed to solve perfect foresight model.

The crucial thing is that the model does not have a steady state, since there is endogenous growth (due to the transmission of human capital). How can I solve the model in this case?

Thank you for your help!

[OLG\_problem.mod](https://forum.dynare.org/uploads/short-url/7HUgWIvMRKzIUfluiO1eW0RjTvM.mod) (3.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:** [17 February 2025 19:18 UTC](https://forum.dynare.org/t/perfect-foresight-in-the-olg-model-with-endogenous-growth/27187/2 "2025-02-17T19:18:21Z")

</div>

`q=1` creates an edge case. That causes the issue. In any case, is the problem well-defined? What is the terminal condition of your model?

---

<div class="post-metadata">

**Author:** ![olg](https://forum.dynare.org/letter_avatar_proxy/v4/letter/o/cab0a1/32.png) [@olg](https://forum.dynare.org/u/olg)\
**Post date:** [17 February 2025 20:25 UTC](https://forum.dynare.org/t/perfect-foresight-in-the-olg-model-with-endogenous-growth/27187/3 "2025-02-17T20:25:48Z")

</div>

Basically, I want to implement shocks to the size of age groups. So, I added this block to the code. I also added terminal conditions, but, anyway, it doesn’t work out. As for q, I tried to change its values, but it did not help as well.  
[OLG\_problem.mod](https://forum.dynare.org/uploads/short-url/vGtl0R6Dbxfovb6ziX8cTNSZGUv.mod) (6.2 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:** [17 February 2025 21:02 UTC](https://forum.dynare.org/t/perfect-foresight-in-the-olg-model-with-endogenous-growth/27187/4 "2025-02-17T21:02:18Z")

</div>

You should start with a working version and then start modifying. With the current version, it’s impossible to tell where exactly the problem derives from.

---

<div class="post-metadata">

**Author:** ![olg](https://forum.dynare.org/letter_avatar_proxy/v4/letter/o/cab0a1/32.png) [@olg](https://forum.dynare.org/u/olg)\
**Post date:** [20 February 2025 08:03 UTC](https://forum.dynare.org/t/perfect-foresight-in-the-olg-model-with-endogenous-growth/27187/5 "2025-02-20T08:03:55Z")

</div>

I’ve elaborated the code. Now it solves for the steady state and the model itself. However, in oo\_.endo\_simul the variables look like they are in the steady state during all periods, despite the fact that I also use shocks during all periods. What could be the problem?  
[OLG\_problem.mod](https://forum.dynare.org/uploads/short-url/yGaNuaSHExHaPN4eZu0XqSVUIaD.mod) (6.3 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:** [20 February 2025 09:01 UTC](https://forum.dynare.org/t/perfect-foresight-in-the-olg-model-with-endogenous-growth/27187/6 "2025-02-20T09:01:47Z")

</div>

Your steady state is: everything is 0. That makes no sense.

---

<div class="post-metadata">

**Author:** ![olg](https://forum.dynare.org/letter_avatar_proxy/v4/letter/o/cab0a1/32.png) [@olg](https://forum.dynare.org/u/olg)\
**Post date:** [20 February 2025 10:09 UTC](https://forum.dynare.org/t/perfect-foresight-in-the-olg-model-with-endogenous-growth/27187/7 "2025-02-20T10:09:32Z")

</div>

I see, thank you. It’s strange that the model does not work when human capital is endogenous. I’ve tried to make the human capital accumulation process be exogenous. In this case, Dynare solves the model perfectly well. As far as I understand, the main challenge is endogenous growth that comes from human capital accumulation process with social transmission. Is it possible to handle such a problem in Dynare?

I’ve read in some of the topics here that a unique steady state is not necessary in the perfect foresight setting (since BGP is a sequence of steady states). It means that I should simply define initial and terminal conditions for the model to be solved. But it fails to find a solution anyway.

May be I should detrend variables?

---

<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:** [20 February 2025 10:28 UTC](https://forum.dynare.org/t/perfect-foresight-in-the-olg-model-with-endogenous-growth/27187/8 "2025-02-20T10:28:34Z")

</div>

This is a chicken and egg problem. A properly set up problem like that should be easily solvable in Dynare. But your current code suggests that the problem is not yet properly set up so that no proper BGP exists.
