# Model with entrepreneurs

**URL:** <https://discourse.vfitoolkit.com/t/model-with-entrepreneurs/377>\
**Category:** Uncategorized\
**Created:** [April 27, 2025, 10:29pm UTC](https://discourse.vfitoolkit.com/t/model-with-entrepreneurs/377 "2025-04-27T22:29:39Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![aledinola](https://discourse.vfitoolkit.com/letter_avatar_proxy/v4/letter/a/3ec8ea/32.png) [@aledinola](https://discourse.vfitoolkit.com/u/aledinola)\
**Post date:** [April 27, 2025, 10:29pm UTC](https://discourse.vfitoolkit.com/t/model-with-entrepreneurs/377/1 "2025-04-27T22:29:39Z")

</div>

Hi Robert,

I’m running a code that I had written a few months ago (infinite horizon with entrepreneuers). The setup is very basic: the state space is (a,z1,z2,age), z1 and z2 are two Markov shocks and I use joint grids to avoid solving the model for all combinations of z1,z2 and age.

As far I rember the code was working back then, but now it returns with this error message when I call the toolkit function `EvalFnOnAgentDist_ValuesOnGrid_Case1`:

```auto
Not enough input arguments.

Error in PolicyInd2Val_Case1 (line 71)
if isfield(simoptions,'n_e')
           ^^^^^^^^^^
Error in EvalFnOnAgentDist_AllStats_Case1 (line 82)
    PolicyValues=PolicyInd2Val_Case1(PolicyIndexes,n_d,n_a,n_z,d_grid,a_grid);
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in solve_toolkit (line 192)
AllStats=EvalFnOnAgentDist_AllStats_Case1(StationaryDist,Policy,FnsToEvaluate,...
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

```

I’m surprised about the error since I am not using any “e” variable

These are the options that I use:

```auto
vfoptions = 

  struct with fields:

                        verbose: 1
                      tolerance: 1e-06
                     solnmethod: 'purediscretization_refinement'
               divideandconquer: 0
                       parallel: 2
                   returnmatrix: 2
                      lowmemory: 0
                        howards: 80
                     maxhowards: 500
                        maxiter: Inf
                 endogenousexit: 0
                       endotype: 0
                incrementaltype: 0
                experienceasset: 0
                    polindorval: 1
        policy_forceintegertype: 0
    piz_strictonrowsaddingtoone: 0
                     outputkron: 0
                       actualV0: 0

```

I’m also surprised that solnmethod: ‘purediscretization\_refinement’. Since I don’t have any `d` variable, refinement should not be used, right?

Thanks!

---

<div class="post-metadata">

**Author:** ![aledinola](https://discourse.vfitoolkit.com/letter_avatar_proxy/v4/letter/a/3ec8ea/32.png) [@aledinola](https://discourse.vfitoolkit.com/u/aledinola)\
**Post date:** [April 28, 2025, 10:12pm UTC](https://discourse.vfitoolkit.com/t/model-with-entrepreneurs/377/2 "2025-04-28T22:12:12Z")

</div>

Also the Aiyagari example in the repo “VFItoolkit-matlab-examples” returns with the same error message (so it’s not something specific to my code)

> <https://github.com/vfitoolkit/VFItoolkit-matlab-examples/blob/master/HeterogeneousAgentModels/Aiyagari1994.m>

If you run the script Aiyagari1994.m, it gives an error on line 142:

```auto
AllStats=EvalFnOnAgentDist_AllStats_Case1(StationaryDist, Policy, FnsToEvaluateIneq,Params, [],n_d, n_a, n_z, d_grid, a_grid,z_grid,simoptions);

```

The error message is this:

```auto
Not enough input arguments.

Error in PolicyInd2Val_Case1 (line 71)
if isfield(simoptions,'n_e')
           ^^^^^^^^^^
Error in EvalFnOnAgentDist_AllStats_Case1 (line 82)
    PolicyValues=PolicyInd2Val_Case1(PolicyIndexes,n_d,n_a,n_z,d_grid,a_grid);
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

```

---

<div class="post-metadata">

**Author:** ![robertdkirkby](https://discourse.vfitoolkit.com/user_avatar/discourse.vfitoolkit.com/robertdkirkby/32/287_2.png) [@robertdkirkby](https://discourse.vfitoolkit.com/u/robertdkirkby)\
**Post date:** [April 29, 2025, 4:35pm UTC](https://discourse.vfitoolkit.com/t/model-with-entrepreneurs/377/3 "2025-04-29T16:35:24Z")

</div>

Sorry. Fixed (was trivial internal thing). Thanks for letting me know.

---

<div class="post-metadata">

**Author:** ![aledinola](https://discourse.vfitoolkit.com/letter_avatar_proxy/v4/letter/a/3ec8ea/32.png) [@aledinola](https://discourse.vfitoolkit.com/u/aledinola)\
**Post date:** [April 29, 2025, 9:41pm UTC](https://discourse.vfitoolkit.com/t/model-with-entrepreneurs/377/4 "2025-04-29T21:41:33Z")

</div>

Thanks! There is still a very similar mistake in the next toolkit function that I call, `EvalFnOnAgentDist_ValuesOnGrid_Case1`

```auto
Not enough input arguments.

Error in PolicyInd2Val_Case1 (line 71)
if isfield(simoptions,'n_e')
           ^^^^^^^^^^
Error in EvalFnOnAgentDist_ValuesOnGrid_Case1 (line 74)
    PolicyValues=PolicyInd2Val_Case1(PolicyIndexes,n_d,n_a,n_z,d_grid,a_grid);
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in solve_toolkit (line 207)
ValuesOnGrid=EvalFnOnAgentDist_ValuesOnGrid_Case1(Policy,FnsToEvaluate,Params,[],n_d,n_a,n_z,d_grid,a_grid,z_grid,[],simoptions);
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```

---

<div class="post-metadata">

**Author:** ![aledinola](https://discourse.vfitoolkit.com/letter_avatar_proxy/v4/letter/a/3ec8ea/32.png) [@aledinola](https://discourse.vfitoolkit.com/u/aledinola)\
**Post date:** [April 29, 2025, 9:45pm UTC](https://discourse.vfitoolkit.com/t/model-with-entrepreneurs/377/5 "2025-04-29T21:45:06Z")

</div>

The mistake happens in line 71 of `PolicyInd2Val_Case1`

My way of fixing the mistake: commenting out from line 71 to line 94, but not sure if it is a good idea 😃

---

<div class="post-metadata">

**Author:** ![robertdkirkby](https://discourse.vfitoolkit.com/user_avatar/discourse.vfitoolkit.com/robertdkirkby/32/287_2.png) [@robertdkirkby](https://discourse.vfitoolkit.com/u/robertdkirkby)\
**Post date:** [April 29, 2025, 10:00pm UTC](https://discourse.vfitoolkit.com/t/model-with-entrepreneurs/377/6 "2025-04-29T22:00:18Z")

</div>

Fixed. (is about adding simoptions as input to PolicyInd2Val, as PolicyInd2Val didn’t use to need it but I added features to PolicyInd2Val and now it does need it).

---

<div class="post-metadata">

**Author:** ![aledinola](https://discourse.vfitoolkit.com/letter_avatar_proxy/v4/letter/a/3ec8ea/32.png) [@aledinola](https://discourse.vfitoolkit.com/u/aledinola)\
**Post date:** [April 29, 2025, 10:08pm UTC](https://discourse.vfitoolkit.com/t/model-with-entrepreneurs/377/7 "2025-04-29T22:08:15Z")

</div>

Thanks, now it’s ok. But there is another strange thing happening when I call the stationary distribution:

`StationaryDist=StationaryDist_Case1(Policy,n_d,n_a,n_z,pi_z,simoptions);`

It actually opens a parallel pool without really using it. Not a big problem, but opening a parallel pool the first time slows down the code (with finite horizon it does not happen)

---

<div class="post-metadata">

**Author:** ![robertdkirkby](https://discourse.vfitoolkit.com/user_avatar/discourse.vfitoolkit.com/robertdkirkby/32/287_2.png) [@robertdkirkby](https://discourse.vfitoolkit.com/u/robertdkirkby)\
**Post date:** [May 4, 2025, 9:59am UTC](https://discourse.vfitoolkit.com/t/model-with-entrepreneurs/377/8 "2025-05-04T09:59:06Z")

</div>

Think this is fixed now (no firing up parallel pool): [General equilibrium conditions, weights - #8 by robertdkirkby](https://discourse.vfitoolkit.com/t/general-equilibrium-conditions-weights/378/8)
