A Rough Guide to Getting Inequality in OLGs

Hi Robert, I set n_a(2)=11 just for convenience. I think Chen (2010) sets the number of points on the housing grid equal to 35. The grid for assets is complicated (see my post above) but he seems to set 60 points for owners (among which 10 are below zero) and 50 points for renters. However, he uses golden section search with interpolation for assets, so to replicate his results with the toolkit, which relies on pure discretization, I had to use at least 300 points (more would be better).
As @Shiki pointed out, Chen (2010) discretizes also the housing choice for renters (I am 90% sure on this. Not 100% since the Fortran code is complicated :slight_smile: ). This is not needed thanks to the nice trick Robert has shown.

! grid size

	integer, parameter :: q_grid_size = 50, h_grid_size = 35, q1_grid_size = 60
3 Likes

Hi @robertdkirkby what grid do you mean?

ValuesOnGrid=EvalFnOnAgentDist_ValuesOnGrid_FHorz_Case1()
gives the values of the FnsToEvaluate on the state-space grid (so in this model, on the grids on assets, housing, and exogenous shock). When calculating any statistic, say the mean, what happens internally is that first if calculates these ā€˜values on grid’ and then combines those with the weights (the agent distribution) to get the statistics —so in case of the mean, it is calculated as values on grid summed according to the weights (total mass of weights is 1, so no need to divide by total as part of calculating the mean).

This is going to allow you to see the value of the FnsToEvaluate everywhere in the (discretized) state-space of the model.

1 Like

Hi @jake88, I implemented Robert’s suggestion as follows:

FnsToEvaluate3.LoanToValueRatio=@(aprime,hprime,a,h,z) (hprime>0)*abs(aprime);
ValuesOnGrid=EvalFnOnAgentDist_ValuesOnGrid_FHorz_Case1(Policy, FnsToEvaluate3,Params,[],n_d,n_a,n_z,N_j,d_grid,a_grid,z_grid,simoptions);
LoanToValueRatio = gather(ValuesOnGrid.LoanToValueRatio);

Now I have the CPU array LoanToValueRatio with size [n_assets,n_housing,n_z,N_j]

This is a big array and I cannot display it in Matlab, but I can compute some summary:

min(LoanToValueRatio) = 0.000000 
max(LoanToValueRatio) = 14.577259 
Tot no. elements = 1529682.000000 
How many NaNs = 282656.000000 
How many 0s = 6147.000000 

It seems that there are indeed many NaN values in LoanToValueRatio. A bit strange…

This explains why AggVars.LoanToValueRatio.Mean is NaN

1 Like

Looks odd. I will take a closer look later this week.

2 Likes

@aledinola Regarding your Point 3, to calculate equilibrium price r and Tr, is it correct to add following codes to your main file:

GEPriceParamNames={ā€˜r’,ā€˜Tr’};
GeneralEqmEqns.capitalmarket = @(r,A,N,alpha,delta_k,Hr,p) r-alpha*((A-Hr*(1-p))^(alpha-1))*(N^(1-alpha))+delta_k;
GeneralEqmEqns.bequests = @(AccidentalBeqLeft,Tr,n) AccidentalBeqLeft/(1+n)-Tr;

heteroagentoptions.verbose=1;
p_eqm=HeteroAgentStationaryEqm_Case1_FHorz(jequaloneDist,AgeWeightsParamNames,n_d, n_a, n_z, N_j, 0, pi_z, d_grid, a_grid, z_grid, ReturnFn, FnsToEvaluate, GeneralEqmEqns, Params, DiscountFactorParamNames, , , , GEPriceParamNames, heteroagentoptions, simoptions, vfoptions);
Params.r=p_eqm.r;
Params.Tr=p_eqm.Tr;

1 Like

I haven’t looked into the general equilibrium part of the model yet. Hope to have time at the end of the week.

1 Like

The NaNs were just because the formula evaluated to NaN when hprime=0 due to trying to divide by zero [formula was: (hprime>0)*(aprime<0)*abs(aprime/hprime) ]

Easiest solution, just use a conditional restriction so that you can get a version only for Homeowners, just set
simoptions.conditionalrestrictions.Homeowners=@(aprime,hprime,a,z) (hprime>0);
and you can then also simplify
FnsToEvaluate.LoanToValueRatio=@(aprime,hprime,a,z) (aprime<0)*abs(aprime/hprime);
[no need to include that hprime>0; note, if aprime>0 then the loan is zero]

I updated my version of Chen (2010) codes to incorporate all the things Alessandro mentions. I think the only substantial thing still missing is that I don’t renormalize the model for g (deterministic growth), so I am implicitly just using g=0 [and toolkit does not do generalized lorenz curves so don’t do Gini of financial wealth as some observations are negative]. I also included a Chen2010.pdf that describes the model more in line with how VFI Toolkit codes implement it (and fix some typos).

2 Likes

Hi @Shiki, I think you can now have a look at Robert’s updated codes. He incorporated all my changes and he has the general equilibrium as well. In case anything is still not clear, feel free to ask!

1 Like