Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

This notebook solves the consumption-labor model of Section 2, the paper’s smallest example of chaining two EGM inversions in one period, and then extends it with a risky portfolio share. The extension adds a stage that has no closed-form inversion. Its solution uses the numerical fallback of Section 5, while the labor and consumption stages run exactly as they do in the two-stage model.

1The Household Problem

A household enters period t with liquid assets at and draws a transitory wage θt. It chooses leisure zt∈[0,1], so that it works nt=1−zt, and then consumption ct, with

mt=𝖱at+θtnt,at+1=mt−ct,

and period utility u(c)+h(z)=c1−ρ/(1−ρ)+νz1−ζ/(1−ζ). Section 2 orders the period in three stages, each with its own value function:

vt0(at,θt)=maxzt∈[0,1]⁡h(zt)+vt1(mt),vt1(mt)=maxct∈[0,mt]⁡u(ct)+vt2(at+1),vt2(at+1)=β𝔼t[vt+10(at+1,θt+1)].

Placing the labor stage first resolves the wage before the consumption stage, which then keeps a single state. In the code, the labor stage takes as its state the bank balance bt=𝖱at, the incoming assets with their return. Market resources are mt=bt+wθtnt with the wage rate w=1. HARK also multiplies β by a survival probability. The calibration below is that of the paper’s figure.

Parameter                     Value
----------------------------  -----
Relative risk aversion (rho)  5.0
Discount factor (beta)        0.9
Survival probability          0.98
Risk-free return (R)          1.03
Leisure curvature (zeta)      2.0
Leisure weight (nu)           16.0
Wage shock dispersion         0.1
Zero-wage probability         0.05
Wage rate (w)                 1.0
Decision periods              30

2Two Inversions

The consumption stage is the standard EGM of Carroll (2006). On an exogenous grid of end-of-period assets, inverting the Euler equation u′(ct)=(vt2)′(at+1) gives consumption, and the budget gives the endogenous market resources mt=ct+at+1. The labor stage applies the same idea to leisure. Its first-order condition h′(zt)=(vt1)′(mt)θt inverts in closed form,

zt=(h′)−1((vt1)′(mt)θt)=((vt1)′(mt)θtν)−1/ζ,

on an exogenous grid of (mt,θt), after which the budget returns the endogenous bank balance bt=mt−θtnt. Where the inverted leisure exceeds the time endowment, the solver projects it onto zt=1.

After the solve, one node of the first-period labor stage shows the inversion at work. At that node the leisure the solver stored matches the closed form above and satisfies the first-order condition, while the stored bank balance is the budget identity.

node: m = 2.0196, theta = 1.0474
stored leisure      z = 0.751797789658500
closed form         z = 0.751797789658500
h'(z)                 = 28.308567520812279
v1'(m) theta          = 28.308567520812275
stored bank balance b = 1.759620466390091
m - theta n           = 1.759620466390091

3Solving the Model

agent.solve() above ran the backward recursion over all 30 periods. A direct check of the result is the consumption Euler equation, with next period’s consumption composed through both stages, first the labor policy at bt+1=𝖱at+1 and then the consumption policy at the market resources that labor choice produces. consumption_euler_residual returns the relative consumption error cˆ/c−1, where cˆ inverts the right-hand side of the Euler equation.

largest |c_Euler / c - 1| on m in [0.3, 10]: 1.5e-04

Between nodes, the composition evaluates two piecewise linear policies. If interpolation accounts for the residual, it should shrink as the asset grid is refined. Solving again on 48, 96 and 192 asset-grid points shows that it does:

Asset-grid points  Largest |c_Euler / c - 1|
-----------------  -------------------------
48                 3.5e-03
96                 6.2e-04
192                1.5e-04

Each doubling of the asset grid cuts the largest residual by roughly a factor of four.

4The Endogenous Grid and the Policies

Below, the paper’s figure is redrawn from this solve. Panel (a) is the endogenous grid of the first-period labor stage, on which each exogenous node (m,θ) lands at the bank balance its labor choice implies. Panel (b) shows consumption at every age except the last two, and panel (c) the first-period leisure policy at six wage draws.

<Figure size 2400x720 with 5 Axes>

Each wage draw keeps its own row of nodes, while the warping shows in the lines of constant m. Along one of them, a higher wage raises labor income θn, since panel (c) shows leisure falling as the wage rises. The same market resources then come from a smaller bank balance, which tilts the line to the left. At high market resources leisure is at its bound. Labor income is then zero, b=m, and the line is vertical. The zero-wage household stays at full leisure throughout.

The text of Section 2 quotes the first-period marginal propensity to consume and the household’s expected future labor. Both come from consumption_labor_mpc.csv, which the figure script writes. This run recomputes each row with the same functions:

Quantity                 m      This run   Published
-----------------------  -----  ---------  ---------
mpc_first_segment        0      0.47686    0.47686
mpc_at_m                 0.5    0.456941   0.456941
mpc_trough               4.416  0.0243734  0.0243734
mpc_plateau              22.5   0.0609332  0.0609332
future_labor             2      11.045     11.045
future_labor             7      6.77008    6.77008
future_labor             13     1.70092    1.70092
future_labor             16     0.127776   0.127776
future_labor             20     0          0
future_labor_first_zero  17.75  0          0

The propensity to consume falls from near one half at the borrowing constraint to a trough near m=4.4 and then rises slowly. Expected future labor, summed over the remaining periods along the simulated savings path, declines from about 11 periods’ worth at m=2 and first reaches zero near m=18 (the future_labor_first_zero row, found on a grid of step 0.25).

5Extension: A Risky Portfolio Share

Now give the household a risky asset with gross return 𝖱~t+1 alongside the safe one, and let it choose the risky share ςt∈[0,1] of its end-of-period assets. The new choice is a stage of its own, placed after consumption, where the only state is at+1:

vt2(at+1)=maxςt∈[0,1]⁡vt3(at+1,ςt),vt3(at+1,ςt)=β𝔼t[vt+10(bt+1,θt+1)],bt+1=(𝖱+(𝖱~t+1−𝖱)ςt)at+1.

The labor stage v0 and the consumption stage v1 keep their problems. As its state, the labor stage still takes a bank balance, now earned at the portfolio return. Consumption still comes from inverting the marginal value (vt2)′(at+1), which is now that of the risky-share stage at its optimal share.

The risky-share stage is the worked instance of the fallback in Section 5. Its first-order condition,

𝔼t[(𝖱~t+1−𝖱)∂vt+10∂b(bt+1,θt+1)]=0,

involves only the continuation value, with the risky share ςt entering inside the expectation through bt+1. The condition therefore cannot be inverted in closed form. At every asset node the solver evaluates the condition on a grid of shares, and linearly interpolates its first nonnegative-to-nonpositive crossing. Where no such crossing exists, the solver picks a corner by the sign at the endpoint, ς=1 if the condition is positive at share one, ς=0 otherwise. This stage solves a first-order condition numerically, which no EGM inversion does.

The reuse can be read off the classes themselves:

Solver method                 In the portfolio solver
----------------------------  -----------------------
calc_EndOfPrdvP               overridden
end_of_period_partials        new
make_consumer_labor_solution  inherited
make_consumption_solution     inherited
make_labor_leisure_solution   inherited
prepare_to_solve              inherited
solve                         inherited

terminal period built by the two-stage constructor: True

The portfolio household keeps every parameter of the two-stage calibration and adds HARK’s default risky return and share grid:

Parameter                      Value
-----------------------------  ------
Mean risky return              1.08
Std. dev. of log risky return  0.1836
Risky return nodes             5
Risk-free return (R)           1.03
Share grid nodes               26

The checks on this solve mirror those on the two-stage solve. With the risky asset the Euler equation becomes u′(ct)=β𝔼t[𝖱t+1pu′(ct+1)] at the chosen share, where 𝖱t+1p is the portfolio return. portfolio_residuals reports the share condition relative to the same expectation, as a fraction of the marginal value of wealth. The last line reads the share policy at the smallest asset node and at the largest assets drawn below.

largest |c_Euler / c - 1| on m in [0.3, 10]: 1.6e-04
interior shares: 101 of 200 points
largest |share condition| at interior shares: 5.1e-04
share-one corners with a positive condition: 99 of 99
risky share at a = 0.001 and a = 60: [0.3106 0.3106]

Wherever the household holds only the risky asset the condition is positive, as a corner at ς=1 requires. At interior shares the condition would be exactly zero without interpolation error. Re-solving on other grids places that error in the asset dimension. The interior residual shrinks as the asset grid is refined, while doubling the share grid leaves it where it was.

Asset-grid points  Share-grid points  Largest interior |share condition|
-----------------  -----------------  ----------------------------------
48                 26                 6.5e-03
96                 26                 3.0e-03
96                 51                 3.0e-03
200                26                 5.1e-04
<Figure size 2400x690 with 3 Axes>

Panel (a) shows the fallback at work. At each asset node the solver has the share condition at the grid shares (the dots). The cross marks where linear interpolation puts its first zero. A curve that stays positive is a corner at ς=1. In panel (b), a household with modest savings holds only the risky asset, since its future labor income behaves like a safe holding. As savings grow relative to that income, the risky share falls. At the smallest balances it also falls below one. There, next period’s marginal utility is dominated by the zero-wage draw, in which the portfolio is the household’s only resource. Both ends of the policy approach the same share, printed above, because at both ends the portfolio return alone governs next period’s consumption in the states that dominate its marginal utility. Panel (c) and the table below compare consumption with and without the risky asset.

m     Safe asset only  With risky share
----  ---------------  ----------------
1.0   0.4188           0.4174
5.0   0.6050           0.6090
10.0  0.7443           0.8011
20.0  1.2218           1.3244
30.0  1.8317           1.9561

At low market resources the two consumption functions nearly coincide. At higher resources the higher expected return raises consumption, by more the more the household has saved.