QuantEcon / QuantEcon/lecture-python-advanced.myst
[arellano] Default occurs at zero debt due to incorrect `B0_idx`
Nobody has claimed this yet.
- Dominant language
- TeX
- Stars
- 37
- Forks
- 26
- Avg merge
- 13d 22h
- Merged PRs (30d)
- 2
Description
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_dusesv_c[B0_idx, :]as the re-entry
continuation value, so default carries a small reward. Sinceh(y) = y
fory < 0.978, default is costless at low income, and this is enough
to makev_c(0, y) < v_d(y)there — even thoughh(y) <= yand
v >= 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
# 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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in lectures/arellano.md, reading ArellanoEconomy.init and simulate around B0_idx, then inspect how T_d uses the re-entry value. Verify that zero is selected for the default grid and for grids without an exact zero, default-state assets remain zero, the value inequality is restored, and the bond price schedule and time-series figures are regenerated.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data, documentation
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100