Lecture: Default Risk and Income Fluctuations (lectures/arellano.md)
In ArellanoEconomy.__init__:
self.B0_idx = np.searchsorted(self.B_grid, 1e-10)
With the default grid, B_grid[125] is exactly 0.0, but searchsorted returns the first index >= 1e-10, i.e. 126, where B_grid[126] = +0.0036.
This breaks two things:
-
Default at zero debt. T_d uses v_c[B0_idx, :] as the re-entry
continuation value, so default carries a small reward. Since h(y) = y
for y < 0.978, default is costless at low income, and this is enough
to make v_c(0, y) < v_d(y) there — even though h(y) <= y and
v >= v_d imply the reverse must always hold.
-
Positive assets while in default. simulate sets Bp_idx = B0_idx, so foreign assets sit at +0.0036 throughout every exclusion period.
Proposed fix
# The index of the grid point closest to zero
self.B0_idx = np.argmin(np.abs(self.B_grid))
self.B_grid[self.B0_idx] = 0
Selecting by distance is robust to floating-point noise; the second line also covers grids that do not contain zero (e.g. B_grid_size=250), and is a no-op with the default grid.
Note that this changes the bond price schedule and the time-series
figures, so they will need regenerating.
Happy to open a PR.
Lecture: Default Risk and Income Fluctuations (
lectures/arellano.md)In
ArellanoEconomy.__init__:With the default grid,
B_grid[125]is exactly0.0, butsearchsortedreturns the first index>= 1e-10, i.e. 126, whereB_grid[126] = +0.0036.This breaks two things:
Default at zero debt.
T_dusesv_c[B0_idx, :]as the re-entrycontinuation value, so default carries a small reward. Since
h(y) = yfor
y < 0.978, default is costless at low income, and this is enoughto make
v_c(0, y) < v_d(y)there — even thoughh(y) <= yandv >= v_dimply the reverse must always hold.Positive assets while in default.
simulatesetsBp_idx = B0_idx, so foreign assets sit at+0.0036throughout every exclusion period.Proposed fix
Selecting by distance is robust to floating-point noise; the second line also covers grids that do not contain zero (e.g.
B_grid_size=250), and is a no-op with the default grid.Note that this changes the bond price schedule and the time-series
figures, so they will need regenerating.
Happy to open a PR.