In the model “Life-Cycle Model 11A: Idiosyncratic shocks again, persistent and transitory” there is a bug if the user chooses lowmemory=2
Finite horizon: 80 of 81
Error using +
Arrays have incompatible sizes of 10251 and 51 in dimension 1. In each dimension, the sizes must be equal or one of the arrays must
have size 1.
Error in ValueFnIter_Case1_FHorz_raw (line 263)
entireRHS_az=ReturnMatrix_az+DiscountFactorParamsVec*entireEV_z;
^
Error in ValueFnIter_Case1_FHorz (line 890)
[VKron, PolicyKron]=ValueFnIter_Case1_FHorz_raw(n_d,n_a,n_z, N_j, d_grid, a_grid, z_gridvals_J, pi_z_J, ReturnFn, Parameters, DiscountFactorParamNames, ReturnFnParamNames, vfoptions);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in LifeCycleModel11A (line 116)
[V, Policy]=ValueFnIter_Case1_FHorz(n_d,n_a,n_z,N_j, d_grid, a_grid, z_grid, pi_z, ReturnFn, Params, DiscountFactorParamNames, [], vfoptions);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Related documentation
The error happens because of the line
entireRHS_az=ReturnMatrix_az+DiscountFactorParamsVec*entireEV_z;
The return matrix ReturnMatrix_az
should have size [n_d*n_a,1] and entireEV_z
likewise, but ReturnMatrix_az is of size [n_d,1] only.
P.S. I don’t need lowmemory=2, but I was looking at the codes to see the algorithm.