Model with entrepreneurs

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:

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:

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!

1 Like

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)

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

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:

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);
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 Likes

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

2 Likes

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

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);
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1 Like

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 :smiley:

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).

1 Like

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)

Think this is fixed now (no firing up parallel pool): General equilibrium conditions, weights - #8 by robertdkirkby

1 Like