phillips_priors#
Series: lecture-python.myst
File:
lectures/phillips_priors.mdAudit date: 2026-08-26
Corpus snapshot:
e25fdf2345Categories audited: writing, math, code, figures, references, links, admonitions (JAX out of scope)
Overall score: 7.5 / 10
Priority: LOW
Score breakdown#
Category |
Score |
One-line note |
|---|---|---|
Writing |
4.5/10 |
|
Math |
7/10 |
|
Code |
8.5/10 |
|
JAX |
out of scope |
JAX rules target |
Figures |
5.5/10 |
|
References |
7/10 |
|
Links |
10/10 |
no mechanical violations detected. |
Admonitions |
10/10 |
no mechanical violations detected. |
Issues#
Critical#
None found.
High severity#
[qe-fig-001] — Do not set figure size unless necessary. Count: 5. Lines: 328, 366, 397, 553, 655. Example: figsize=.
[qe-math-010 (proposed)] — Blackboard \mathbb{P}, \mathbb{E}, \mathbb{V} with braces. Count: 2. Lines: 161, 189. Example: non-blackboard
\operatorname{cov}.[qe-ref-001] — Use correct citation style. Count: 12. Lines: 40, 57, 103, 182, 444, 446, 448, 587, 599, 668. Example:
{cite}in narrative flow: ‘of{cite}’.[qe-writing-002] (reviewer) — Keep writing clear, concise, and valuable. Count: 5. Lines: 219, 40, 438, 587, 615. Example: the file is otherwise well-paced - one sentence per paragraph, no qe-writing-001 hits at all - and the cost is concentrated in five long sentences. 219 is 63 words carrying three equation references and two definitions (“Constant-gain recursive least squares is the special case in which the government’s prior is \(V = V^* \equiv \epsilon^2\sigma^2 M(\bar\gamma)^{-1}\) and \(\sigma = \sigma_1\); then
{eq}`pp_riccati`gives … and{eq}`pp_kalman`reduces to … with gain \(\epsilon\)”) - the sentence that establishes the link to the previous lecture is the hardest one in the file to read. 40 is 39 words and four references; 438 is 40 words with a parenthesis nested inside an em-dash aside; 587 is 57 words ending in an appositive that names another lecture; 615 is 45 words. Splitting each at its semicolon or dash would cost nothing.
Medium severity#
[qe-code-001] (reviewer) — Follow PEP8 unless closer to mathematical notation. Count: 3. Lines: 267, 472, 560. Example: flake8 (90-character limit) finds two things in the whole file and both are real: 267 puts two statements on one line with a semicolon,
gp[j] += h; gm[j] -= h(E702), the only semicolon in the lecture; and 560 is 95 characters. The third item is a naming one a linter cannot see:effective_gain(467-472) returns(P @ Φ)[0] / (σ_govt**2 + Φ @ P @ Φ), the first component of the Kalman gain vector, under a name that promises the gain - the number printed at 476 and quoted at 479 (“multiplies the effective gain by more than twenty”) is the intercept’s gain, not the gain.gain_interceptwould say what it is. Otherwise the code matches the algebra unusually closely: Unicode Greek throughout (γ,σ1,σ2,ε,λ,Φ,Λabsent only because the drift is never simulated),γ_sce,M_sce,V_star,P_starall named after their symbols, and no long lines apart from 560.[qe-fig-003] — No matplotlib embedded titles. Count: 3. Lines: 372, 379, 564. Example: .set_title.
[qe-fig-004] — Caption formatting conventions. Count: 4. Lines: 307, 359, 390, 544. Example: caption of 10 words.
[qe-fig-008] — Use lw=2 for line charts. Count: 4. Lines: 329, 398, 656, 657. Example: plot() without lw=.
[qe-math-009] (reviewer) — Choose simplicity in mathematical notation. Count: 4. Lines: 419, 219, 187, 115. Example: four places where a symbol could simply be dropped. (1) \(Q(\bar\gamma, \bar P) = \hat V\) at 419 gives two new names to an object the lecture has called \(V\) for two hundred lines and the sentence itself calls “the prior itself”; 677 then uses \(\hat V\) again in the exercise. Writing \(V\) would be shorter and correct. (2) The gain is
\epsilonat 219 (three times, including \(V^* \equiv \epsilon^2 \sigma^2 M(\bar\gamma)^{-1}\)) and\varepsilonat 480 and 482 - the same parameter in two different glyphs, which render as visibly different characters, and the code calls itε(320) andε_common(474). (3) \(\Lambda_n\) is the drift innovation at 187 and \(\lambda\) is the prior-tightening parameter from 297 onward, so upper- and lower-case lambda name unrelated objects in one file;λin the code (314-326, 343, 650) is only ever the second. (4) 115 introduces \(\hat{\mathbb{E}}\) for the government’s subjective expectation, uses it once, and never explains the hat - the only decorated operator in a file that otherwise writes \(\mathbb{V}\) and \(\operatorname{cov}\) plainly (161, 189).[qe-writing-003] (reviewer) — Maintain logical flow. Count: 4. Lines: 419, 129, 541, 153. Example: (1) The section that carries the lecture’s cleanest result introduces two undefined symbols in one sentence. 419 reads “it is the eigenvector associated with the largest eigenvalue of the belief-innovation covariance \(Q(\bar\gamma, \bar P) = \hat V\) - the prior itself”: \(Q\) appears here and nowhere else in the file, \(\hat V\) appears only here and at 677, and neither is defined, so the reader cannot tell whether \(\hat V\) is \(V\), \(\sigma^{-2}V\) or something else - while the code two lines later simply uses
V_star(422). (2)StaticPhillips.__init__hard-codesself.σ = σ1with the comment# govt regression error std = σ1(129), i.e. the class asserts the government has the variance right - and the whole of §“Sims’s nonconvergence” (440-480) is about the case where it does not.effective_gainandsimulatetherefore take a separateσ_govtargument (467, 487) whileV_star(230),P_star(231) and everysolve_riccaticall outside them (325, 345, 652) keep usingmodel.σ. Nothing says whether the baseline prior is meant to be held fixed across the two specifications. (3) 541-542 says “Three seeds make the point without any cherry-picking: seed 0 never escapes, seed 4 escapes repeatedly and is pulled back each time, and seed 6 escapes and stays away for a long spell” - but the figure at 551-568 plots all three seeds in both panels, so it never says which specification each description belongs to, and the per-seed narrative sits awkwardly beside 538’s claim that under Sims’s misallocation “every path escapes”. (4) Belief 3 is named at 153 (“in a dynamic version, coefficients on current and lagged inflation summing to zero”) and never used again; the lecture is static throughout, as 59 says, so the third of the three “belief vectors worth naming” is content the reader has to carry and never spend.[qe-writing-004] — Avoid unnecessary capitalization in narrative text. Count: 1. Lines: 615. Example: mid-sentence ‘Inflation’.
[qe-writing-005] (reviewer) — Use bold for definitions, italic for emphasis. Count: 3. Lines: 289, 59, 338. Example: the file’s convention is clear and almost always followed - bold for definitions (mean dynamics and escape dynamics 50-51, learning cycle 55, prior about parameter drift 194, E-stability 275, stable limit cycle 295) and italic for emphasis (any 48, toward/away 50-51, unstable 55, forever 57, joint 238, general 287, typical/rare 409-411, right 448, too little 456, every 538) - which makes the three deviations stand out. 289 sets an emphatic negation in bold, “the \(P\) block does not decouple”, where 631 writes the identical construction in italic, “does not destabilize the self-confirming equilibrium”. 59 bolds the bare adjective static as emphasis and 90 then bolds static model as a definition, so the same term is bolded twice for two different reasons while 70, 159 and 487 leave it plain. And 338 introduces a named concept in italic - “what
{cite}`Bullard1994`calls a learning equilibrium” - which is a definition, not emphasis.[qe-writing-007] (reviewer) — Use visual elements to enhance understanding. Count: 3. Lines: 413, 336, 466. Example: the lecture draws its mean dynamics well and then stops drawing exactly where the geometry gets interesting. (1) §“Escape dynamics and the direction of escape” (413-438) is the section with the prettiest result - the escape direction is the dominant eigenvector of the prior - and its entire output is two
printlines (430-431). The figure is already half-built: 375-380 plots belief space with the self-confirming point markedkx, so adding the eigenvector as an arrow from \((2u, -1)\) to \((u, 0)\), with the Ramsey line \(b = 0\), would show the claim rather than assert it, and would let the exercise-2 comparison of two priors (699-702) be drawn on the same axes. (2) The Hopf bifurcation is described at 336-338 and split across two figures that are never combined: 307-333 plots the maximum real part against \(\lambda\), 359-383 plots one cycle at \(\lambda = 0.7\). The standard picture - cycle amplitude against \(\lambda\), going to zero at the bifurcation point - would join them and is a three-line loop over the existingsolve_ivpcall. (3) The mechanism at 456-464 (understating the error variance inflates the steady-state \(P\) and hence the gain) is quantified by exactly two printed numbers at 474-476; the effective gain plotted against \(\sigma\) over \([\,0.05, 0.5\,]\), with \(\sigma_1\) marked, would carry it in one panel.
Low severity#
[qe-fig-005] — Descriptive figure names for cross-referencing. Count: 1. Lines: 642. Example: code-cell figure without mystnb figure metadata.
Strengths#
The
{warning}at 100-113 is the single most useful block in the file: it records that the sibling lecture{doc}`phillips_escaping_nash`orders the belief vector the other way round, gives the exact translation (\(a = \gamma_{-1}\), \(b = \gamma_1\), \((2u,-1)\) here is \((-1, u(1+\theta^2))\) there with \(\theta = 1\)) and notes that \(M\), \(V\) and \(P\) transpose correspondingly - a coordinate clash between two lectures in the same suite, declared rather than left to bite.The self-confirming equilibrium is derived by hand in three lines (161-163: slope \(= \operatorname{cov}(U,\pi)/\mathbb{V}[\pi] = -1\), then \(a = u + x(\bar\gamma)\) with \(x = a/2\), so \(a = 2u\)) and then checked numerically in the next cell, where 171 prints
g_bar(γ_sce)to confirm it is zero.The link to the previous lecture is verified rather than asserted: 219 claims that the RLS prior \(V^* = \epsilon^2\sigma^2 M(\bar\gamma)^{-1}\) makes the Riccati solution \(P = \epsilon M(\bar\gamma)^{-1}\), and 233 prints
np.allclose(P_star, np.linalg.inv(M_sce))to check it.The closed-form Jacobian at
{eq}`pp_jacobian`(254-259) is immediately re-derived numerically by central differences (262-272), so the analytic matrix and the code agree in the output, and 283 then reads one eigenvalue off it (“one of them exactly \(-\tfrac12\), the marginal value that appeared in{doc}`phillips_learning`”).The lecture is careful about what kind of object a disinflation is, and says so in the place where a reader would otherwise conflate the two: 407-411 contrasts the new learning cycle with the escapes of the previous lecture in three sentences (“There, disinflations were rare events … Here the disinflations are a typical feature of the time series … a deterministic cycle that persists even as the gain shrinks to zero”).
The Sims puzzle is settled by an experiment designed to isolate one cause:
simulate(487-507) takesσ_govtas its only varying argument, 482-484 states the design (“holding \(\varepsilon\) fixed so that the only difference is the variance the government attributes to its own regression error”), and 509-528 then reports mean inflation and time near Ramsey for ten seeds in each specification rather than showing one path.The mechanism behind that result is given before the simulation, not after: 454-464 argues from the Riccati equation alone that a government understating its error variance must attribute the variation to coefficient drift, which inflates \(P\) and hence the gain - and 474-476 then measures the factor.
The conclusion goes past the paper being taught and reports the objection to it (591-607):
{cite}`Primiceri2006`and{cite}`Sargent2008`on implausibly volatile estimated beliefs, then{cite}`CarboniEllison2009`disciplining the prior with the Fed’s own Greenbook forecasts, with the punchline that shrinking \(V\) by orders of magnitude leaves the low-frequency story intact.Both exercises test the lecture’s own claims rather than adding new material - ppr_ex1 checks the asymmetry asserted at 438 (tightening the intercept prior does not destabilize), ppr_ex2 checks that the escape destination is robust to the prior’s scale but its route is not - and the solution at 705-714 states the result carefully in both directions.
Four of the five figure cells carry
mystnbcaption and name metadata (307-313, 359-365, 390-396, 544-550), which is why qe-fig-005 reports only the exercise-solution cell at 642.
Recommended actions#
Define or delete \(Q\) and \(\hat V\) at 419. Both appear without definition, the sentence itself says the object is “the prior”, and the code at 422 uses
V_star- sothe largest eigenvalue of the prior $V$says the same thing with no new notation. 677 needs the same edit.Say what the baseline prior means when \(\sigma \neq \sigma_1\).
self.σ = σ1is fixed in the constructor (129) whileV_star(230) andP_star(231) are built from it and then reused unchanged in the Sims experiments (470, 492), so the reader cannot tell whether the two specifications share a prior by design.Draw the escape direction in belief space. §“Escape dynamics” (413-438) currently outputs two printed vectors, and 375-380 already plots the \((a, b)\) plane with the self-confirming point marked - adding the eigenvector arrow from \((2u,-1)\) to \((u,0)\) and the line \(b = 0\) would make 434-436 visible, and would give exercise 2 (699-702) somewhere to plot its two priors.
Fix the seed narrative at 541-542: the figure below it plots all three seeds in both panels, so say which specification the per-seed descriptions refer to, or plot the three seeds only for \(\sigma = \sigma_1\) and summarise the Sims panel separately.
Settle the glyphs and the case:
\epsilonat 219 against\varepsilonat 480 and 482 for the same gain, and \(\Lambda_n\) (187) against \(\lambda\) (297 onward) for unrelated objects. Either drop \(\hat{\mathbb{E}}\) at 115 or explain the hat where it first appears.Move the three
set_titlecalls into the captions. 372 and 379 read “Figure 5a: coefficients cycle” and “Figure 5b: the limit cycle”, which name figures of the source paper inside a QuantEcon lecture where the numbering does not apply - the caption at 363 already covers both panels; and 564’s titles carry the two specifications, which belong in the caption at 548 or inax.annotate.Shorten the four captions qe-fig-004 flags for length (307, 359, 390, 544; the rule asks for 5-6 words): “Stability of the self-confirming equilibrium as the slope prior tightens” -> “stability as the slope prior tightens”; “Coefficients cycle, and the limit cycle in belief space” -> “the limit cycle in belief space”; “Inflation oscillates between Nash and Ramsey along the learning cycle” -> “inflation along the learning cycle”; “Escapes are rare under the correct error variance and pervasive under Sims’s misallocation” -> “escapes under two error variances”.
Split the five long sentences (219, 40, 438, 587, 615) - 219 in particular, which is 63 words and is the sentence that connects this lecture to
{doc}`phillips_learning`.Bold the definition at 338 (learning equilibrium), italicise the emphatic not at 289 to match 631, and pick one marking for the static model (static at 59, static model at 90, plain at 70, 159 and 487).
All ten qe-ref-001 hits are genuine and all ten want
{cite:t}: in every one of the eight lines (40, 57, 444, 446, 448, 587, 599, 668) the citation is a grammatical constituent of the sentence rather than a parenthetical aside - “It follows{cite}`SargentWilliams2005`, which generalizes … chapter 8 of{cite}`Sargent1999`” (40), “those of{cite}`Sargent1999`and CWS” (57, 446), “The simulations of{cite}`Sims1988`and{cite}`Chung1990`” (444), “{cite}`SargentWilliams2005`trace the difference” (448), “the empirical sequel{cite}`SargentWilliamsZha2006`shows” (587), “{cite}`CarboniEllison2009`answer the objection” (599) and “As{cite}`SargentWilliams2005`show” (668). Separately, three author names appear in prose with no citation at all and qe-ref-001 cannot see them: “the simulations of Sims and Chung” (57, cited properly 387 lines later at 444), “Arthur Goldberger and Robert Lucas” (583) and “Christopher Sims” (597).Code and figures: split the semicolon at 267, bring 560 under 90 characters, rename
effective_gainto say that it returns the intercept component (472), drop the five hand-setfigsizevalues (328, 366, 397, 553, 655 - only 366 and 553 are genuine multi-panel grids), addlw=2at 329, 398, 656 and 657, and add caption/name metadata to the exercise cell at 642.