I’ve managed to get OLGModel14 to run, but it doesn’t converge very nicely. Looking at it from inside the debugger, what I’m seeing is that the household values are well-behaved in the range of +/- 1.0 mostly, as expected. However, the firm values are a million times smaller. I have traced this down to the fact that while the Stationary Distributions for both sum to 1.0 as expected, the (finite horizon) stationary distribution for households is rich enough (across its many dimensions) to yield meaning values when multiplying by the returned function values.
The shape of the (infinite horizon) firm stationary distribution (which does not have age parameters nor the exogenous shock vectors) is a two dimensional matrix whose top row has “nice” values, then a few rows of zeros, and then the remaining rows full of non-zero values that print as zero (ranging between 10^-6 and 10^-9). The firm return value matrix is zeros across the top row, and then seemingly normal values elsewhere. Alas, when we do the element-wise multiplication for example here:
for ff=1:length(FnsToEvaluate)
FnToEvaluateParamsCell=CreateCellFromParams(Parameters,FnsToEvaluateParamNames(ff).Names);
Values=EvalFnOnAgentDist_Grid(FnsToEvaluate{ff}, FnToEvaluateParamsCell,PolicyValuesPermute,l_daprime,n_a,n_z,a_gridvals,z_gridvals);
Values=reshape(Values,[N_a*N_z,1]);
% When evaluating value function (which may sometimes give -Inf values) on StationaryDistVec (which at those points will be 0) we get 'NaN'. Use temp as intermediate variable just eliminate those.
temp=Values.*StationaryDistVec;
AggVars(ff)=sum(temp(~isnan(temp)));
end
this results in zeroing out the top row and leaving the rest of the matrix scaled down by the very small values remaining in the infinite horizon Stationary Distribution matrix.
I believe that if the these two set of values were within the same order of magnitude, the iteration process would converge. As it is, it seems to be randomly iterating values for dividend payments and shares issued that never quite meet the mark, while all the other GE parameters and outputs remain fixed across iterations.
Now, perhaps there are other errors in the code that I’ve introduced trying to get OLGModel14 to work. But if the above sheds any light on the problem, I’m happy for any guidance.