phillips_drifts_volatilities#
Series: lecture-python.myst
File:
lectures/phillips_drifts_volatilities.mdAudit date: 2026-08-26
Corpus snapshot:
e25fdf2345Categories audited: writing, math, code, figures, references, links, admonitions (JAX out of scope)
Overall score: 7.9 / 10
Priority: HIGH
Score breakdown#
Category |
Score |
One-line note |
|---|---|---|
Writing |
3.5/10 |
|
Math |
9.5/10 |
|
Code |
8/10 |
|
JAX |
out of scope |
JAX rules target |
Figures |
4.5/10 |
|
References |
10/10 |
no mechanical violations detected. |
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: 13. Lines: 422, 1255, 1397, 1758, 1828, 2028, 2342, 2543, 2650, 2858, …. Example: figsize=.
[qe-fig-004] — Caption formatting conventions. Count: 11. Lines: 410, 1384, 1821, 2134, 2335, 2503, 2536, 2643, 2760, 2851, …. Example: caption of 7 words.
[qe-writing-002] (reviewer) — Keep writing clear, concise, and valuable. Count: 5. Lines: 575, 900, 1485, 2880, 3234. Example: the second half of the lecture (2181-3245) re-runs the first half section for section, and it re-states the first half’s caveats in near-identical words rather than referring back: 1854-1855 “The solid curves are posterior medians, and the shaded regions are pointwise 90 percent intervals rather than simultaneous bands for entire paths” against 2880-2881 “The solid lines are posterior medians, and the shaded regions are pointwise 90 percent intervals rather than simultaneous whole-path bands”; 1204-1205 against 2527-2528; 1657-1658 against 2927-2928; 2014-2015 against 3116-3117. The summary section then says one thing twice in consecutive paragraphs - 3234-3235 “adds a dramatic volatility episode without a post-2000 low-frequency ridge comparable to the 1970s” and 3237-3238 “the recent inflation surge does not reproduce the 1970s low-frequency persistence ridge”. Roughly fifteen result paragraphs are each followed by a standalone disclaimer sentence (1207-1208, 1424-1426, 1454-1455, 1572-1574, 1713-1715, 1892-1894, 1896-1897, 2049-2050, 2052-2053, 2177-2178, 2692-2694, 3055-3056, 3150-3151, 3228-3230), which is honest but by the tenth repetition costs more words than it adds. On individual sentences: 900-903 is 38 words and carries the sampler’s validity argument; 1485-1488 is 37 words defining two objects and denying two others in one breath; 3228-3230 joins an unrelated plotting note and an unrelated policy caveat with “and”. 575-576 is not long but is unclear - “But in this case only stable sweeps contribute realizations to the retained restricted-posterior sample” opens with “But” and does not say what case, in the middle of the passage that explains the lecture’s one methodological departure. 158 is a comma splice inside parentheses.
[qe-writing-006] — Capitalize lecture titles properly. Count: 1. Lines: 2577. Example: H3 Title Case: ‘Volatility after the Great Moderation’ (Moderation).
Medium severity#
[qe-code-001] (reviewer) — Follow PEP8 unless closer to mathematical notation. Count: 3. Lines: 102, 371, 1642. Example: the code is unusually clean - flake8 with
--select=E1,E2,E5,E7,W2,W3,W6 --max-line-length=79over every code cell reports only three items in 3,413 lines. 371 writesraw_y[n_lags-lag:-lag]with no spaces around the subtraction on the same line asleft:left + n_variables, which does space it (E226). 102 is 86 characters (E501) and 996, insiderun_sampler’s docstring, is 80. Two cells also end with a blank line before the closing fence (1642, 2217). Nothing else: naming is consistent, Unicode Greek is used throughout, and**is written without spaces at 791 and 834.[qe-code-004] — Use quantecon Timer context manager. Count: 3. Lines: 1008, 1081, 1115. Example: time.perf_counter(.
[qe-fig-003] — No matplotlib embedded titles. Count: 4. Lines: 1402, 1406, 2669, 2671. Example: .set_title.
[qe-math-009] (reviewer) — Choose simplicity in mathematical notation. Count: 4. Lines: 229, 1611, 1923, 1983. Example: the stability indicator is written two ways and one of them collides with the identity matrix: 229, 232 and 453 write \(I(\theta^T)\) and \(I(\theta_0)\), while 893 and 946 write \(\mathbb{1}_{\mathcal A}(z)\) for the same indicator - and \(I\) is simultaneously the identity in \(I_3\) (166, 268) and in \((I-A_{t\mid T})^{-1}\) (1471, 1610). \(\mathcal A\) then does double duty too: it is the set of stable coefficient paths at 887-946 and the activism coefficient \(\mathcal A_t=\beta_1/(1-\beta_3)\) at 1923-1924, 1990 and 2138, with \(A_{t\mid T}\) the companion matrix (1462, 1471, 1610) - three different objects on one letter. \(\mathcal R_t\) at 1611 is introduced only to say at 1616 that it “embeds \(\mathbb{E}(R_t\mid T)\) in the companion system”, which a plain \(R_t^{(6)}\) or a sentence would do without a second alphabet. \(\mathcal{M}_t\) (1983 and twelve further sites) decorates a scalar the code simply calls
policy_margin(1975) and'median M'(3181). And the trace operator is spelled three ways for one object -\operatorname{tr}in prose and captions (1178, 1280, 1187, 2507),\mathrm{tr}in the plotting code (1194, 1195, 2516, 2518), baretr(Q)in a table label (2474).[qe-writing-003] (reviewer) — Maintain logical flow. Count: 4. Lines: 1892, 2226, 2465, 3299. Example: numbers that describe live downloaded data are hard-coded into the prose, and the lecture’s own text says they should not be. 2224-2226 states the convention - the updated sample ends “at the last quarter whose three monthly unemployment readings are all present, detected automatically rather than hard-coded” - and the code honours it, storing the endpoint in
updated_label(2481) and using it as a table name at 2400, 2825 and 3187. The prose and captions then hard-code that endpoint twenty times: eleven figure captions (2339, 2507, 2540, 2647, 2700, 2764, 2855, 2934, 2963, 3017, 3100, 3123, 3196), six prose sentences (2226, 2416, 2752, 2808, 2914, 3153) and one code label (3067'2023--2025Q3'), so the first FRED release after 2025Q4 makes every one of them wrong. Same class: 1892 asserts “Their quarterly correlation of 0.909” for a quantity the figure cell at 1874-1876 computes intocore_persistence_correlationand then never displays - the variable is dead and the number is a transcription - where the parallel case at 1580-1582 does displaycore_natural_correlationand 1585 describes it in words. 2405 and 2803 give the pandemic unemployment spike as “13.0 percent” and 2806 adds “The monthly peak was 14.8 percent”, both from live FRED series and neither printed anywhere. Separately, 2465 “### Did coefficient drift continue?” is the only section in the lecture that opens straight into a code cell (2467) with no sentence between heading and code. And csdv_ex1 (3296-3306) asks the reader to compute \(g(0)\) for \(\rho=0,0.85,0.97\), which 1717-1721 already answers in the body (“Values between 2 and 10 correspond to \(\rho\) between approximately \(0.85\) and \(0.97\)”) and the solution at 3319-3321 then restates in the same words.[qe-writing-004] — Avoid unnecessary capitalization in narrative text. Count: 4. Lines: 67, 107, 1781, 3323. Example: mid-sentence ‘Inflation’.
[qe-writing-005] (reviewer) — Use bold for definitions, italic for emphasis. Count: 4. Lines: 74, 1491, 1923, 3253. Example: bold is used for definitions exactly twice - companion matrix and companion form at 174-175 - and every other term the lecture introduces is either italicised or left plain. 73-74 sets a twenty-word clause in italic as the definition of the model (“a Bayesian vector autoregression whose coefficients drift as random walks and whose shock variances evolve as stochastic volatilities”); 1491 italicises anticipated-utility on first use as a named device; and the activism coefficient (1923), the policy margin (1982-1983), core inflation and the natural rate (1485-1488), and the sweep (569) are all defined in plain text. 110 and 123 do bold bad policy and bad luck, which reads as emphasis on the two views rather than definition, and the same two terms are then set in plain text everywhere afterwards (1424, 2692, 3253-3254, 3334). The verdict’s three bullets at 3253, 3257 and 3262 use italic run-in labels (“Volatilities drifted:”), which are neither emphasis nor definitions - they are headings.
[qe-writing-007] (reviewer) — Use visual elements to enhance understanding. Count: 3. Lines: 909, 1111, 2220. Example: the lecture draws nineteen figures and none of them is about the sampler. Its one departure from
{cite:t}`CogleySargent2005`is the elliptical slice update, explained in nine consecutive prose paragraphs (909-947) around the ellipse \(z(\phi)=m+(z^{(c)}-m)\cos\phi+\nu\sin\phi\) at 916-920 - a single 2-D sketch of that ellipse through \(z^{(c)}\) and \(\widetilde z\) with the stable arc shaded would carry the whole argument, including why the bracket search at 924-930 terminates. Second, the sampler already records exactly the diagnostics that would make the honesty at 1125-1130 (“This short run illustrates the method but not a numerical replication”) checkable -slice_contractions,mean_slice_contractions,maximum_slice_contractions,retained_stability_rate,elapsed_secondsat 1111-1116 - and not one of them is ever printed or plotted, nor is any trace plot or autocorrelation shown, in a lecture whose subject is an MCMC sampler run for 1,000 sweeps. Third, the lecture contains no admonition of any kind: the two things a reader most needs to see - that caveat at 1125-1130, and the missing-October-2025 unemployment reading that silently sets the sample endpoint (2220-2226) - are plain paragraphs, and the second is elaborated in a six-line code comment at 2264-2269 where a{note}in the prose would put it in front of the reader.
Low severity#
[qe-fig-005] — Descriptive figure names for cross-referencing. Count: 1. Lines: 3358. Example: code-cell figure without mystnb figure metadata.
Strengths#
The lecture asks one question in italics at 67-68 (‘Was the Great Inflation of the 1970s and its conquest in the 1980s a story of bad policy, or of bad luck?’), builds the model expressly so that both answers are representable (138-146), and answers it in a named section (3248) whose three bullets each say which channel the evidence supports - then declines to overclaim at 3266-3268.
Each of the five sampler blocks named in the prose list at 583-597 has a function of its own with a matching name -
draw_coefficient_path(624),draw_q(749),draw_σ(787),draw_β(796),draw_volatility_path(828) -run_sampler(977) composes them in the same order, and 599-600 says why the order is not arbitrary.The one place where the lecture departs from
{cite:t}`CogleySargent2005`is declared rather than substituted quietly: 572-581 states that the paper used rejection sampling and that this lecture imposes stability inside the block with the elliptical slice sampler of{cite:t}`MurrayAdamsMacKay2010`, 905-910 quantifies the \(1/a\) cost of the alternative, and 935-947 gives the invariance argument for the replacement.Uncertainty is computed rather than asserted: 1785-1787 says why point estimates are not enough,
posterior_feature_draws(1790-1818) recomputes all three nonlinear features draw by draw, 1828-1851 plots medians with 90 percent bands, and 1854-1855 states that the bands are pointwise and not simultaneous.The numerical claims are checked inside the lecture:
assert is_stable(θ_bar)at 477 tests the prior mean before the sampler starts,validate_posterior_arrays(1146-1166) asserts the shape, finiteness, positivity and stability of every retained array, and 1221, 1441, 2100, 2424-2425, 2461, 2590-2591 and 3177 each assert the property the following figure or table depends on.The data splice is made auditable instead of trusted:
splice_audit(2300-2311) puts the archived 2000Q4 observation, the latest revised 2000Q4 observation, their difference and the first appended quarter in one table; 2326 states that no missing value is filled; and 2331-2333 explains that no log difference ever straddles two data releases.csdv_ex2 (3329-3348) is exactly the experiment the body says four times is missing (1204-1205, 1899-1900, 2527-2528, 3241-3242), the sampler was written to support it (
fixed_qat 988 and 1021-1025), and the solution at 3392-3410 reports a result that partly cuts against the body’s reading - drifting volatility alone can manufacture much of the pre-1980 rise in persistence but none of the post-1980 fall.Distribution names follow qe-math-011 (proposed) without exception - plain
N(0,Q)(210),N(0,I_3)(268),N(0,1)(312),N(m,C)(884),IW_{21}(484),IG(511) - and every displayed equation that is later cited carries a label:csdv_measurement(163),csdv_transition(207),csdv_stability(228),csdv_covariance(265, cited at 1351),csdv_volatility(309),csdv_q_prior(483, cited at 493),csdv_local_means(1470),csdv_spectrum(1605),csdv_normalized_spectrum(1648),csdv_policy_rule(1915).
Recommended actions#
Print the sample endpoint instead of writing it: the code already computes
updated_label(2481) and 2224-2226 promises the endpoint is ‘detected automatically rather than hard-coded’, yet ‘2025Q3’ is typed into eleven captions (2339, 2507, 2540, 2647, 2700, 2764, 2855, 2934, 2963, 3017, 3100, 3123, 3196), six sentences (2226, 2416, 2752, 2808, 2914, 3153) and one code label (3067) - all of which go stale on the next FRED release.Replace the four hard-coded data-dependent numbers with printed values: the correlation ‘0.909’ at 1892 (the figure cell at 1874-1876 already computes it into
core_persistence_correlationand then discards it), ‘13.0 percent’ at 2405 and 2803, and ‘14.8 percent’ at 2806.Do NOT ‘fix’ the six flagged capitalisations: all four qe-writing-004 hits (67, 107, 1781, 3323) are ‘Great Inflation’ and both qe-writing-006 hits are proper nouns - ‘A Metropolis-within-Gibbs sampler’ (564) is two surnames and ‘Volatility after the Great Moderation’ (2577) names the era the lecture cites
{cite:t}`KimNelson1999`for at 1452. Likewise the four qe-code-002 hits are not code at all (see scanner_doubts). Lower-casing any of them would make the lecture wrong.Give \(\mathcal A\) back to one object: it is the set of stable paths at 887-946 and the activism coefficient at 1923-1924, 1990 and 2138, with \(A_{t\mid T}\) the companion matrix - and settle the stability indicator on one notation, since \(I(\theta^T)\) at 229/232/453 and \(\mathbb{1}_{\mathcal A}\) at 893/946 are the same function and the first collides with the identity matrix at 166, 268 and 1471.
Show one sampler diagnostic.
run_sampleralready returnsslice_contractions,mean_slice_contractions,maximum_slice_contractions,retained_stability_rateandelapsed_seconds(1111-1116) and none is displayed; a trace plot of \(\operatorname{tr}(Q)\) across the 500 retained sweeps next to the histogram at 1183-1199 would let the reader judge the caveat at 1125-1130 instead of taking it on trust.Cut the duplicated caveats in the second half by referring back: 2880-2881, 2527-2528, 2927-2928 and 3116-3117 restate 1854-1855, 1204-1205, 1657-1658 and 2014-2015 almost verbatim, and 3237-3238 repeats 3234-3235. Then split the two 37-38 word sentences at 900-903 and 1485-1488, rewrite 575-576, and fix the comma splice at 158.
Bold the definitions the lecture leaves unmarked - the activism coefficient (1923), the policy margin (1982-1983), core inflation and the natural rate (1485-1488), a sweep (569) - un-italicise the twenty-word model definition at 73-74, and promote the italic run-in labels at 3253, 3257 and 3262 to real list emphasis or headings.
Sweep the mechanical items: the thirteen
figsizeoverrides (qe-fig-001), the eleven over-long captions (qe-fig-004), the fourset_titlecalls at 1402, 1406, 2669 and 2671 plus the two that smuggle a panel title into an axis label (set_ylabel(f'{title}\ncycles per quarter')at 1771 and 3044), the missingmystnbmetadata on the solution figure at 3358 (qe-fig-005), the threetime.perf_counter()sites at 1008, 1081 and 1115 (qe-code-004 - usequantecon.Timer), the E226 at 371, the long lines at 102 and 996, the trailing blank cell lines at 1642 and 2217, the trailing whitespace at 1173 and 1304, and the eight captions and two axis labels that write bareE(...)where the prose writes\mathbb{E}(...)(1214, 1388, 1437, 1445, 2540, 2647, 2700, 2711).