rational_expectations#

  • Series: lecture-python.myst

  • File: lectures/rational_expectations.md

  • Audit date: 2026-08-26

  • Corpus snapshot: e25fdf2345

  • Categories 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

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

Math

5/10

qe-math-002 ×14; qe-math-009 ×4.

Code

7.5/10

qe-code-001 ×5.

JAX

out of scope

JAX rules target lecture-jax.

Figures

10/10

no mechanical violations detected.

References

9/10

qe-ref-001 ×1.

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: 5. Lines: 795, 684, 686, 685, 693. Example: flake8 finds one thing (E226 at 685, a1/2 and a0/2 tight inside a list literal, where the same matrix at 879 is written a1 / 2, -a0 / 2), and the rest is what a linter cannot see. 795 is a bug: print('f(h0, h1, h2) = {h0}, {h1}, {h2}') puts the f inside the quotes, so the line prints the literal text f(h0, h1, h2) = {h0}, {h1}, {h2} - and it sits directly under 794, which is a correct f-string. 684 sets a shape by assignment, B.shape = 3, 1, where the two later cells build the same object properly (B = np.array([[1], [0]]) at 878 and 940). 686, 880 and 942 write the same quantity three ways - Q = 0.5 * γ, Q = γ / 2, Q = γ / 2 - against \(Q = \gamma/2\) in the algebra at 640 and 855. And 693-698 routes two f-strings through out1 and out2 before printing them, where 794 prints directly. Separately, the cell language is ipython in the three setup cells (33, 69, 76) and python3 in the four solution cells (667, 776, 874, 938).

  • [qe-math-002] — Use \top for transpose notation. Count: 14. Lines: 502, 503, 511, 517, 645, 860. Example: apostrophe transpose Y'.

  • [qe-writing-002] (reviewer) — Keep writing clear, concise, and valuable. Count: 5. Lines: 49, 973, 800, 258, 233. Example: five sentences are broken as written. 49 loses its parenthesis and its number agreement at once: “a setting that is readily “Bellmanized” (i.e., susceptible to being formulated as a dynamic programming problems.” - the opening bracket is never closed and “a … problems” does not agree. The footnote at 973-981 is three sentences in one paragraph (the file’s only qe-writing-001 hit) and its last sentence has no main verb: “conditions under which collections of adaptive agents who use least squares learning to converge to a rational expectations equilibrium”. 800 says “the answer is pair (iii)” where the candidates at 741-743 are an unnumbered bullet list, so there is no pair (iii) to point at. 258 (“While it faces no uncertainty, it does face adjustment costs”) has no full stop. And “equilibrium” is misspelled twice - “Competitive Equilbrium” in the {index} entry at 233 and “in equilbrium” at 395.

  • [qe-writing-006] — Capitalize lecture titles properly. Count: 1. Lines: 202. Example: H3 Title Case: ‘Further Reading’ (Reading).

  • [qe-writing-008] — Remove excessive whitespace between words. Count: 30. Lines: 44, 49, 53, 86, 103, 104, 108, 112, 180, 215, …. Example: 2 spaces.

Medium severity#

  • [qe-math-009] (reviewer) — Choose simplicity in mathematical notation. Count: 4. Lines: 503, 343, 976, 90. Example: four small notational inconsistencies, each a choice between two forms where the file already uses both. (1) 503 writes the quadratic term as {a_1 \over 2} Y^2 - plain-TeX \over - while every other fraction in the lecture is \frac, including the one three characters later in the same display (\frac{\gamma (Y' - Y)^2}{2}) and at 273, 327, 344, 479 and 906. (2) 343 hand-sets \textrm{argmax} where the series provides an \argmax macro (lectures/_config.yml:110), so the operator is upright but not spaced as an operator. (3) \(\gamma\) is the adjustment-cost parameter throughout (273, 280, 327, 376, 479) and then, in the footnote at 976-977, the relaxation parameter of the modified mapping \(\gamma\Phi + (1-\gamma)I\) - two meanings, one of them introduced with the words “\(\gamma \in (0,1)\) is a relaxation parameter” directly under a lecture in which \(\gamma = 10\). (4) The differential is spelled three ways: d \, \omega (90, 92), d \omega (127, 251, 296) and d\omega (720-721). Related: \(s\) is the integration variable in \(\int_0^Y (a_0 - a_1 s)\,ds\) (183) and the surplus function \(s(Y_t, Y_{t+1})\) at 478, and \(x\) is the integration variable at 479 and the LQ state vector at 616.

  • [qe-writing-001] — Use one sentence per paragraph. Count: 1. Lines: 973. Example: 3 sentences in one paragraph.

  • [qe-writing-003] (reviewer) — Maintain logical flow. Count: 4. Lines: 236, 183, 202, 314. Example: (1) The lecture cannot decide whether there are \(n\) firms or a unit measure of them, and the two conventions are interleaved. 86 and 127 set a unit measure, \(\Omega = [0,1]\) and \(Y = \int_0^1 y(\omega)d\omega\); 152 then warns the reader “not to set \(Y = n y\)” with \(n\) undefined; 236 opens the dynamic model with “a collection of \(n\) firms” and 251 immediately writes \(Y_t = \int_0^1 y_t(\omega)d\omega = y_t\); the exercise-1 solution works “the case \(n > 1\)” at 707-714 and “the case of a unit measure” at 716-725, giving two different answers; and 761-765 writes the aggregate law as \(Y_{t+1} = n h(Y_t/n, Y_t)\) before saying “we can use \(Y_t = n y_t = y_t\)”, which quietly sets \(n = 1\). (2) 183 mistypes the consumer-surplus formula as \(a_o Y - \frac{a_1}{2}Y^2\) - a letter o where the subscript zero belongs - in the display that {eq}`staticY` is derived from three lines later. (3) §“Further Reading” (202-208) is an H3 sitting inside the Overview, between the static example and the model, so the reader meets the reading list before meeting the problem; it belongs at the end. (4) 314 introduces \(Y^e_{t+1}\) for perceived output and never uses it again.

  • [qe-writing-005] (reviewer) — Use bold for definitions, italic for emphasis. Count: 4. Lines: 42, 56, 82, 977. Example: the file bolds most of its definitions - representative firm (82), consumer surplus (180), belief function (312), Euler equation (371), transversality condition (384), actual law of motion (395), rational expectations equilibrium and recursive competitive equilibrium (409), planning problem (484) - but three of its central terms are marked twice, differently. rational expectations equilibrium is italic where it is first named (42, “This lecture introduces the concept of a rational expectations equilibrium”) and bold where it is defined (409). perceived law of motion and actual law of motion are italic at 56 and the second is bold at 395. And representative firm is bold at 82 in a sentence that puts the companion term in quotation marks (is a "price taker"), which 148 then sets in italic (we want the firm to be a *price taker*) - three markings, no bold. 977 introduces the relaxation parameter in italic, which is a definition.

  • [qe-writing-007] (reviewer) — Use visual elements to enhance understanding. Count: 4. Lines: 70, 418, 741, 952. Example: a 981-line lecture built around a fixed point, with import matplotlib.pyplot as plt at 70 and not one plt. call anywhere in the file - the Figures category scores 10/10 because there is nothing to check. Four places pay for it. (1) The mapping \(\Phi\) from a perceived law of motion to an actual one (418-424) is the concept the lecture exists to teach, and §“Failure of contractivity” (433-447) argues that \(\Phi\) reverses the ordering of beliefs - “suppose there are two beliefs with \(H_a(Y) > H_b(Y)\) for every \(Y\)\(\Phi\) reverses the ordering” - which is one 45-degree diagram of \(\kappa_1 \mapsto \Phi(\kappa)_1\) with two iterates marked, and is left entirely to prose. (2) Exercise 2 tests three candidate \((\kappa_0, \kappa_1)\) pairs (741-743) and the solution reports only which one passes np.allclose (793-800); the residual \(h_0 + h_1 + h_2 - \kappa_1\) plotted over a \(\kappa_1\) grid would show that the equilibrium is a crossing and would connect directly to the order reversal of 445. (3) Exercise 4’s conclusion is handed to the reader as arithmetic homework - “If you crunch the numbers, you will see that the monopolist adopts a lower long-run quantity” (964-966) - when the two laws of motion it just computed, \(Y_{t+1} = 73.4729 + 0.9265 Y_t\) and \(Y_{t+1} = 95.0818 + 0.9525 Y_t\), drawn against the 45-degree line, would put both fixed points on one axes. (4) The static example of 110-176, where the whole Big-\(Y\)-little-\(y\) trick is introduced, has an inverse demand curve, a cost curve, consumer surplus as “the area under the inverse demand curve” (180) and a planning problem (190-198) - four objects that live naturally in a single supply-and-demand picture that is never drawn.

Low severity#

  • [qe-ref-001] — Use correct citation style. Count: 1. Lines: 978. Example: {cite} in narrative flow: ‘and {cite}’.

Strengths#

  • The Big \(Y\), little \(y\) trick is taught twice, once in a static model where the whole argument fits in twenty lines (110-176) and then in the dynamic one, and both times the lecture says exactly where the substitution must not happen: “The essence of the Big \(Y\), little \(y\) trick is not to set \(Y = n y\) before taking the first-order condition” (152-153), then “At this point, but not before, we substitute \(Y = y\)” (165).

  • The equivalence at the heart of the lecture is verified rather than asserted, and in two independent ways: 529-543 shows by hand that the planner’s Euler equation {eq}`comp16` and the firm’s {eq}`ree_comp7` are the same difference equation once \(y_t = Y_t\) and \(H(Y_t) = Y_{t+1}\) are imposed, and then exercise 3 computes \((\kappa_0, \kappa_1)\) from the planner’s LQ problem (874-891) and gets the pair that exercise 2 identified as the equilibrium from the firm’s problem (777-797).

  • The failure of contractivity is explained by a mechanism rather than waved at: 443-447 supposes two ordered beliefs, notes that by the Euler equation the actual law decreases as \(H\) increases, and concludes that \(\Phi\) reverses the ordering so Blackwell’s monotonicity fails - three sentences that say why the obvious algorithm is not available.

  • Nearly every displayed equation is labelled and the labels are genuinely used: ree_comp3d_static at 140 and 176, max_problem_static at 148, 153 and 157, BigYsimpleFONC at 165, staticY at 174, 196 and 198, ree_comp3d at 292 and 903, ree_hlom at 318, 379, 403 and 600, comp4 at 363, 388, 422 and 566, ree_opbe at 388 and 422, ree_comp7 at 379, 386, 389, 445 and 531, comp10 at 494, comp12 at 545, comp14 at 520, comp16 at 535, ree_hlom2 at 579 and 588, ree_ex5 at 575, 598, 600 and 605.

  • The {prf:definition} at 408-414 is short, numbered and states both halves of the fixed point (“Given belief \(H\), the map \(h\) is the firm’s optimal policy function” / “\(H(Y) = h(Y,Y)\) for all \(Y\)”), and 416 immediately translates it back into the language of perceived versus actual laws of motion.

  • The four exercises build one on another rather than sitting side by side: ree_ex1 sets up the firm’s LQ problem, ree_ex2 extends that program to test candidate equilibria, ree_ex3 solves the planner’s problem and compares with ree_ex2, and ree_ex4 changes one matrix entry (\(a_1/2 \to a_1\), 930-934) to turn the planner into a monopolist - so the last exercise’s economics comes out of a one-character difference in \(R\).

  • Each solution states the mapping between the LQ output and the model’s parameters explicitly before computing anything - \(h_0 = -F_2\), \(h_1 = 1 - F_0\), \(h_2 = -F_1\) (662), \(\kappa_0 = -F_1\), \(\kappa_1 = 1 - F_0\) (870) - and 643-646 and 858-861 both invite the reader to multiply out \(x_t' R x_t + u_t' Q u_t\) and check it equals the negative of the period return.

  • The envelope step is attributed and used consistently: 361-363 names Benveniste-Scheinkman {cite}`BenvenisteScheinkman1979` for differentiating the right side of {eq}`comp4` naively, and 514 then says “Applying the same Benveniste-Scheinkman formula” for the planner’s problem rather than re-deriving it.

  • The footnote at 973-981 is well placed: it hangs off the sentence that says direct iteration on \(\Phi\) may diverge (439) and points to the relaxation-parameter literature ({cite}`MarcetSargent1989`, {cite}`EvansHonkapohja2001`) that studies when adaptive agents converge, which is exactly the reader’s next question.