phillips_adaptive#
Series: lecture-python.myst
File:
lectures/phillips_adaptive.mdAudit date: 2026-08-26
Corpus snapshot:
e25fdf2345Categories audited: writing, math, code, figures, references, links, admonitions (JAX out of scope)
Overall score: 8.4 / 10
Priority: LOW
Score breakdown#
Category |
Score |
One-line note |
|---|---|---|
Writing |
5.5/10 |
|
Math |
9.5/10 |
|
Code |
8.5/10 |
|
JAX |
out of scope |
JAX rules target |
Figures |
6.5/10 |
|
References |
8.5/10 |
|
Links |
10/10 |
no mechanical violations detected. |
Admonitions |
10/10 |
no mechanical violations detected. |
Issues#
Critical#
None found.
High severity#
None found.
Medium severity#
[qe-code-001] (reviewer) — Follow PEP8 unless closer to mathematical notation. Count: 3. Lines: 220, 137, 272. Example: flake8 over every code cell (
--select=E1,E2,E5,E7,W2,W3,W6,F,C4 --max-line-length=79) is silent, and three items sit just outside what it can see. 220 unpacks three values and uses one:P, F, d = self.lq.stationary_values(), withPanddnever referenced again - pyflakes does not report unused names bound by tuple unpacking, so_, F, _ = ...(or indexing) is the version that says what is meant. 137 escapes a backslash in a plain string,label='policy $\\tilde y$', one line after 136 uses an r-string for the same job,rf'$\lambda = {λ}$', and 447-448 use r-strings too. 272 is the one function in the file with no docstring (def disinflation_table(δ, lags=(1, 5, 20, 50)):), where 122, 202-205 and 226 all have one. Also worth folding in: 131 pads a trailing comment with seventeen spaces, and 480 rebuilds a seriessimulatealready computed -x = adaptive_forecast(np.concatenate([[12.0], y]), λ=0.7, x0=12.0)[1:]reconstructs the expectation path that line 232 computes and discards.[qe-fig-001] — Do not set figure size unless necessary. Count: 3. Lines: 133, 302, 445. Example: figsize=.
[qe-fig-003] — No matplotlib embedded titles. Count: 1. Lines: 308. Example: .set_title.
[qe-fig-004] — Caption formatting conventions. Count: 2. Lines: 114, 295. Example: caption of 11 words.
[qe-math-009] (reviewer) — Choose simplicity in mathematical notation. Count: 3. Lines: 198, 156, 106. Example: \(\beta\) is two objects 145 lines apart. 198 states “The discount factor is \(\beta = \delta\)” (the name QuantEcon’s
LQuses), and 343 then makes \(\beta\) the coefficient vector of the Keynesian Phillips curve, \(y_t = \beta^\top X_{K,t} + \varepsilon_{K,t}\), which 363 lists as one of the four objects carried into the next lectures. Since 157 already has \(\delta\) for the discount factor, 198 can say “we pass \(\delta\) as thebetaargument” in prose and leave the symbol free. Second, the one-period payoff changes letter and arguments across the suite without being recorded: 156 writes \(p(U_t, y_t) = -\tfrac{1}{2}(U_t^2 + y_t^2)\), wherephillips_credibility.md:102writes the same payoff as \(r(x, y)\) andphillips_credible_policieskeeps \(r\) - so the object the two lectures share is \(r\) in one and \(p\) in the other, with different arguments, and the suite’s notation table (phillips_two_stories.md:84-98) has no row for it. Third, the suite’s notation table gets this lecture’s own gain wrong.phillips_two_stories.md:97lists “learning gain | \(\lambda\), \(g_t\) |{doc}`phillips_adaptive`,{doc}`phillips_learning`”, and line 106 here says the opposite in as many words:{eq}`pa_adaptive`is “a constant gain version of the least squares learning algorithm … with the constant \((1 - \lambda)\) playing the role that the decreasing gain \(t^{-1}\) played there”. So \(\lambda\) is the adaptation (or forgetting) parameter and the gain is \(1 - \lambda\) - which is exactly whatphillips_learning.md:535also states from the other side (“A forgetting factor \(\lambda \in (0, 1]\) maps to the gain: \(\lambda = 1\) gives least squares (\(g_t \to 1/t\)), while \(\lambda < 1\) gives a constant gain \(g_0 = 1 - \lambda\)”). The row is therefore wrong for both lectures it names on the \(\lambda\) half, while \(g_t\) is right forphillips_learning(its 450).phillips_two_stories.md:111-114compounds it by giving \(\lambda\) a fourth reading, “the Cagan-Friedman adaptation parameter in{doc}`phillips_adaptive`”, which is the correct one and contradicts the table thirteen lines above it.[qe-ref-001] — Use correct citation style. Count: 2. Lines: 84, 399. Example:
{cite}in narrative flow: ‘{cite}’.[qe-writing-002] (reviewer) — Keep writing clear, concise, and valuable. Count: 4. Lines: 399, 349, 415, 413. Example: 399 is 46 words and says “unit root” twice inside one clause chain: “
{cite}`KingWatson1994`and others later argued that the pattern of rejections and non-rejections is consistent with the tendency of inflation to have a unit root after the 1960s but not before, so the unit-sum restriction \(b_1 = 1\) is compatible with rational expectations when \(y_t\) has a unit root.” It splits cleanly at the “so”. 349 is 34 words and is a definition carrying three subordinate clauses at once - the objective, the believed Phillips curve, and the control error \(v_{2t}\) - which is the one sentence in the section a reader must hold intact. 415 is 37 words with three coordinated claims about what the next two lectures do; 413 is 35 words with the lesson of the whole section buried after an “…but in the form that Phelps, Tobin, and Solow used it” aside; 453 is 36 and 417 is 34. Seven sentences run past 32 words in a 490-line file that is otherwise disciplined (qe-writing-001measures zero).[qe-writing-003] (reviewer) — Maintain logical flow. Count: 4. Lines: 333, 249, 108, 427. Example: the general Phelps problem is written with an off-by-one that also puts it out of step with the lecture it feeds. 328-333 defines \(X_{U,t} = [U_{t-1} \cdots U_{t-m_U}]^\top\), \(X_{y,t} = [y_{t-1} \cdots y_{t-m_y}]^\top\) and \(X_t = [X_{U,t}^\top\ X_{y,t}^\top\ 1]^\top\), saying in words that \(X_t\) “collects information dated \(t-1\) and earlier”. 339 then writes \(X_{C,t} = [y_t\ X_{t-1}^\top]^\top\), so by that definition the classical Phillips curve regresses \(U_t\) on \(y_t\), \(U_{t-2}, \ldots\) and \(y_{t-2}, \ldots\), with \(U_{t-1}\) and \(y_{t-1}\) missing; and 349’s control law \(\hat y_t = h X_{t-1}\) has the government ignoring last period’s data.
phillips_learning.md:436gets it right by putting the shift in the subscript - \(X_{t-1} = [U_{t-1}\ U_{t-2}\ y_{t-1}\ y_{t-2}\ 1]^\top\) - and:426writes \(X_{C,t} = [y_t\ U_{t-1}\ U_{t-2}\ y_{t-1}\ y_{t-2}\ 1]^\top\), which is what 339 means. So the two lectures index the same vector one period apart, and it is the vector the whole learning suite is built on. Second, {prf:proposition}pa_propat 249-253 is the result 247 calls “the reason the Phelps problem is interesting”, and it is neither proved, nor cited to a proof, nor ever computed: the code replaces \(\delta = 1\) byβ = min(δ, 1 - 1e-7)(218), so the claims at 291 and 317 that “inflation is driven all the way to the Ramsey value of zero” in the undiscounted case rest on a run at \(\beta = 0.9999999\), and exercise 1 (425-429) only checks the approach as \(\delta \to 1\). Third, 108 defines an induction property and 366 defines an induction hypothesis as a different thing (a unit-sum restriction on the Keynesian lag weights), while 146 and 375 use the two names for the same act - “Solow and Tobin exploited this induction property” against “exploited the induction hypothesis” - and the lecture never says whether they are one concept. Fourth, exercise 1 asks for \(\delta \in \{0.90, 0.92, \ldots, 0.99\}\) (427), a step that cannot land on 0.99, and its solution computesnp.arange(0.90, 0.995, 0.01)(439), a different grid.[qe-writing-005] (reviewer) — Use bold for definitions, italic for emphasis. Count: 3. Lines: 411, 349, 335. Example: 411 sets a definition in italic and glosses it in the same breath: “Large sacrifice ratios — estimated amounts of foregone GDP required to bring inflation down one percentage point — circulated widely” - the em-dash aside is the definition, so the term wants bold. 335 does the same for direction of fit, introduced in italic at 335 and then glossed at 347 (“The subscripts \(C\) and \(K\) stand for Classical … and Keynesian …”), and 106 introduces constant gain in italic where
phillips_learning.md:52bolds gain as the definition of the same idea. Against that, 349 bolds Phelps problem a second time, having already bolded it at 66, so a reader cannot tell which of the two is the definition - the same defect flagged atphillips_learning.md:206for mean dynamics. And 363 bolds self-confirming equilibria in a sentence that explicitly defers the definition to another lecture (“exactly the ingredients we will need to define … in{doc}`phillips_self_confirming`”), wherephillips_self_confirming.md:49bolds it again as the real definition.[qe-writing-007] (reviewer) — Use visual elements to enhance understanding. Count: 3. Lines: 255, 335, 271. Example: the lecture’s central comparative static is a statement about a region and it is only ever verbal. 255-259: “When \(\delta = 1\), \(\lambda\) governs the speed of convergence … When \(\delta < 1\), the limit point of \(y_t\) depends on a comparison of \(\lambda\) with \(\delta\) … For \(\lambda < \delta\) and \(\delta\) close to \(1\), the government’s policy eventually approximates the Ramsey outcome.” That is a picture in the \((\lambda, \delta)\) plane with the \(\lambda = \delta\) line on it, and the machinery to draw it already exists - exercise 1 (438-450) computes \(y_\infty\) on a \(\delta\) grid for one \(\lambda\); a second loop over \(\lambda\) turns it into the surface the proposition is about. Second, the two directions of fit (335-347) are the canonical scatter with two fitted lines - classical regresses \(U\) on \(y\), Keynesian regresses \(y\) on \(U\), same cloud, different residual - and 363 says these are “exactly the ingredients we will need” for the next lectures, so this is where the picture belongs; there is none. Third, 269 promises “The following tables” and 271-285 prints hand-aligned f-strings, which render as a preformatted block rather than a table in the book.
Low severity#
[qe-fig-005] — Descriptive figure names for cross-referencing. Count: 1. Lines: 438. Example: code-cell figure without mystnb figure metadata.
Strengths#
The LQ translation at 180-196 is done in full and is correct: \(U_t = a^\top s_t - \theta y_t\) with \(a = [U^*\ \theta]^\top\) expands to exactly the quadratic form displayed at 185, and matching it to the QuantEcon loss gives \(R = \tfrac12 a a^\top\), \(Q = \tfrac12(\theta^2+1)\), \(N = -\tfrac12\theta a^\top\) - each of which the code reproduces literally at 210-215, including the sign of
Nand the1 - λinB. The policy extraction at 223 also has the sign right for QuantEcon’s \(u = -Fx\) convention.236-238 states what the solution looks like and what would falsify the setup: the optimal rule is \(y_t = f_1 + f_2 x_t\) with \(f_1 \neq 0\) and \(f_2 \neq 1\), “if instead \(f_1 = 0\) and \(f_2 = 1\), we would have \(y_t = x_t\) for all histories” - and 240-242 then prints the two coefficients, so the reader can check the inequalities rather than believe them.
The induction property is demonstrated before it is used: 108-110 states it, 114-141 simulates a constant policy at two values of \(\lambda\) and shows the expectation walking up to it, and 144 draws the one conclusion the figure supports (“more slowly the larger is \(\lambda\)”) without overreaching.
106 makes the connection back to the previous lecture precise rather than gestural:
{eq}`pa_adaptive`is “a constant gain version of the least squares learning algorithm from{doc}`phillips_credibility`, with the constant \((1 - \lambda)\) playing the role that the decreasing gain \(t^{-1}\) played there” - which is exactly the mappingphillips_learning.md:535states from the other side (\(g_0 = 1 - \lambda\)).The historical section (373-417) does the unusual thing of following the model into its misuse: 386-397 gives the Solow-Tobin regression
{eq}`pa_tobin`and its \(b_1 < 1\) rejection, 399 gives the unit-root rebuttal, and 403-413 says plainly that the same apparatus was turned around in the late 1970s to argue against disinflating, with “Phelps’s control problem carries a tattered past” (405).Both exercises test something the body asserts and could not otherwise be checked - the \(\delta \to 1\) limit of the proposition (425-429) and whether the public is fooled in the steady state (462-466) - and exercise 2’s solution prints the gap \(y_\infty - x_\infty\) to scientific notation (484) rather than asking the reader to eyeball two numbers.
The Frost epigraph at 42-47 is the whole lecture in four lines: agents who “cannot look out far” and “cannot look in deep” but keep watch anyway is precisely the adaptive public the Phelps problem posits.
Recommended actions#
Fix the indexing of the state vector at 328-333: define \(X_{t-1} = [U_{t-1}\ \cdots\ y_{t-1}\ \cdots\ 1]^\top\) as
phillips_learning.md:436does, so that \(X_{C,t}\) at 339 really contains \(U_{t-1}\) and \(y_{t-1}\) and the control law at 349 is not one period stale. As written the two lectures disagree by a period about the object the whole learning suite shares.Give {prf:proposition}
pa_prop(249-253) either a proof, a{prf:proof}sketch, or a citation to chapter 5 of{cite}`Sargent1999`- and say in the text at 218 that \(\delta = 1\) is computed as \(\beta = 1 - 10^{-7}\), since 291 and 317 report the undiscounted case as if it had been solved exactly.Settle “induction property” (108) against “induction hypothesis” (366): either say they are the same thing, or stop using them interchangeably at 146 and 375.
Free up \(\beta\): 198 can name \(\delta\) as the value passed to
LQ’sbetaargument in prose, leaving \(\beta\) for the Keynesian coefficient vector at 343 and 363 alone.Correct the suite’s notation table:
phillips_two_stories.md:97calls \(\lambda\) the “learning gain” in this lecture and in{doc}`phillips_learning`, and both lectures say the gain is \(1 - \lambda\) - line 106 here andphillips_learning.md:535. The table’s own prose gloss atphillips_two_stories.md:111gets it right (“the Cagan-Friedman adaptation parameter”), so the row and the paragraph below it disagree.Bold sacrifice ratios (411) and direction of fit (335), which are definitions; un-bold the second Phelps problem at 349 and the forward-referenced self-confirming equilibria at 363, neither of which is defined where it is bolded.
Split the four long sentences (399 at the “so”, 349 into objective and constraints, 415, 413), and reconcile exercise 1’s stated grid \(\{0.90, 0.92, \ldots, 0.99\}\) (427) with the
np.arange(0.90, 0.995, 0.01)its solution uses (439).Add the \((\lambda, \delta)\) picture that 255-259 describes - \(y_\infty\) over a grid in both parameters with the \(\lambda = \delta\) line drawn - by looping exercise 1’s computation (438-443) over \(\lambda\) as well; and turn the printed block at 271-285 into a real table, since 269 already calls it one.
Sweep:
_, F, _ = self.lq.stationary_values()at 220, an r-string at 137, a docstring ondisinflation_tableat 272, and havesimulatereturnxas well so 480 need not reconstruct it. Then the mechanical figure items: drop the threefigsize=overrides (133, 302, 445), moveax.set_titleat 308 and 449 into captions, addmystnbmetadata to the solution cell at 438, cut the two captions to six words (114, 295), and change the two narrative citations at 84 and 399 to{cite:t}.