# Weird/Divergent Value Function in Dynare

**URL:** <https://forum.dynare.org/t/weird-divergent-value-function-in-dynare/13467>\
**Category:** Stochastic simulations\
**Created:** [24 March 2019 23:53 UTC](https://forum.dynare.org/t/weird-divergent-value-function-in-dynare/13467 "2019-03-24T23:53:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jona](https://forum.dynare.org/letter_avatar_proxy/v4/letter/j/3d9bf3/32.png) [@Jona](https://forum.dynare.org/u/Jona)\
**Post date:** [24 March 2019 23:53 UTC](https://forum.dynare.org/t/weird-divergent-value-function-in-dynare/13467/1 "2019-03-24T23:53:44Z")

</div>

Hello, I’m trying to calculate the value function in Dynare. But I get a divergent value function: value function for fixed consumption path (with \<1 discount factor) is divergent. I’m trying to pin down the source of the problem. I find that I can replicate the problem in a simple PIH model. After a permanent shock to income, the consumption would just to a new level and stay there. Therefore the value function is expected and discounted sum of (CRRA) utility from the consumption, which should give a fixed number. But Dynare gives me a divergent IRF for the value function.

I don’t know if it’s because that I can’t use the bellman equation to calculate value function in Dynare or it’s something else like Jensen’s inequality as Dynare gives averaged IRF. Any comment is very much appreciated. Thanks.

[simulationPIH.mod](https://forum.dynare.org/uploads/default/original/2X/5/5d0c65982b01c75d8d92dd36cc8624e0ac589a2b.mod) (698 Bytes)

---

<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:** [27 March 2019 19:34 UTC](https://forum.dynare.org/t/weird-divergent-value-function-in-dynare/13467/2 "2019-03-27T19:34:01Z")

</div>

You are currently using a second-order approximation, which relies on GIRFs that are simulation based. Set

```auto
stoch_simul(irf=100,order=1);

```

and the problem will disappear.

---

<div class="post-metadata">

**Author:** ![Jona](https://forum.dynare.org/letter_avatar_proxy/v4/letter/j/3d9bf3/32.png) [@Jona](https://forum.dynare.org/u/Jona)\
**Post date:** [28 March 2019 15:47 UTC](https://forum.dynare.org/t/weird-divergent-value-function-in-dynare/13467/3 "2019-03-28T15:47:04Z")

</div>

That solved my problem. Thanks, jpfeifer.
