Good evening Robert,
When running the replciation program of RestucciaUrrutia2004, in the calculation module for AggVars, it reports
Unrecognized function or variable ‘ValuesOnSSGrid_Case2’.
Error in EvalFnOnAgentDist_AggVars_FHorz_Case2_AgeDepGrids (line 48)
Values=reshape(ValuesOnSSGrid_Case2(FnsToEvaluateFn{i}, FnToEvaluateParamsVec,PolicyValuesPermute,n_d,n_a,n_z,a_grid,z_grid,2),[N_a*N_z,1]);
Error in EvalFnOnAgentDist_AggVars_FHorz_Case2 (line 9)
AggVars=EvalFnOnAgentDist_AggVars_FHorz_Case2_AgeDepGrids(StationaryDist, PolicyIndexes, FnsToEvaluateFn, Parameters,FnsToEvaluateParamNames, n_d, n_a, n_z, N_j, d_grid, a_grid, z_grid, options, AgeDependentGridParamNames);
Error in RestucciaUrrutia2004 (line 290)
AggVars=EvalFnOnAgentDist_AggVars_FHorz_Case2(StationaryDist, Policy, FnsToEvaluate, Params, FnsToEvaluateParamNames, n_d, n_a, n_z,N_j, d_gridfn, a_gridfn, z_gridfn, simoptions, AgeDependentGridParamNames);
I doublecheck that there is no a variable ValuesOnSSGrid_Case2 generated internally. Since the problem persists after I test it using both the lastest version of the toolkit and the version that you released with this replication file, I guess there may be a function of this name missing in the toolkit.
Another question related to this issue is that, when I try to add one more endogenous state of asset like what you mentioned,
the computation for policy function, stationary distribution is Okey. However, in the module for AggVars, it reports
Error using gpuArray/subsref
Index exceeds matrix dimension.
Error in PolicyInd2Val_FHorz_Case1 (line 69)
PolicyValues(l_d+end,:)=temp_a_grid(PolicyIndexes(l_d+end,:));
Error in EvalFnOnAgentDist_AggVars_FHorz_Case1 (line 147)
PolicyValues=PolicyInd2Val_FHorz_Case1(PolicyIndexes,n_d,n_a,n_z,N_j,d_grid,a_grid);
Error in EndoRetireTest (line 199)
AggVars=EvalFnOnAgentDist_AggVars_FHorz_Case1(StationaryDist_init, Policy_init, FnsToEvaluate, Params, , n_d, n_a, n_z,N_j, d_grid, a_grid, z_grid);
That why I go back to read the only replication code, the RU2004, with more than one endogenous states and then come across the first problem. I check context of the function PolicyInd2Val_FHorz_Case1 and understand that you allow for the first endogenous state variable, say, asset, to fit into its corresponding policy value. So do the rest endogenous state variables. But in my test, l_d=1, and the “end” means 3. Imagine a one decision variable, say, labor, and two endogenous state variables, say, asset and retirement state, than the max row dimension for PolicyValues or PolicyIndex is 3. That is why it reports “Index exceeds matrix dimension.”
My understanding is that it should be " PolicyValues(l_d+end-1,:)=temp_a_grid(PolicyIndexes(l_d+end-1,:));", then it can capture the rest endogenous state variables other than asset.
To make it clear and in order to reproduce this problem, I attach the link of my short sample code as follows.
Best,