Bug in infinite horizon codes after improvement?

Dear Robert,

I ran an infinite horizon model (see my repo GitHub - aledinola/PijoanMasTaxes) and the default options are good. Thanks for improving the code!
However, if I set vfoptions.lowmemory = 1;, I get the following error message:

Unrecognized function or variable 'ReturnFnParams'.

Error in ValueFnIter_Case1_Refine (line 43)
        ReturnMatrix_z=CreateReturnFnMatrix_Case1_Disc_Par2(ReturnFn,n_d, n_a, n_z_temp,d_grid, a_grid, zvals,ReturnFnParams,1); % the 1 at the end is to output for refine

Error in ValueFnIter_Case1 (line 622)
    [VKron,Policy]=ValueFnIter_Case1_Refine(V0,n_d,n_a,n_z,d_grid,a_grid,z_grid,pi_z,ReturnFn,ReturnFnParamsVec,DiscountFactorParamsVec,vfoptions);

Error in HeteroAgentStationaryEqm_Case1_subfn (line 8)
[~,Policy]=ValueFnIter_Case1(n_d,n_a,n_s,d_grid,a_grid,s_grid, pi_s, ReturnFn, Parameters, DiscountFactorParamNames,ReturnFnParamNames,vfoptions);

Error in HeteroAgentStationaryEqm_Case1>@(p)HeteroAgentStationaryEqm_Case1_subfn(p,n_d,n_a,n_z,l_p,pi_z,d_grid,a_grid,z_grid,ReturnFn,FnsToEvaluate,GeneralEqmEqns,Parameters,DiscountFactorParamNames,ReturnFnParamNames,FnsToEvaluateParamNames,GeneralEqmEqnParamNames,GEPriceParamNames,heteroagentoptions,simoptions,vfoptions) (line 197)
    GeneralEqmConditionsFnOpt=@(p) HeteroAgentStationaryEqm_Case1_subfn(p, n_d, n_a, n_z, l_p, pi_z, d_grid, a_grid, z_grid, ReturnFn, FnsToEvaluate, GeneralEqmEqns, Parameters, DiscountFactorParamNames, ReturnFnParamNames, FnsToEvaluateParamNames, GeneralEqmEqnParamNames, GEPriceParamNames, heteroagentoptions, simoptions, vfoptions)

Error in fminsearch (line 216)
fv(:,1) = funfcn(x,varargin{:});

Error in HeteroAgentStationaryEqm_Case1 (line 216)
    [p_eqm_vec,GeneralEqmConditions]=fminsearch(GeneralEqmConditionsFnOpt,p0,optimoptions);

The code does not have the variable ReturnFnParams which is a cell array of characters with the names of the parameters in the ReturnFn. It used to be an input set manually but now the toolkit should do it automatically, I think.

Unrelated to the bug: is the divide and conquer method implemented also for infinite horizon models?

1 Like

Fixed.

Was not actually recent, has been there all along just no-one tried vfoptions.lowmemory=1 (was just that it should have said ReturnFnParamsVec instead of ReturnFnParams).

1 Like

Divide-and-conquer is not implemented for infinite horizon (partly as I am not sure it would work that well)

1 Like

Great, thanks! Pijoan-Mas is fixed. I ran the Aiyagari example and I found the same (?) problem with lowmemory=1. My codes are available here: GitHub - aledinola/Aiyagari-with-taxes: Aiyagari model with progressive income taxation

I guess the difference is that my Aiyagari example does not have a d variable, contrary to Pijoan-Mas.

Calculating price corresponding to the stationary general eqm 

GeneralEqmConditionsFnOpt =

  function_handle with value:

    @(p)HeteroAgentStationaryEqm_Case1_subfn(p,n_d,n_a,n_z,l_p,pi_z,d_grid,a_grid,z_grid,ReturnFn,FnsToEvaluate,GeneralEqmEqns,Parameters,DiscountFactorParamNames,ReturnFnParamNames,FnsToEvaluateParamNames,GeneralEqmEqnParamNames,GEPriceParamNames,heteroagentoptions,simoptions,vfoptions)

Unrecognized function or variable 'l_z'.

Error in ValueFnIter_Case1_LowMem_NoD_Par2_raw (line 25)
        ReturnMatrix_z=CreateReturnFnMatrix_Case1_Disc_Par2(ReturnFn,0, n_a, ones(l_z,1),0, a_grid, zvals,ReturnFnParams);

Error in ValueFnIter_Case1 (line 569)
                [VKron,Policy]=ValueFnIter_Case1_LowMem_NoD_Par2_raw(V0, n_a, n_z, a_grid, z_gridvals, pi_z, DiscountFactorParamsVec, ReturnFn, ReturnFnParamsVec, vfoptions.howards, vfoptions.maxhowards, vfoptions.tolerance);

Error in HeteroAgentStationaryEqm_Case1_subfn (line 8)
[~,Policy]=ValueFnIter_Case1(n_d,n_a,n_s,d_grid,a_grid,s_grid, pi_s, ReturnFn, Parameters, DiscountFactorParamNames,ReturnFnParamNames,vfoptions);

Error in HeteroAgentStationaryEqm_Case1>@(p)HeteroAgentStationaryEqm_Case1_subfn(p,n_d,n_a,n_z,l_p,pi_z,d_grid,a_grid,z_grid,ReturnFn,FnsToEvaluate,GeneralEqmEqns,Parameters,DiscountFactorParamNames,ReturnFnParamNames,FnsToEvaluateParamNames,GeneralEqmEqnParamNames,GEPriceParamNames,heteroagentoptions,simoptions,vfoptions) (line 197)
    GeneralEqmConditionsFnOpt=@(p) HeteroAgentStationaryEqm_Case1_subfn(p, n_d, n_a, n_z, l_p, pi_z, d_grid, a_grid, z_grid, ReturnFn, FnsToEvaluate, GeneralEqmEqns, Parameters, DiscountFactorParamNames, ReturnFnParamNames, FnsToEvaluateParamNames, GeneralEqmEqnParamNames, GEPriceParamNames, heteroagentoptions, simoptions, vfoptions)

Error in fminsearch (line 216)
fv(:,1) = funfcn(x,varargin{:});

Error in HeteroAgentStationaryEqm_Case1 (line 216)
    [p_eqm_vec,GeneralEqmConditions]=fminsearch(GeneralEqmConditionsFnOpt,p0,optimoptions);

Fixed. Thanks for spotting.

1 Like