QuantEcon / QuantEcon/lecture-python-advanced.myst

[arellano] Default occurs at zero debt due to incorrect `B0_idx`

Open
#382 0 comments 0 reactions 0 assignees View on GitHub

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:

  1. 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.

  2. 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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.