HeteroAgentStationaryEqm_Case1 with maxiter=0

I think I found a bug in HeteroAgentStationaryEqm_Case1.

I set heteroagentoptions.maxiter=0 to just evaluate the GE conditions (this should also be useful to solve the model for fixed GE prices) but I get this error:

Unrecognized function or variable 'p_eqm_vec_untranformed'.

Error in HeteroAgentStationaryEqm_Case1 (line 511)
    GeneralEqmConditions=GeneralEqmConditionsFnOpt(p_eqm_vec_untranformed);
                                                   ^^^^^^^^^^^^^^^^^^^^^^

As a temporary fix to this problem, I defined a flag called do_GE which is set equal to 0 if I want to skip finding the general equilibrium. Here is my code:

if do_GE==1
    %% Compute GE
    [p_eqm,~,~]=HeteroAgentStationaryEqm_Case1(n_d, n_a, n_z, 0, pi_z, d_grid, a_grid, z_grid, ReturnFn, FnsToEvaluate, GeneralEqmEqns, Params, DiscountFactorParamNames, [], [], [], GEPriceParamNames,heteroagentoptions, simoptions, vfoptions);

    %% Compute eqm objects
    Params.r=p_eqm.r;
    Params.w=p_eqm.w;
    [~,Policy]=ValueFnIter_Case1(n_d,n_a,n_z,d_grid,a_grid,z_grid,pi_z,ReturnFn,Params,DiscountFactorParamNames,[],vfoptions);
    StationaryDist=StationaryDist_Case1(Policy,n_d,n_a,n_z,pi_z,simoptions);
    AggVars=EvalFnOnAgentDist_AggVars_Case1(StationaryDist, Policy, FnsToEvaluate, Params, [], n_d, n_a, n_z, d_grid, a_grid, z_grid, [], simoptions);
    ValuesOnGrid=EvalFnOnAgentDist_ValuesOnGrid_Case1(Policy, FnsToEvaluate, Params, [], n_d, n_a, n_z, d_grid, a_grid, z_grid, [], simoptions);
else
    [~,Policy]=ValueFnIter_Case1(n_d,n_a,n_z,d_grid,a_grid,z_grid,pi_z,ReturnFn,Params,DiscountFactorParamNames,ReturnFnParamNames,vfoptions);
    %[~,Policy]=ValueFnIter_Case1_fast(n_d,n_a,n_z,d_grid,a_grid,z_grid,pi_z,ReturnFn,Params,DiscountFactorParamNames,[],vfoptions);
    StationaryDist=StationaryDist_Case1(Policy,n_d,n_a,n_z,pi_z,simoptions);
    AggVars=EvalFnOnAgentDist_AggVars_Case1(StationaryDist, Policy, FnsToEvaluate, Params, [], n_d, n_a, n_z, d_grid, a_grid, z_grid, [], simoptions);
    ValuesOnGrid=EvalFnOnAgentDist_ValuesOnGrid_Case1(Policy, FnsToEvaluate, Params, [], n_d, n_a, n_z, d_grid, a_grid, z_grid, [], simoptions);
end
1 Like

I broke it when implementing constraints on the general eqm price params. Fixed now.
(Very minor. I had renamed something when implementing the constraints/restrictions, but hadn’t put the renaming into the maxiter=0 case.)

1 Like