Bug in WorkshopOLGTPath4

There are bugs in WorkshopOLGTPath4.

Bug 1 (In Line 72): The addition of ‘sj’ to DiscountFactorParamNames is missing.

Bug 2 (In line 100): The ‘mewj’ should be calculated based on ‘sj’. When revising the corresponding scripts, I made the following changes:

Params.mewj = ones(1,N_j)/N_j;
for jj = 2:length(Params.mewj)
    Params.mewj(jj) = Params.sj(jj-1)*Params.mewj(jj-1);
end
Params.mewj = Params.mewj./sum(Params.mewj);

However, the bequests condition no longer converges to a satisfactory result following these revisions.

Current GE prices: 
	r:   0.0287 
	w:   1.5154 
	G:   0.0643 
	Beq:   0.0303 
Current aggregate variables: 
	L:   0.4246 
	K:   4.6528 
	taxrevenue:   0.0643 
	Beqleft:   0.0158 
	Beqreceived:   0.0176 
Current GeneralEqmEqns: 
	capitalmarket: 0.000919 
	labormarket: 0.000064 
	govbudgetbalance: 0.000076 
	bequests: -0.001788 
Elapsed time is 611.383478 seconds.

GEcondns_init = 

  struct with fields:

       capitalmarket: 9.1949e-04
         labormarket: 6.4371e-05
    govbudgetbalance: 7.6062e-05
            bequests: -0.0018

After revising ReturnFn_OLGTPath4 to distribute accidental bequests evenly across all agents (adding ‘beq’ to retired agents’ budgets), the solution improves significantly. Given that both approaches simply redistribute bequests to survivors, why is there such a substantial difference in result accuracy? It confused me. The results from my revised scripts are below:

Current GE prices: 
	r:   0.0282 
	w:   1.5088 
	G:   0.0645 
	Beq:   0.0263 
Current aggregate variables: 
	L:   0.4276 
	K:   4.6311 
	taxrevenue:   0.0645 
	Beqleft:   0.0156 
	Beqreceived:   0.0153 
Current GeneralEqmEqns: 
	capitalmarket: -0.000205 
	labormarket: -0.000018 
	govbudgetbalance: -0.000014 
	bequests: 0.000334 
Elapsed time is 637.750974 seconds.

GEcondns_init = 

  struct with fields:

       capitalmarket: -2.0544e-04
         labormarket: -1.7555e-05
    govbudgetbalance: -1.4226e-05
            bequests: 3.3424e-04

Bug 3 (Line 246): The argument GeneralEqmEqns in the function TransitionPath_Case1_Fhorz should be GeneralEqmEqns_Transition. However, when I passed GeneralEqmEqns_Transition to the function, the script returned error messages. It indicates that Bequest_tminus1 is undefined. I am uncertain about the proper way to define lagged or lead variables/parameters in the toolkit.

Unrecognized function or variable 'Beqleft_tminus1'.

Error in OLGTPath4>@(Beqleft,Beqreceived)Beqleft_tminus1-Beqreceived (line
205)
GeneralEqmEqns_Transition.bequests = @(Beqleft,Beqreceived)
Beqleft_tminus1-Beqreceived; % Note: bequests are left in t-1 and received
in t (not declare Beqleft_tminus1?)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in GeneralEqmConditions_Case1_v3 (line 11)
GeneralEqmConditionsValue=GeneralEqmEqnsCell(GeneralEqmEqnParamsCell{:});
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in updatePricePathNew_TPath_tt (line 6)
    p_i(gg)=real(GeneralEqmConditions_Case1_v3(GeneralEqmEqnsCell{gg},
    GeneralEqmEqnParamNames(gg).Names, Parameters));
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in TransitionPath_FHorz_shooting_fastOLG (line 178)
        [PricePathNew_tt,GEcondnPath_tt]=updatePricePathNew_TPath_tt(Parameters,GeneralEqmEqnsCell,GeneralEqmEqnParamNames,PricePathOld(tt,:),transpathoptions);
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in TransitionPath_Case1_FHorz (line 740)
                    [PricePath,GEcondnPath]=TransitionPath_FHorz_shooting_fastOLG(PricePath0,
                    PricePathNames, PricePathSizeVec, l_p, ParamPath,
                    ParamPathNames, ParamPathSizeVec, T, V_final,
                    AgentDist_initial, jequalOneDist, n_d, n_a, n_z, N_j,
                    N_d,N_a,N_z, l_d,l_aprime,l_a,l_z,
                    d_gridvals,aprime_gridvals,a_gridvals,d_grid,a_grid,z_gridvals_J,ze_gridvals_J_fastOLG,
                    pi_z_J,pi_z_J_sim, ReturnFn, FnsToEvaluateCell,
                    AggVarNames, FnsToEvaluateParamNames, GEeqnNames,
                    GeneralEqmEqnsCell, GeneralEqmEqnParamNames, Parameters,
                    DiscountFactorParamNames, AgeWeights_T,
                    ReturnFnParamNames,
                    N_probs,II1orII,II2,exceptlastj,exceptfirstj,justfirstj,
                    use_tminus1price, use_tminus1params, use_tplus1price,
                    use_tminus1AggVars, tminus1priceNames,
                    tminus1paramNames, tplus1priceNames,
                    tminus1AggVarsNames, vfoptions, simoptions,
                    transpathoptions);
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in OLGTPath4 (line 232)
[PricePath, GECondnsPath] =
TransitionPath_Case1_FHorz(PricePath0,ParamPath,T,V_final,AgentDist_init,jequaloneDist,n_d,n_a,n_z,N_j,d_grid,a_grid,z_grid,pi_z,ReturnFn,FnsToEvaluate,GeneralEqmEqns_Transition,Params,DiscountFactorParamNames,AgeWeightParamNames,transpathoptions,simoptions,vfoptions);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1 Like