cagan_rational_expectations#

  • Series: lecture-python-advanced.myst

  • File: lectures/cagan_rational_expectations.md

  • Audit date: 2026-08-26

  • Corpus snapshot: b83d6da399

  • Categories audited: writing, math, code, figures, references, links, admonitions (JAX out of scope)

  • Overall score: 6.9 / 10

  • Priority: HIGH

Score breakdown#

Category

Score

One-line note

Writing

5.5/10

qe-writing-005 ×3; qe-writing-003 ×4; qe-writing-002 ×4, +2 more.

Math

3/10

qe-math-010 (proposed) ×32; qe-math-002 ×5; qe-math-003 ×2, +1 more.

Code

6/10

qe-code-002 ×5; qe-code-001 ×8.

JAX

out of scope

JAX rules target lecture-jax.

Figures

5.5/10

qe-fig-006 ×2; qe-fig-004 ×2; qe-fig-003 ×1, +2 more.

References

8.5/10

qe-ref-001 ×2.

Links

10/10

no mechanical violations detected.

Admonitions

10/10

no mechanical violations detected.

Issues#

Critical#

None found.

High severity#

  • [qe-code-001] (reviewer) — Follow PEP8 unless closer to mathematical notation. Count: 8. Lines: 1108, 1136, 1199, 1301, 1436, 1631. Example: 1199 passes a non-raw string containing a LaTeX escape, ax.set_ylabel('det$(D_a(\lambda))$'), so \l is an invalid escape sequence and Python 3.12 emits a SyntaxWarning - every other label in the file is a raw string, including 1198 two lines above. 1136 and 1141 pad with two spaces before the operator to align assignments (x_prev  = 0.0), as do 1436-1438 (λ_ml   = [...]), which also pads after commas (α_se   = [4.62,  1.57,  2.97,  0.40, 10.74,  0.86]); PEP8 asks for a single space in both places. The continuation lines at 1301-1302 are indented 35 spaces against an opening parenthesis at column 34, so the visual indent is off by one. 1631-1633 write cxx[1]*np.conj(z) + cxx[0] + cxx[1]*z with no spaces around the multiplications, where the same lecture writes φ**2 * (1 + λ**2) * var_diff at 1575 - the rule reserves the tight form for a**b. And 1108-1109 mixes conventions inside one loop body: the lag of ε is named e_prev while the lag of η is named η_prev, four lines after both arrays were unpacked as ε, η at 1096.

  • [qe-code-002] — Use Unicode symbols for Greek letters in code. Count: 5. Lines: 431, 441, 445, 464, 1678. Example: spelled-out rho.

  • [qe-math-002] — Use \top for transpose notation. Count: 5. Lines: 761, 770, 944, 997. Example: apostrophe transpose a_t'.

  • [qe-math-010 (proposed)] — Blackboard \mathbb{P}, \mathbb{E}, \mathbb{V} with braces. Count: 32. Lines: 155, 158, 167, 169, 172, 195, 198, 205, 209, 225, …. Example: bare expectation E_t x_{t+1}.

Medium severity#

  • [qe-fig-001] — Do not set figure size unless necessary. Count: 2. Lines: 1440, 1476. Example: figsize=.

  • [qe-fig-003] — No matplotlib embedded titles. Count: 1. Lines: 1482. Example: .set_title.

  • [qe-fig-004] — Caption formatting conventions. Count: 2. Lines: 451, 1178. Example: caption of 7 words.

  • [qe-fig-006] — Lowercase axis labels. Count: 2. Lines: 473, 1683. Example: axis label True $\alpha$.

  • [qe-math-003] — Use square brackets for matrix notation. Count: 2. Lines: 632, 1037. Example: pmatrix environment.

  • [qe-math-009] (reviewer) — Choose simplicity in mathematical notation. Count: 3. Lines: 529, 717, 768. Example: \(L\) carries two meanings. It is introduced at 148-149 as the lag operator (“\(L\) is the lag operator defined by \(L^n x_t = x_{t-n}\)”) and used that way in roughly thirty displays through 1239, and it is also the likelihood function at 768, 1022, 1025 and 1365 - so \log L at 1022, three lines after (1-\lambda L), asks the reader to switch meaning inside the same argument; \(\mathcal L\) or \(\ell\) for the likelihood costs nothing here. Separately the fraction and spacing commands are chosen three different ways for no reason the reader can see: \dfrac at 529-530 and 655-656, \tfrac at 717 and 770, plain \frac in every other display, with thirteen manual \! thin-space corrections (169, 171, 195, 197, 297, 770, 830, 846, 849, 995, 997, 1078, 1365) and hand-set row spacing \\[4pt], \\[8pt], \\[10pt] at 529, 655, 958 and 1010-1013. Picking \frac throughout and dropping the tuning would leave the same mathematics with less to maintain.

  • [qe-ref-001] — Use correct citation style. Count: 2. Lines: 739, 1030. Example: {cite} in author position: ‘{cite}`sims1972money` proved’.

  • [qe-writing-002] (reviewer) — Keep writing clear, concise, and valuable. Count: 4. Lines: 50, 745, 809, 874. Example: 809-813 is a 50-word sentence with two em-dash asides that has to hold four parameters and five parameters in the air at once (“On the basis of the four parameters \(\lambda\), \(\sigma_{11}\), \(\sigma_{12}\), and \(\sigma_{22}\) that are identified by {eq}`eq27` – i.e., that characterize the likelihood function {eq}`eq32` – we can think of attempting to estimate the five parameters of the model: …”). 48-52 is another 50 words carrying the paradox that motivates the lecture, with a nested “– and often very much less –” between subject and verb. 744-748 is 45 words with two inline column vectors embedded in it. And 872-878 asks the same question twice in consecutive paragraphs: “Do there exist offsetting changes in \(\alpha\) and \(\sigma_{\varepsilon\eta}\) that leave both {eq}`eq37` and {eq}`eq38` satisfied with \(\sigma_{11}\), \(\sigma_{22}\), and \(\sigma_{12}\) unchanged?” then “That is, holding \(\lambda\) and \(\sigma_\varepsilon^2\) constant, can we change \(\alpha\) and \(\sigma_{\varepsilon\eta}\) in offsetting ways that leave \(\sigma_{11}\), \(\sigma_{12}\), and \(\sigma_{22}\) constant?” - the restatement adds nothing the first sentence did not say. 1401 does the same on a smaller scale, following “Hungary I is the only case in which \(\alpha\) is estimated with much precision” (1398) with “Hungary I is the standout case.”.

  • [qe-writing-003] (reviewer) — Maintain logical flow. Count: 4. Lines: 59, 733, 1539, 1541. Example: Table 1 (57-75) is the lecture’s motivation and it does not reconcile with itself. Column (1) is \(-1/\alpha\) and column (2) is headed \((e^{1/\alpha}-1)\times 100\), but with \(\alpha < 0\) that expression is negative while every entry in the column is positive - the entries are in fact \((e^{-1/\alpha}-1)\times 100\), i.e. the exponential of column (1), so the header and the bullet that repeats it at 72 both carry the wrong sign. On those entries six of the seven rows check out (Austria .117 gives 12.4, Germany .183 gives 20.1, Greece .244 gives 27.6, Hungary I .115 gives 12.2, Poland .435 gives 54.5, Russia .327 gives 38.7) and Hungary II does not: .236 gives 26.6, not the 32 shown. Second, the four footnote definitions at 733-739 are dropped into the body of the “Consistent estimator” section, between the Granger-causality paragraph at 730-731 and the resumption of the maximum-likelihood argument at 741, so a continuous derivation is interrupted by four unrelated notes. Third, the Exercises section (1537) opens not with an exercise but with two paragraphs and a 45-line function definition (1543-1589), and the promise made at 1541 - “We will use these moments to evaluate the bias in Cagan’s estimator and to construct a consistent estimator” - is not kept: the bias was already treated at 337-484 and the consistent estimator at 487-1209, and the only use of bivariate_ma1_moments is the positive-semidefiniteness check at 1610-1641.

  • [qe-writing-005] (reviewer) — Use bold for definitions, italic for emphasis. Count: 3. Lines: 103, 149, 365. Example: bold is never used in this lecture - there is not one ** span in 1739 lines - so the division of labour the rule asks for is not in place: every term the lecture introduces is left unmarked, including the lag operator at 149, the triangular bivariate Wold representation at 365, the fundamental noises at 375, the innovations at 643-645, and \(D_a\) at 756. Italic, meanwhile, is used thirteen times, correctly for emphasis (99 leading, 405 consistent, 809 four, 811 five, 1342 seven linear restrictions, 1498 single free parameter, 1508 inconsistent, 1515 not identifiable, 1532 not) but at 103 for a term that is being introduced - “invariance with respect to an intervention”, the concept the whole note at 91-104 exists to name - which the rule assigns to bold.

  • [qe-writing-007] (reviewer) — Use visual elements to enhance understanding. Count: 3. Lines: 57, 728, 872. Example: the lecture plots Table 2 and Table 3 (the two code cells at 1428-1489) but not Table 1 (57-75), which is the table the whole paper is about: the paradox is that column (2), the revenue-maximising inflation rate implied by Cagan’s \(\hat\alpha\), sits far below column (3), the actual average inflation - 12 against 47 for Austria, 20 against 322 for Germany, 32 against 19,800 for Hungary II - and one grouped bar chart on a log scale would carry that gap at a glance instead of asking the reader to compare two columns of a seven-row table. Second, the identification argument at 872-925 is the least intuitive claim in the lecture (offsetting movements in \(\alpha\) and \(\sigma_{\varepsilon\eta}\) leave \(\sigma_{11}, \sigma_{12}, \sigma_{22}\) and hence the likelihood unchanged) and it is carried entirely by two differentials at 884-900; a contour plot of mle_criterion (1150) over the \((\alpha, \sigma_{\varepsilon\eta})\) plane would show the flat ridge directly, and both functions needed already exist. Third, 728 asserts “Their cross-spectrum has zero phase at all frequencies” and shows nothing, although the exercise solution at 1627-1640 already assembles \(S(\omega)\) on a 50-point grid and uses it only for an eigenvalue check.

Low severity#

  • [qe-fig-005] — Descriptive figure names for cross-referencing. Count: 1. Lines: 1669. Example: code-cell figure without mystnb figure metadata.

  • [qe-writing-008] — Remove excessive whitespace between words. Count: 1. Lines: 82. Example: 2 spaces.

Strengths#

  • The algebra from the structural model to the estimable VAR is done in full, one substitution at a time, and every step says what it is doing: 501-521 solves for \(\varepsilon_t\) and \(\eta_t\), 523-533 stacks them, 535 multiplies through by \((1-\lambda L)I\), 568-576 names \(G_0\), 578-587 gives \(G_0^{-1}\) explicitly, and 605-615 lands on {eq}`eq26` - so a reader can reproduce the derivation without going to the paper.

  • The one fact that makes the estimator computable is isolated and then stated twice where it matters: 801-806 observes that \(\alpha\) does not appear in the likelihood except through \(D_a\), and 1070-1072 repeats it as the reason the innovation recursions {eq}`eq:a1_recursion`-{eq}`eq:a2_recursion` need only \(\lambda\) - which is exactly what compute_innovations (1119) implements and what its docstring at 1127 records.

  • Non-identification is proved rather than asserted: 853-870 reduces {eq}`eq34`-{eq}`eq36` to the two relations {eq}`eq37`-{eq}`eq38`, 884-900 differentiates them under \(d\lambda = d\sigma_\varepsilon^2 = 0\), and 902-904 notes that {eq}`eq40` is just \(2(1-\lambda)\) times {eq}`eq39`, which is the whole content of the claim.

  • Each computational cell is preceded by one sentence saying what it computes and which equation it implements - 428 for {eq}`eq:rho` and {eq}`eq:plim_alpha`, 1083 for {eq}`eq11`-{eq}`eq12`, 1116 for the innovation recursions, 1147 for {eq}`eq:mle_criterion`, 1285 for the first-stage Monte Carlo - and each is followed by one sentence reading the result off the figure (480-484, 1207-1209, 1320-1321).

  • The empirical section keeps the paradox in view instead of stopping at the estimates: 1395-1410 reads Table 2 as “how loose the estimates of \(\alpha\) become”, identifies Hungary I as the one case estimated with precision, works out that \(-1/\hat\alpha = 54\) percent against an observed 46 percent, and then says plainly that for the other countries only the two-standard-error bands rescue the paradox.

  • The three exercises each extend the machinery rather than rehearse it - a positive-semidefiniteness check on the spectral density built from bivariate_ma1_moments (1595-1601), the bias as a function of \(\alpha\) for three \(\lambda\)’s against the Wallace-Sargent value (1650-1656), and a \(T = 100\) against \(T = 500\) comparison that recovers the \(1/\sqrt{T}\) rate (1702-1711) - and all three reuse functions defined earlier in the lecture.