# A Life Cycle Model: The Distribution of Assets By Age#

National registry data on income and wealth from Scandinavian countries has recently become available (with a lot of security) to some (lucky!) researchers. These data offer a uniquely powerful tool for testing (and improving) our models of consumption and saving behavior over the life cycle.

But as of this writing (in March of 2019), the data are so new that there do not seem to be any published attempts to compare the data to the implications a standard life cycle model with income uncertainty, constraints, and other modern features.

This notebook is an example of how one could counstruct a life cycle model with the HARK toolkit that would make predictions about the model analogues of the raw data statistics that are available.

For example, the papers have shown information about the growth rate of assets at different ages over the life cycle. Here, we show how (under a given parameterization) we could produce the life cycle model’s prediction about the distribution of assets at age 65 and age 66, and the growth rate between 65 and 66.

The parameters of the model have not been optimized to match features of the Norwegian data; a first step in “structural” estimation would be to calibrate the inputs to the model (like the profile of income over the life cycle, and the magnitude of income shocks), and then to find the values of parameters like the time preference rate that allow the model to fit the data best.

An interesting question is whether this exercise will suggest that it is necessary to allow for *ex ante* heterogeneity in such preference parameters.

This seems likely; a paper by Carroll et al (2017) (all of whose results were constructed using the HARK toolkit) finds that, if all other parameters (e.g., rates of return on savings) are the same, models of this kind require substantial heterogeneity in preferences to generate the degree of inequality in U.S. data.

But in one of the many new and interesting findings from the Norwegian data, Fagereng et al (2020) have shown that there is substantial heterogeneity in rates of return, even on wealth held in public markets.

Derin Aksit has shown that the degree of time preference heterogeneity needed to match observed inequality is considerably less when rate-of-return heterogeneity is calibrated to match these data.

```
[1]:
```

```
# Initial imports and notebook setup, click arrow to show
import HARK.ConsumptionSaving.ConsIndShockModel as Model # The consumption-saving micro model
import EstimationParameters as Params # Parameters for the consumer type and the estimation
from HARK.utilities import plot_funcs # Some tools
import numpy as np
```

```
[2]:
```

```
# Set up default values for CRRA, DiscFac, and simulation variables in the dictionary
Params.init_consumer_objects["CRRA"] = (
2.00 # Default coefficient of relative risk aversion (rho)
)
Params.init_consumer_objects["DiscFac"] = (
0.97 # Default intertemporal discount factor (beta)
)
Params.init_consumer_objects["PermGroFacAgg"] = (
1.0 # Aggregate permanent income growth factor
)
Params.init_consumer_objects["aNrmInitMean"] = -10.0 # Mean of log initial assets
Params.init_consumer_objects["aNrmInitStd"] = (
1.0 # Standard deviation of log initial assets
)
Params.init_consumer_objects["pLvlInitMean"] = (
0.0 # Mean of log initial permanent income
)
Params.init_consumer_objects["pLvlInitStd"] = (
0.0 # Standard deviation of log initial permanent income
)
```

```
[3]:
```

```
# Make a lifecycle consumer to be used for estimation
LifeCyclePop = Model.IndShockConsumerType(**Params.init_consumer_objects)
```

```
[4]:
```

```
# Solve and simulate the model (ignore the "warning" message)
LifeCyclePop.solve() # Obtain consumption rules by age
LifeCyclePop.unpack("cFunc") # Expose the consumption rules
# Which variables do we want to track
LifeCyclePop.track_vars = ["aNrm", "pLvl", "mNrm", "cNrm", "TranShk"]
LifeCyclePop.T_sim = 120 # Nobody lives to be older than 145 years (=25+120)
LifeCyclePop.initialize_sim() # Construct the age-25 distribution of income and assets
LifeCyclePop.simulate() # Simulate a population behaving according to this model
```

```
[4]:
```

```
{'aNrm': array([[0.15124943, 0.15125731, 0.15126049, ..., 0.15125088, 0.15125539,
0.151246 ],
[0.22518609, 0.18215553, 0.35807711, ..., 0.27812983, 0.17667259,
0.15458877],
[0.32597743, 0.38337328, 0.37146627, ..., 0.41407619, 0.2350288 ,
0.25442612],
...,
[0.01608449, 0.35744504, 0.23336433, ..., 0.46517625, 0.49899843,
0.52070675],
[0.15126599, 0.40279067, 0.15865312, ..., 0.63411803, 0.59225189,
0.50505825],
[0.21086177, 0.43497386, 0.10261234, ..., 0.49429389, 0.5951336 ,
0.48172896]]),
'pLvl': array([[1.05822383, 0.94158876, 0.94158876, ..., 1.05822383, 1.10492571,
0.87169091],
[1.16925872, 1.04038564, 0.8865894 , ..., 1.16925872, 1.32101196,
0.88907473],
[1.29194402, 0.97961543, 0.83480262, ..., 1.0192322 , 1.24385002,
0.94084007],
...,
[0.78985017, 1.2206714 , 2.6930019 , ..., 1.51390313, 1.14934868,
1.26319886],
[1.05822383, 1.14937048, 2.6930019 , ..., 1.42547418, 1.0018768 ,
1.33674714],
[1.0793276 , 1.37414863, 2.6930019 , ..., 1.70424892, 0.98490683,
1.3634054 ]]),
'mNrm': array([[1.00001827, 1.00003607, 1.00004326, ..., 1.00002153, 1.00003174,
1.00001051],
[1.14105943, 1.06423984, 1.33773072, ..., 1.22438773, 1.05354839,
1.00744107],
[1.29330935, 1.37152667, 1.35560327, ..., 1.41203468, 1.15716564,
1.18806724],
...,
[1.06456208, 1.33262987, 1.34334302, ..., 1.47580996, 1.48887221,
1.52996964],
[1.00005568, 1.39107394, 1.24036526, ..., 1.68112185, 1.5896886 ,
1.50688532],
[1.11666181, 1.43040404, 1.16341271, ..., 1.51020732, 1.58443432,
1.47394272]]),
'cNrm': array([[0.84876883, 0.84877876, 0.84878277, ..., 0.84877065, 0.84877634,
0.84876451],
[0.91587334, 0.88208431, 0.97965361, ..., 0.94625789, 0.87687579,
0.85285231],
[0.96733192, 0.98815339, 0.984137 , ..., 0.99795848, 0.92213684,
0.93364112],
...,
[1.04847759, 0.97518483, 1.10997869, ..., 1.01063371, 0.98987378,
1.00926289],
[0.84878969, 0.98828327, 1.08171214, ..., 1.04700382, 0.9974367 ,
1.00182707],
[0.90580003, 0.99543018, 1.06080037, ..., 1.01591343, 0.98930072,
0.99221376]]),
'TranShk': array([[1. , 1. , 1. , ..., 1. , 1. ,
1. ],
[1.00006632, 0.92323938, 1.1722675 , ..., 1.08339327, 0.92323938,
0.85470368],
[1.08339327, 1.1722675 , 0.96390423, ..., 1.08339327, 0.96390423,
1.0376015 ],
...,
[1. , 0.92323938, 1. , ..., 1.08339327, 0.85470368,
1.0376015 ],
[1. , 1.00006632, 1. , ..., 1.1722675 , 1.00006632,
1.00006632],
[0.96390423, 1.08339327, 1. , ..., 0.96390423, 0.96390423,
0.96390423]])}
```

```
[5]:
```

```
# Plot the consumption functions during working life
print("Consumption as a function of market resources while working:")
mMin = min([LifeCyclePop.solution[t].mNrmMin for t in range(LifeCyclePop.T_cycle)])
plot_funcs(LifeCyclePop.cFunc[: LifeCyclePop.T_retire], mMin, 5)
```

```
Consumption as a function of market resources while working:
```

```
[6]:
```

```
# Define the saving rate function
def savingRateFunc(SomeType, m):
"""
Parameters:
----------
SomeType:
Agent type that has been solved and simulated.
Returns:
--------
SavingRate: float
"""
inc = (SomeType.Rfree - 1.0) * (m - 1.0) + 1.0
cons = SomeType.solution[0].cFunc(m)
Saving = inc - cons
SavingRate = Saving / inc
return SavingRate
```

```
[7]:
```

```
# Create a Giant matrix gathering useful data:
# 't_now', 'aNrmNow_hist', 'cNrmNow_hist', employment-status in date t, in date t-1, aLvlGro_hist, Saving rate
w, h = 1, LifeCyclePop.T_cycle
giant_list = [[0 for x in range(w)] for y in range(h)]
SavingRate_list = []
import warnings
warnings.filterwarnings("ignore") # Suppress some disturbing but harmless warnings
for t in range(1, LifeCyclePop.T_cycle + 1):
# aLvlGro_hist[0] = 0 # set the first growth rate to 0, since there is no data for period 0
aLvlGroNow = np.log(
LifeCyclePop.history["aNrm"][t] / LifeCyclePop.history["aNrm"][t - 1]
) # (10000,)
# Call the saving rate function with test value for
SavingRate = savingRateFunc(LifeCyclePop, LifeCyclePop.history["mNrm"][t])
SavingRate_list.append(SavingRate)
# Create elements of matrix list
matrix_list = [0 for number in range(7)]
matrix_list[0] = t
matrix_list[1] = LifeCyclePop.history["aNrm"][t]
matrix_list[2] = LifeCyclePop.history["cNrm"][t]
matrix_list[3] = LifeCyclePop.history["TranShk"][t]
matrix_list[4] = LifeCyclePop.history["TranShk"][t - 1]
matrix_list[5] = aLvlGroNow
matrix_list[6] = SavingRate
giant_list[t - 1] = matrix_list
# Print command disabled to prevent giant print!
# print giant_list
```

```
[8]:
```

```
# Construct the level of assets A from a*p where a is the ratio to permanent income p
LifeCyclePop.history["aLvl"] = (
LifeCyclePop.history["aNrm"] * LifeCyclePop.history["pLvl"]
)
aGro41 = LifeCyclePop.history["aLvl"][41] / LifeCyclePop.history["aLvl"][40]
aGro41NoU = aGro41[aGro41[:] > 0.2] # Throw out extreme outliers
```

```
[9]:
```

```
# Plot the distribution of growth rates of wealth between age 65 and 66 (=25 + 41)
from matplotlib import pyplot as plt
n, bins, patches = plt.hist(aGro41NoU, 50, density=True)
```