Error in LifeCycleModel30

I tried to run LifeCycleModel30 (model with semi-exogenous shocks and fertility decision) in the introduction to lifecycle models, but I got this error:

Finite horizon: 80 of 81 
Error using kron
Inputs must be 2-D.

Error in ValueFnIter_Case1_FHorz_SemiExo_raw (line 192)
                entireEV=kron(EV,ones(N_d1,1));

Error in ValueFnIter_Case1_FHorz (line 749)
                    [VKron, Policy3]=ValueFnIter_Case1_FHorz_SemiExo_raw(n_d1,n_d2,n_a,n_z,vfoptions.n_semiz, N_j, d1_grid, d2_grid, a_grid, z_gridvals_J, semiz_gridvals_J, pi_z_J, pi_semiz_J, ReturnFn, Parameters, DiscountFactorParamNames, ReturnFnParamNames, vfoptions);

The reason is that EV is not a 2-dim array but it has size (201,1,88). Adding squeeze(EV) avoids the error when calling the kron function but generates another error in the next line (incompatible size for the + operation).

fixed. thanks for letting me know.

(Was doing kron() when needed to be repelem() because it has more than 2 dimensions; kron can only be used in 2-D.)

1 Like