# Welfare and Pruning

**URL:** <https://forum.dynare.org/t/welfare-and-pruning/11470>\
**Category:** Stochastic simulations\
**Created:** [14 March 2018 15:42 UTC](https://forum.dynare.org/t/welfare-and-pruning/11470 "2018-03-14T15:42:51Z")\
**Posts on this page:** 11\
**Page:** 2

<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:** [15 November 2024 09:25 UTC](https://forum.dynare.org/t/welfare-and-pruning/11470/21 "2024-11-15T09:25:46Z")

</div>

The following should work:  
[wrapper\_function.m](https://forum.dynare.org/uploads/short-url/vxdlxwcC8ZJWV0kJeUIdiktLyno.m) (1.3 KB)  
[Loop\_main.m](https://forum.dynare.org/uploads/short-url/3b9tfW4xYawvtnXtGQRrQMxDpiG.m) (1.2 KB)  
[allcomb.m](https://forum.dynare.org/uploads/short-url/A88KvQ996YV210avRpZWyXCUQfD.m) (4.2 KB)  
[Loop\_dynare.mod](https://forum.dynare.org/uploads/short-url/1TWNRpFiLJMBV30CkevWuDSFnCF.mod) (6.5 KB)  
[get\_consumption\_equivalent\_conditional\_welfare.m](https://forum.dynare.org/uploads/short-url/fwPvVaYkIyzMxlt0p3PapArsU5y.m) (2.3 KB)

---

<div class="post-metadata">

**Author:** ![jojokre](https://forum.dynare.org/letter_avatar_proxy/v4/letter/j/d2c977/32.png) [@jojokre](https://forum.dynare.org/u/jojokre)\
**Post date:** [20 November 2024 15:13 UTC](https://forum.dynare.org/t/welfare-and-pruning/11470/22 "2024-11-20T15:13:20Z")

</div>

Yes! Thank you very much!

---

<div class="post-metadata">

**Author:** ![jojokre](https://forum.dynare.org/letter_avatar_proxy/v4/letter/j/d2c977/32.png) [@jojokre](https://forum.dynare.org/u/jojokre)\
**Post date:** [3 April 2025 13:29 UTC](https://forum.dynare.org/t/welfare-and-pruning/11470/23 "2025-04-03T13:29:33Z")

</div>

Hi Johannes,

I recognized that the csolve for finding the consumption equivalent is not converging unless I use “initval” instead of “steady\_state\_model”. This is for my model as well as for your example code posted above. I added a simpler version of it, where I took out the wrapper function and just gave parameter values.

Any idea why this could be the case?  
[without\_wrapper.zip](https://forum.dynare.org/uploads/short-url/4GMMDyxHiQGXgNxMH1cC6TdOv2y.zip) (6.2 KB)

Thanks!

---

<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 06:54 UTC](https://forum.dynare.org/t/welfare-and-pruning/11470/24 "2025-04-04T06:54:30Z")

</div>

You need to fix your steady state file. If you set

```auto
lambda_utility=0.01;

```

you will get an error message.

---

<div class="post-metadata">

**Author:** ![jojokre](https://forum.dynare.org/letter_avatar_proxy/v4/letter/j/d2c977/32.png) [@jojokre](https://forum.dynare.org/u/jojokre)\
**Post date:** [4 April 2025 08:27 UTC](https://forum.dynare.org/t/welfare-and-pruning/11470/25 "2025-04-04T08:27:34Z")

</div>

Sorry, I don’t understand this. In the mod files lambda\_utility is set to 0.

What I’m saying is that if I run

dynare Loop\_dynare\_new.mod %in this .mod file the steady state is specificied using steady\_state\_model;

lambda\_conditional=csolve(‘get\_consumption\_equivalent\_conditional\_welfare’,0,,1e-8,1000,M\_, options\_, oo\_);

→ The csolve stops after 1000 iterations with still a large outvalue.

If I run the following instead

dynare Loop\_dynare\_new\_v1.mod %in this .mod file the steady state is specificied using initval;

lambda\_conditional=csolve(‘get\_consumption\_equivalent\_conditional\_welfare’,0,,1e-8,1000,M\_, options\_, oo\_);

→ The csolve converges quickly.

---

<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:28 UTC](https://forum.dynare.org/t/welfare-and-pruning/11470/26 "2025-04-04T08:28:50Z")

</div>

The mod file needs to work for every value of `lambda_utility` between 0 and 1. Your `steady_state_model`-block only works for `lambda_utility=0`.

---

<div class="post-metadata">

**Author:** ![jojokre](https://forum.dynare.org/letter_avatar_proxy/v4/letter/j/d2c977/32.png) [@jojokre](https://forum.dynare.org/u/jojokre)\
**Post date:** [4 April 2025 09:12 UTC](https://forum.dynare.org/t/welfare-and-pruning/11470/27 "2025-04-04T09:12:25Z")

</div>

Ok, so I guess using initval; gives the steady state block this flexibility? So, is it okay to use initval; instead? How else could I allow for every value of lambda\_utility between 0 and 1?

The .mod file with the steady\_state\_model-block with lambda\_utility=0 is exactly the one you uploaded in November 2024.

Since I have a very large model, I changed the procedure a bit: I run the parfor loop first, just storing Recursive\_Welfare. Then, in a second step, I do the csolve for the consumption equivalent only for the parameter combination with the highest Recursive\_Welfare. This speeds up things considerably with my code.

---

<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 April 2025 07:32 UTC](https://forum.dynare.org/t/welfare-and-pruning/11470/28 "2025-04-07T07:32:19Z")

</div>

Yes, usually using initval should be fine, but slower.  
Regarding fixing the steady state file, you set

```auto
Recursive_natural_welfare_equivalent = Welf_SS;

```

but that is only true for `lambda_utility`.

---

<div class="post-metadata">

**Author:** ![jojokre](https://forum.dynare.org/letter_avatar_proxy/v4/letter/j/d2c977/32.png) [@jojokre](https://forum.dynare.org/u/jojokre)\
**Post date:** [7 April 2025 09:00 UTC](https://forum.dynare.org/t/welfare-and-pruning/11470/29 "2025-04-07T09:00:08Z")

</div>

Thank you for your reply! Okay, so, I will just run my files with initval. It takes a while, but they converge at some point.

Please note that the

```auto
Recursive_natural_welfare_equivalent = Welf_SS;

```

is also from the files you uploaded in November. It does not converge on my computer. I am wondering whether I overlooked anything.

---

<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 April 2025 09:06 UTC](https://forum.dynare.org/t/welfare-and-pruning/11470/30 "2025-04-07T09:06:41Z")

</div>

That is clearly a mistake. A correct file would be  
[Loop\_dynare\_new.mod](https://forum.dynare.org/uploads/short-url/6utohMR5xpf4DvTtNKcCwCAHxB4.mod) (6.5 KB)

---

<div class="post-metadata">

**Author:** ![jojokre](https://forum.dynare.org/letter_avatar_proxy/v4/letter/j/d2c977/32.png) [@jojokre](https://forum.dynare.org/u/jojokre)\
**Post date:** [8 April 2025 12:23 UTC](https://forum.dynare.org/t/welfare-and-pruning/11470/31 "2025-04-08T12:23:32Z")

</div>

Thank you for clarification!

[Previous page](https://forum.dynare.org/t/welfare-and-pruning/11470.md?page=1)
