diff --git a/lectures/_static/quant-econ.bib b/lectures/_static/quant-econ.bib index 2701fe981..862efab0e 100644 --- a/lectures/_static/quant-econ.bib +++ b/lectures/_static/quant-econ.bib @@ -203,7 +203,8 @@ @article{Epstein_Zin1989 volume = {57}, number = {4}, pages = {937--969}, - year = {1989} + year = {1989}, + doi = {10.2307/1913778} } @article{Epstein_Zin1991, @@ -213,7 +214,8 @@ @article{Epstein_Zin1991 volume = {99}, number = {2}, pages = {263--286}, - year = {1991} + year = {1991}, + doi = {10.1086/261750} } @article{Duffie_Epstein1992a, @@ -292,7 +294,8 @@ @article{Kreps_Porteus1978 volume = {46}, number = {1}, pages = {185--200}, - year = {1978} + year = {1978}, + doi = {10.2307/1913656} } @article{Lucas_Stokey1984, @@ -302,7 +305,8 @@ @article{Lucas_Stokey1984 volume = {32}, number = {1}, pages = {139--171}, - year = {1984} + year = {1984}, + doi = {10.1016/0022-0531(84)90079-6} } @book{Karlin_Taylor1981, @@ -2133,17 +2137,6 @@ @book{Lucas1987 publisher = {Oxford Blackwell} } -@article{Hans_Scheink_2009, - author = {Lars Peter Hansen and Jose A. Scheinkman}, - title = {Long-Term Risk: An Operator Approach}, - journal = {Econometrica}, - year = {2009}, - volume = {77}, - number = {1}, - pages = {177-234}, - month = {01} -} - @book{Whittle1963, title = {Prediction and regulation by linear least-square methods}, author = {Whittle, Peter}, @@ -2841,6 +2834,53 @@ @article{MarcetMarimon1994 year = {2019} } +@article{MarcetSargent1989jet, + author = {Marcet, Albert and Sargent, Thomas J.}, + title = {Convergence of Least Squares Learning Mechanisms in + Self-Referential Linear Stochastic Models}, + journal = {Journal of Economic Theory}, + year = {1989}, + volume = {48}, + number = {2}, + pages = {337--368}, + publisher = {Elsevier}, + doi = {10.1016/0022-0531(89)90032-X} +} + +@article{Ljung1977, + author = {Ljung, Lennart}, + title = {Analysis of Recursive Stochastic Algorithms}, + journal = {IEEE Transactions on Automatic Control}, + year = {1977}, + volume = {22}, + number = {4}, + pages = {551--575}, + doi = {10.1109/TAC.1977.1101561} +} + +@article{Evans1985, + author = {Evans, George W.}, + title = {Expectational Stability and the Multiple Equilibria Problem + in Linear Rational Expectations Models}, + journal = {Quarterly Journal of Economics}, + year = {1985}, + volume = {100}, + number = {4}, + pages = {1217--1233}, + doi = {10.2307/1885681} +} + +@article{FourgeaudGourieroux1986, + author = {Fourgeaud, Claude and Gourieroux, Christian and Pradel, Jacqueline}, + title = {Learning Procedures and Convergence to Rationality}, + journal = {Econometrica}, + year = {1986}, + volume = {54}, + number = {4}, + pages = {845--868}, + doi = {10.2307/1912839} +} + @article{MarcetSargent1989, author = {Marcet, Albert and Sargent, Thomas J}, journal = {Journal of Political Economy}, @@ -3063,29 +3103,26 @@ @article{Schelling1969 } @article{Bansal_Yaron_2004, - author = {Ravi Bansal and Amir Yaron}, - title = {{Risks for the Long Run: A Potential Resolution of Asset Pricing Puzzles}}, - journal = {Journal of Finance}, - year = 2004, - volume = {59}, - number = {4}, - pages = {1481-1509}, - month = {08}, - keywords = {}, - doi = {}, - abstract = { We model consumption and dividend growth rates as containing (1) a small long-run predictable component, and (2) fluctuating economic uncertainty (consumption volatility). These dynamics, for which we provide empirical support, in conjunction with Epstein and Zin's (1989) preferences, can explain key asset markets phenomena. In our economy, financial markets dislike economic uncertainty and better long-run growth prospects raise equity prices. The model can justify the equity premium, the risk-free rate, and the volatility of the market return, risk-free rate, and the price-dividend ratio. As in the data, dividend yields predict returns and the volatility of returns is time-varying. Copyright 2004 by The American Finance Association.}, - url = {https://ideas.repec.org/a/bla/jfinan/v59y2004i4p1481-1509.html} + author = {Bansal, Ravi and Yaron, Amir}, + title = {Risks for the Long Run: A Potential Resolution of Asset Pricing Puzzles}, + journal = {Journal of Finance}, + year = {2004}, + volume = {59}, + number = {4}, + pages = {1481--1509}, + doi = {10.1111/j.1540-6261.2004.00670.x} } @article{hansen2008consumption, - title = {Consumption strikes back? Measuring long-run risk}, - author = {Hansen, Lars Peter and Heaton, John C and Li, Nan}, - journal = {Journal of Political economy}, + title = {Consumption Strikes Back? Measuring Long-Run Risk}, + author = {Hansen, Lars Peter and Heaton, John C. and Li, Nan}, + journal = {Journal of Political Economy}, volume = {116}, number = {2}, pages = {260--302}, year = {2008}, - publisher = {The University of Chicago Press} + publisher = {The University of Chicago Press}, + doi = {10.1086/588200} } @article{Hansen_2007, @@ -3166,7 +3203,9 @@ @article{Townsend1983 title = {Forecasting the Forecasts of Others}, journal = {Journal of Political Economy}, volume = {91}, - pages = {546-588} + number = {4}, + pages = {546--588}, + doi = {10.1086/261166} } @article{tobin1992old, @@ -3859,3 +3898,179 @@ @article{grossman1976 pages = {573--585}, year = {1976} } + +@incollection{BrayKreps1987, + author = {Bray, Margaret M. and Kreps, David M.}, + title = {Rational Learning and Rational Expectations}, + booktitle = {Arrow and the Ascent of Modern Economic Theory}, + editor = {Feiwel, George R.}, + publisher = {Palgrave Macmillan}, + address = {London}, + year = {1987}, + pages = {597--625}, + doi = {10.1007/978-1-349-07239-2_19} +} + +@article{Bray1982, + author = {Bray, Margaret M.}, + title = {Learning, Estimation, and the Stability of Rational Expectations}, + journal = {Journal of Economic Theory}, + year = {1982}, + volume = {26}, + number = {2}, + pages = {318--339}, + doi = {10.1016/0022-0531(82)90007-2} +} + +@article{BraySavin1986, + author = {Bray, Margaret M. and Savin, N. E.}, + title = {Rational Expectations Equilibria, Learning and Model Specification}, + journal = {Econometrica}, + year = {1986}, + volume = {54}, + number = {5}, + pages = {1129--1160}, + doi = {10.2307/1912325} +} + +@article{Radner1979, + author = {Radner, Roy}, + title = {Rational Expectations Equilibrium: Generic Existence and the Information Revealed by Prices}, + journal = {Econometrica}, + year = {1979}, + volume = {47}, + number = {3}, + pages = {655--678}, + doi = {10.2307/1910413} +} + +@article{Jordan1982, + author = {Jordan, James S.}, + title = {The Generic Existence of Rational Expectations Equilibrium in the Higher Dimensional Case}, + journal = {Journal of Economic Theory}, + year = {1982}, + volume = {26}, + number = {2}, + pages = {224--243}, + doi = {10.1016/0022-0531(82)90002-3} +} + +@article{Jordan1982b, + author = {Jordan, James S.}, + title = {Admissible Market Data Structures: A Complete Characterization}, + journal = {Journal of Economic Theory}, + year = {1982}, + volume = {28}, + number = {1}, + pages = {19--31}, + doi = {10.1016/0022-0531(82)90089-8} +} + +@article{Admati1985, + author = {Admati, Anat R.}, + title = {A Noisy Rational Expectations Equilibrium for Multi-Asset Securities Markets}, + journal = {Econometrica}, + year = {1985}, + volume = {53}, + number = {3}, + pages = {629--657}, + doi = {10.2307/1911659} +} + +@article{GrossmanStiglitz1980, + author = {Grossman, Sanford J. and Stiglitz, Joseph E.}, + title = {On the Impossibility of Informationally Efficient Markets}, + journal = {American Economic Review}, + year = {1980}, + volume = {70}, + number = {3}, + pages = {393--408}, + doi = {10.2307/1805228} +} + +@article{AndersonSonnenschein1982, + author = {Anderson, Robert M. and Sonnenschein, Hugo}, + title = {On the Existence of Rational Expectations Equilibrium}, + journal = {Journal of Economic Theory}, + year = {1982}, + volume = {26}, + number = {2}, + pages = {261--278}, + doi = {10.1016/0022-0531(82)90004-7} +} + +@article{BlumeEasley1982, + author = {Blume, Lawrence E. and Easley, David}, + title = {Learning to be Rational}, + journal = {Journal of Economic Theory}, + year = {1982}, + volume = {26}, + number = {2}, + pages = {340--351}, + doi = {10.1016/0022-0531(82)90008-4} +} + +@article{Frydman1982, + author = {Frydman, Roman}, + title = {Towards an Understanding of Market Processes: Individual Expectations, Learning, and Convergence to Rational Expectations Equilibrium}, + journal = {American Economic Review}, + year = {1982}, + volume = {72}, + number = {4}, + pages = {652--668} +} + +@article{Grossman1981, + author = {Grossman, Sanford J.}, + title = {An Introduction to the Theory of Rational Expectations under Asymmetric Information}, + journal = {Review of Economic Studies}, + year = {1981}, + volume = {48}, + number = {4}, + pages = {541--559}, + doi = {10.2307/2297195} +} + +@techreport{ArrowGreen1973, + author = {Arrow, Kenneth J. and Green, Jerry R.}, + title = {Notes on Expectations Equilibria in Bayesian Settings}, + year = {1973}, + type = {Working Paper}, + number = {33}, + institution = {Institute for Mathematical Studies in the Social Sciences, Stanford University} +} + +@article{Kreps1977, + author = {Kreps, David M.}, + title = {A Note on Fulfilled Expectations Equilibria}, + journal = {Journal of Economic Theory}, + year = {1977}, + volume = {14}, + number = {1}, + pages = {32--43}, + doi = {10.1016/0022-0531(77)90083-7} +} + +@article{Breeden1979, + author = {Breeden, Douglas T.}, + title = {An Intertemporal Asset Pricing Model with Stochastic + Consumption and Investment Opportunities}, + journal = {Journal of Financial Economics}, + year = {1979}, + volume = {7}, + number = {3}, + pages = {265--296}, + doi = {10.1016/0304-405X(79)90016-3} +} + +@book{Nummelin_1984, + author = {Nummelin, Esa}, + title = {General Irreducible {Markov} Chains and Non-Negative + Operators}, + series = {Cambridge Tracts in Mathematics}, + number = {83}, + publisher = {Cambridge University Press}, + address = {Cambridge}, + year = {1984}, + doi = {10.1017/CBO9780511526237} +} diff --git a/lectures/_toc.yml b/lectures/_toc.yml index 45213fcdb..929fefe00 100644 --- a/lectures/_toc.yml +++ b/lectures/_toc.yml @@ -142,8 +142,11 @@ parts: - file: ge_arrow - file: harrison_kreps - file: morris_learn + - file: rational_learning_re + - file: ls_learning - file: affine_risk_prices - file: ross_recovery + - file: long_run_risk_operator - file: misspecified_recovery - caption: Data and Empirics numbered: true diff --git a/lectures/imp_sample.md b/lectures/imp_sample.md index 09ae67576..2ce766683 100644 --- a/lectures/imp_sample.md +++ b/lectures/imp_sample.md @@ -264,13 +264,12 @@ We next study the bias and efficiency of the Monte Carlo and importance sampling The code below produces distributions of estimates using both Monte Carlo and importance sampling methods. ```{code-cell} ipython3 -@jit(parallel=True) def simulate(p_a, p_b, q_a, q_b, N_simu, T=1): μ_L_p = np.empty(N_simu) μ_L_q = np.empty(N_simu) - for i in prange(N_simu): + for i in range(N_simu): μ_L_p[i] = estimate(p_a, p_b, p_a, p_b, T=T) μ_L_q[i] = estimate(p_a, p_b, q_a, q_b, T=T) diff --git a/lectures/long_run_risk_operator.md b/lectures/long_run_risk_operator.md new file mode 100644 index 000000000..079a5dbfd --- /dev/null +++ b/lectures/long_run_risk_operator.md @@ -0,0 +1,3403 @@ +--- +jupytext: + text_representation: + extension: .md + format_name: myst + format_version: 0.13 + jupytext_version: 1.17.1 +kernelspec: + display_name: Python 3 (ipykernel) + language: python + name: python3 +--- + +(long_run_risk_operator)= +```{raw} jupyter +
+ + QuantEcon + +
+``` + +# Long-term Risk: An Operator Approach + +```{contents} Contents +:depth: 2 +``` + +## Overview + +Standard short-horizon asset pricing tells us how equilibrium prices compensate investors +for tiny, instantaneous exposures to shocks. + +That is, they tell us about the *short end* of the term +structure of risk prices. + +But many of the most interesting asset pricing questions (e.g., the equity +premium puzzle, the slope of the yield curve, the prices of long-dated +options) concern the *long end* of the term structure of risk prices. + +This lecture studies the long end using the operator approach of +{cite:t}`HansenScheinkman2009`. + +At center stage will be a stochastic discount factor process and a return process that are +multiplicative across time in the sense that conditional expectations define a *semigroup* of +valuation operators indexed by horizon $t$. + +Long-horizon behaviour of the semigroup is controlled by a single eigenvalue +problem on the state space. + +By solving that eigenvalue problem and selecting an appropriate eigenfunction, we can factor the +multiplicative functional $M_t$ into three economically meaningful +pieces: a deterministic exponential trend, a non-negative martingale that changes +probability measure, and a transient state-dependent component. + +In particular, the factorization takes the form + +$$ + M_t + = + \exp(\rho t)\, \hat M_t\, + \frac{\phi(X_0)}{\phi(X_t)}, +$$ (eq:hs-factorization) + +where + +* $\rho$ is a scalar (the **principal eigenvalue**) giving the asymptotic + growth or decay rate, +* $\phi$ is a strictly positive **principal eigenfunction** on the state + space, capturing the long-run dependence on the current state, +* $\hat M$ is a positive martingale used to change probability measure (the + **martingale component**), and +* $\phi(X_0)/\phi(X_t)$ is a transient component that washes out as the + twisted process settles into its stationary distribution. + +In finite-state problems this is exactly the Perron-Frobenius decomposition of +a positive matrix; in general state spaces it is a continuous-state counterpart. + +We will refer to {eq}`eq:hs-factorization` as the **multiplicative +factorization** associated with $(\rho,\phi,\hat M)$. + +{cite:t}`AlvarezJermann2005` applied a related permanent-transitory +decomposition to stochastic discount factors. + +The operator approach links +that decomposition to an explicit eigenvalue problem. + +```{seealso} +This lecture is closely related to the lecture +{doc}`advanced:additive_functionals`, which studies the same kind of +permanent-transitory decomposition for additive and multiplicative +functionals in a discrete-time linear-Gaussian setting. + +Reading these two lectures together is a good way to learn about representations of long-run risks +in both continuous and discrete time. +``` + +We will build up to {eq}`eq:hs-factorization` and use it to compute +long-run risk prices in concrete models. + +The plan of this lecture is to: + +1. Set up positive multiplicative functionals $M$ (discount factors, returns, + stochastic growth) and the valuation semigroups they generate. + +2. Introduce the **generator** of a semigroup, a local operator whose + eigenvalue problem controls long-run behaviour. + +3. Find the principal eigenfunction $\phi$ and derive the factorization. + +4. Work two examples in detail: a finite-state Markov chain (where everything + reduces to Perron-Frobenius theory) and an affine diffusion model (where + the eigenfunction is exponential-affine and we get closed-form formulas). + +5. Use the factorization to compute long-run risk prices and compare them to + the local risk prices appropriate for short-horizon asset + pricing. + +A recurring theme is that shocks to persistent state variables drive a wedge between local and long-run risk prices. + +Generating that wedge is the mechanism through which long-run risk models like {cite:t}`Bansal_Yaron_2004` +generate large equity premia. + +We start with the following imports + +```{code-cell} ipython3 +import numpy as np +import matplotlib.pyplot as plt +from scipy.linalg import eig, expm +``` + +## Multiplicative functionals + +### Setting + +Let $\{X_t : t \geq 0\}$ be a continuous-time Markov process with state space +$\mathcal D_0$, and let $\mathcal F_t$ denote the filtration generated by its +history. + +We will work with a strong Markov process whose sample paths are càdlàg +(defined below). + +To arrive at the explicit formulas presented later we will specialize to a semimartingale that + decomposes into a continuous component $X^c$ and a pure-jump +component $X^j$: + +$$ + X_t = X_t^c + X_t^j . +$$ + +We write the continuous-component dynamics as + +$$ + dX_t^c = \xi(X_{t-})\, dt + \Gamma(X_{t-})\, dB_t, +$$ + +and the pure-jump component as + +$$ + dX_t^j = \int \bigl(y - X_{t-}\bigr)\, \zeta(dy, dt), +$$ + +where $\zeta$ is the random counting measure of jumps indexed by the +*post-jump state* $y$, so that $\zeta(B, [0,t])$ counts the number of +jumps in $[0,t]$ landing in the Borel set $B$. + +Its compensator is $\eta(dy \mid X_{t-})\, dt$, the rate at which $X$ +jumps from $X_{t-}$ into a region $dy$. + +We will use this "$y$ = post-jump state" convention throughout, matching +the form $\phi(y) - \phi(x)$ that appears in the generator below. + +We also impose two simplifying assumptions: + +* **Finite jumps** on finite time intervals: only finitely many jumps + occur on any bounded interval; this keeps integrals against the jump + measure well-defined and finite. +* **Sufficient rank in $\Gamma$** so that the Brownian shocks relevant for + pricing can be recovered from the state history; this makes the + Markov state $X$ "rich enough" to describe valuation. + +These assumptions let us write the generator +in closed form and use martingale-based changes of measure freely. + +### Functionals and càdlàg paths + +We need a name for "a process that records something about the history of +$X$". + +This includes, for example, a stochastic discount factor or a cumulated return. + +```{prf:definition} Functional +:label: lrr-def-functional + +A **functional** is a real-valued adapted process $\{M_t : t \geq 0\}$ +constructed from the history of $X$, so that $M_t$ is +$\mathcal F_t$-measurable for each $t$. +``` + +We will always work with the **càdlàg** version of a functional, the +French acronym for "right-continuous with left limits". + +Concretely, for almost every sample path $\omega$, + +$$ + \lim_{s \downarrow t} M_s(\omega) = M_t(\omega) + \qquad \text{for all } t \geq 0, +$$ + +and the left limit $M_{t-}(\omega) := \lim_{s \uparrow t} M_s(\omega)$ exists +and is finite for all $t > 0$. + +Thus, paths can jump, but each jump $\Delta M_t := M_t - M_{t-}$ occurs +instantaneously. + +At the jump time $t$, the value is the post-jump value, +not the pre-jump value. + +```{note} +Why is the càdlàg property worth insisting on? + +Because we will later want to (i) integrate functionals against time, (ii) +apply optional stopping arguments, and (iii) take limits like +$\lim_{t \to \infty} t^{-1}\log M_t$. + +All three operations need the joint measurability in $(\omega,t)$ that +càdlàg paths give us automatically. +``` + +### Multiplicativity + +The central restriction we impose on the functional $M$ is that it is +*multiplicative across time*. + +```{prf:definition} Multiplicative Functional +:label: lrr-def-multiplicative-functional + +A functional $\{M_t : t \geq 0\}$ is **multiplicative** if $M_0 = 1$ and + +$$ + M_{t+u} = M_u(\theta_t)\, M_t , + \qquad t, u \geq 0, +$$ (eq:multiplicative) + +where $\theta_t$ shifts the underlying Markov path forward by $t$ units. +``` + +Why is this a useful condition to require? + +Think of $M_t = S_t$, a stochastic discount factor. + +The date-$0$ value of a date-$t$ payoff $\Pi_t$ is $\mathbb{E}[S_t\Pi_t \mid \mathcal F_0]$. + +If we instead buy this payoff at intermediate date $\tau$, its date-$\tau$ +price must be + +$$ + \mathbb{E}\left[\frac{S_t}{S_\tau}\Pi_t \,\Big|\, \mathcal F_\tau\right]. +$$ + +For the price to depend only on the current Markov state $X_\tau$ (and not on +the entire history up to $\tau$), the ratio $S_t/S_\tau$ must be a function +only of the Markov path *after* $\tau$. + +Thus, +$S_{\tau+u}/S_\tau = S_u(\theta_\tau)$, which is exactly +{eq}`eq:multiplicative`. + +So multiplicativity is the Markov form of the law of one price. + +The same structural property is then carried over to stochastic growth and +cumulated returns. + +### Additive functionals + +It is often easier to work with the *log* of a strictly positive +multiplicative functional. + +If $M_t > 0$, we can write $M_t = \exp(A_t)$, and the multiplicative property +{eq}`eq:multiplicative` becomes the corresponding additive property of $A$. + +```{prf:definition} Additive Functional +:label: lrr-def-additive-functional + +A functional $\{A_t : t \geq 0\}$ is **additive** if $A_0 = 0$ and + +$$ + A_{t+u} = A_u(\theta_t) + A_t . +$$ +``` + +So exponentials of additive functionals are exactly the strictly positive +multiplicative functionals. + +In our jump-diffusion setting, a useful parameterization is + +$$ + A_t + = + \int_0^t \beta(X_s)\, ds + + \int_0^t \gamma(X_{s-})^\top dB_s + + \sum_{0 \leq s \leq t} \kappa(X_s, X_{s-}) , +$$ (eq:additive-functional) + +where the three functions $(\beta, \gamma, \kappa)$ play the following +roles: + +* $\beta(x)$ is a **state-dependent drift** rate ( + e.g., a pure discount factor with short rate $r(x)$ has $\beta(x) = -r(x)$). +* $\gamma(x)$ is a **Brownian loading**, controlling how Brownian shocks feed + into $A$ at state $x$. +* $\kappa(y,x)$ is a **jump amplitude** that fires whenever $X$ jumps from + $x$ to $y$. + +For everything to be well defined, we impose the natural integrability +conditions + +$$ + \int_0^t |\beta(X_s)|\, ds < \infty, + \qquad + \int_0^t \|\gamma(X_s)\|^2\, ds < \infty, +$$ + +together with $\kappa(x,x)=0$ (no jump if the state doesn't change) and + +$$ + \int \exp[\kappa(y,x)]\, \eta(dy \mid x) < \infty. +$$ + +This parameterization is rich enough for everything we do in this lecture, +though additive functionals can also include things like occupation times. + +## Semigroups + +A multiplicative functional $M$ together with the Markov process $X$ defines +a **valuation operator** for each horizon $t$: + +$$ + \mathbb M_t \psi(x) = \mathbb{E}\left[M_t \psi(X_t) \mid X_0 = x\right] . +$$ + +You should read $\mathbb M_t \psi(x)$ as "the date-$0$ value, starting from +state $x$, of a date-$t$ payoff $\psi(X_t)$", weighted by $M_t$. + +The family of operators $\{\mathbb M_t\}_{t \geq 0}$ has a key compositional +structure, the *semigroup property*. + +```{prf:definition} One-Parameter Semigroup +:label: lrr-def-one-parameter-semigroup + +A family of linear operators $\{T_t : t \geq 0\}$ is a **one-parameter +semigroup** if $T_0=I$ and $T_{t+s}=T_tT_s$ for all $s,t \geq 0$. + +It is **positive** if $T_t\psi \geq 0$ whenever $\psi \geq 0$. +``` + +```{prf:definition} Multiplicative Semigroup +:label: lrr-def-multiplicative-semigroup + +Given a multiplicative functional $M$, the associated **multiplicative +semigroup** is the family of operators + +$$ + \mathbb M_t \psi(x) + = + \mathbb{E}\left[M_t \psi(X_t) \mid X_0 = x\right]. +$$ (eq:m-semigroup) +``` + +The semigroup identity $\mathbb M_{t+u} = \mathbb M_t \mathbb M_u$ follows +from iterated expectations and the multiplicative property of $M$. + +Economically, this is the *Markov law of iterated values*: to value a +date-$(t+u)$ payoff today, we can either + +* discount it directly from $t+u$ back to $0$ in one step (apply + $\mathbb M_{t+u}$), or +* first discount it from $t+u$ back to $t$ (apply $\mathbb M_u$), then + discount the resulting date-$t$ price back to $0$ (apply $\mathbb M_t$). + +The semigroup identity says these two procedures give the same answer. + +This is the operator-level version of the intertemporal consistency that +rules out arbitrage across horizons. + +Four positive multiplicative functionals will appear often below. + +| Symbol | Object | Semigroup | +|:---|:---|:---:| +| $S$ | stochastic discount factor | $\{\mathbb S_t\}$ | +| $V$ | cumulated return on an asset | $\{\mathbb V_t\}$ | +| $G$ | stochastic growth in cash flows | $\{\mathbb G_t\}$ | +| $Q=GS$ | valuation of growing cash flows | $\{\mathbb Q_t\}$ | + +The first three are primitives. + +The fourth combines discounting and growth to +value cash flows that grow stochastically over time. + +```{prf:definition} Stochastic Discount Factor +:label: lrr-def-stochastic-discount-factor + +A **stochastic discount factor** $S$ is a positive multiplicative functional +for which $\mathbb{E}[S_t Z_t \mid X_0=x]$ is the date-$0$ value of an +$\mathcal F_t$-measurable payoff $Z_t$. +``` + +```{prf:definition} Valuation Functional +:label: lrr-def-valuation-functional + +Given a stochastic discount factor $S$, a **valuation functional** $V$ is a +positive multiplicative functional such that $\{V_t S_t : t \geq 0\}$ is a +martingale. +``` + +```{prf:definition} Stochastic Growth Functional +:label: lrr-def-stochastic-growth-functional + +A **stochastic growth functional** $G$ is a positive multiplicative +functional, interpreted as a multiplicative growth factor applied to a +date-$0$ cash flow. +``` + +Consider a cash flow $D_t = D_0\, G_t\, \psi(X_t)$, where $D_0 > 0$ is the +date-$0$ level and $\psi$ is a Borel state-payoff function. + +Discounting with $S$ and growing with $G$, its date-$0$ value is + +$$ + D_0\, \mathbb Q_t \psi(X_0), + \qquad + \mathbb Q_t \psi(x) + = + \mathbb{E}\left[G_t S_t \psi(X_t) \mid X_0=x\right]. +$$ + +```{prf:definition} Cash-Flow Valuation Semigroup +:label: lrr-def-cash-flow-valuation-semigroup + +The **cash-flow valuation semigroup** is the multiplicative semigroup +generated by $Q=GS$. +``` + +The long-horizon behaviour of $\mathbb Q_t$ is the central object of the +lecture: it tells us how current prices value cash-flow growth risk that +materializes far in the future. + +```{note} +The factorization $D_t=D_0 G_t \psi(X_t)$ is not unique. + +For any positive function +$\varphi$, + +$$ + D_t + = + D_0 + \left[G_t\frac{\varphi(X_t)}{\varphi(X_0)}\right] + \left[\frac{\psi(X_t)\varphi(X_0)}{\varphi(X_t)}\right], +$$ + +so a transient state-dependent factor can be shuffled between $G$ and $\psi$ +without changing $D_t$. + +We resolve this indeterminacy by normalizing the growth component so that its permanent part is +a martingale: $G_t = \exp(\delta t)\hat G_t$, with $\hat G$ a martingale and +$\delta$ a constant trend. + +The eigenfunction construction below will tell us exactly which martingale to +pick. +``` + +### Local pricing restriction + +Before tackling long horizons, it is good to understand valuation at the *short* end. + +That is the standard instantaneous risk-return relation. + +This will give us a benchmark against which to compare long-run risk prices. + +For a textbook discrete-time treatment of the same SDF-based asset-pricing +ideas, see {doc}`advanced:asset_pricing_lph`. + +For an estimation perspective +on Euler-equation-based asset pricing, see {doc}`hansen_singleton_1982`. + +The key starting point is that a valuation functional $V$ must satisfy the +no-arbitrage requirement that $VS$ is a martingale ({prf:ref}`lrr-def-valuation-functional`). + +We parameterize the stochastic discount factor $S$ and valuation functional +$V$ as additive functionals with coefficients $(\beta^s,\gamma^s,\kappa^s)$ +and $(\beta^v,\gamma^v,\kappa^v)$ respectively, in the notation of +{eq}`eq:additive-functional`. + +For a generic positive multiplicative functional $M = \exp(A)$ with +parameters $(\beta,\gamma,\kappa)$, applying Itô's formula to +$\exp(A_t)$ and requiring the drift of $dM_t/M_{t-}$ to vanish gives the +**local martingale restriction**: + +$$ + \beta(x) + + \frac{\gamma(x)^\top\gamma(x)}{2} + + \int \big(\exp[\kappa(y,x)] - 1\big)\, \eta(dy \mid x) + = 0 . +$$ (eq:local-martingale-restriction) + +The three terms correspond to: + +* the drift of $A$ itself, +* the Itô correction from the Brownian part (because $M = e^A$ picks up a + quadratic-variation contribution), and +* the compensated jumps of $M$ at the multiplier $\exp[\kappa(y,x)]$. + +We ask you to verify this in {ref}`lrr_ex_local_mg`. + +Applying this to $VS$, whose parameters add: $(\beta^v + \beta^s, +\gamma^v + \gamma^s, \kappa^v + \kappa^s)$, gives the **local pricing +restriction** + +$$ + \beta^v+\beta^s + = + -\frac{\|\gamma^v+\gamma^s\|^2}{2} + - + \int + \left( + \exp[\kappa^v(y,\cdot)+\kappa^s(y,\cdot)]-1 + \right) + \eta(dy \mid \cdot). +$$ (eq:local-pricing-restriction) + +This determines the drift $\beta^v$ of any candidate valuation functional in +terms of its Brownian and jump exposures. + +To turn this into an *expected return*, note that the expected net rate of +return on $V$ is + +$$ + \epsilon^v + = + \beta^v + + \frac{\|\gamma^v\|^2}{2} + + \int + \left(\exp[\kappa^v(y,\cdot)]-1\right) + \eta(dy \mid \cdot) . +$$ + +Combining with {eq}`eq:local-pricing-restriction` gives + +$$ +\begin{aligned} + \epsilon^v + &= + -\beta^s + - \gamma^v \cdot \gamma^s + - \frac{\|\gamma^s\|^2}{2} + \\ + &\quad + - + \int + \left( + \exp[\kappa^v(y,\cdot)+\kappa^s(y,\cdot)] + - + \exp[\kappa^v(y,\cdot)] + \right) + \eta(dy \mid \cdot). +\end{aligned} +$$ (eq:local-risk-return) + +Thus, the Brownian local risk-price vector is $-\gamma^s(x)$, expressed in +the same exposure units as $\gamma^v(x)$. + +Jump risk is priced through the function $\kappa^s$. + +This local relation is one end of the term structure of risk prices. + +The eigenvalue calculations below describe the other end. + +## The generator + +So far we have a family of operators $\{\mathbb M_t\}_{t \geq 0}$, one for each +horizon $t$. + +That is more information than we can use directly. + +What we care about is the long-run behaviour: how $\mathbb M_t \psi$ grows as $t \to \infty$. + +The **generator** $\mathbb A$ compresses the entire semigroup into one +time-independent operator on the state space. + +It records the *instantaneous* rate of change of $M_t \psi(X_t)$, and its +eigenvalues drive the long-run growth rate of $\mathbb M_t$. + +This lets us turn an asymptotic question about a family of operators +into a single eigenvalue problem. + +### Discrete-time intuition + +The role of the generator is easiest to see when time is discrete, so we +build the picture there once and then carry it over. + +Let $X_n$ be Markov and $M_n$ a multiplicative functional, and define the +one-period valuation operator + +$$ + K\psi(x) + = + \mathbb{E}\left[M_1 \psi(X_1) \mid X_0=x\right]. +$$ + +Iterating gives the $n$-period operator $K^n$. + +This parallels the logic of a transition matrix: just as $P^n$ gives $n$-step probabilities, $K^n$ weights $n$-period payoffs, with $M_1$ folded in at each step. + +So one local object, $K$, controls the entire horizon-indexed family. + +It also controls long-run growth: if $K\phi = \lambda \phi$, then + +$$ + K^n \phi = \lambda^n \phi , +$$ + +so $\lambda$ is the long-run geometric growth (or decay) rate and $\phi$ is +the long-run dependence on the current state. + +The same operator gives the predictable rate of change of the weighted +payoff. + +By multiplicativity, + +$$ + \mathbb{E}\left[ + M_{n+1}\psi(X_{n+1}) - M_n \psi(X_n) + \mid \mathcal F_n + \right] + = + M_n (K\psi - \psi)(X_n) , +$$ + +so subtracting the cumulative predictable change from the total change leaves +a martingale: + +$$ + M_n\psi(X_n) + - \psi(X_0) + - \sum_{j=0}^{n-1} M_j (K\psi - \psi)(X_j) . +$$ + +Here $K-I$ is the *local* rate of change of +$M_n \psi(X_n)$, and through $K^n$ it also controls long-run growth. + +### From discrete to continuous time + +Continuous time keeps the same logic. + +The natural counterpart $K-I$ is the **infinitesimal generator** of the +semigroup $\{\mathbb M_t\}$, the time derivative at zero: + +$$ + \mathbb A \psi(x) + := + \lim_{h \downarrow 0} + \frac{\mathbb M_h \psi(x) - \psi(x)}{h}, +$$ + +so that for small $h>0$, + +$$ + \mathbb M_h \psi(x) + \approx + \psi(x) + h\, \mathbb A \psi(x) . +$$ + +```{note} +When $M \equiv 1$, the +multiplicative semigroup reduces to the standard Markov transition semigroup +$\mathbb M_t \psi(x) = \mathbb{E}[\psi(X_t) \mid X_0=x]$, and $\mathbb A$ becomes the +familiar infinitesimal generator $\mathcal L$ of $X$ from textbook stochastic +calculus. + +For general $M$, $\mathbb A$ is the same kind of object but it carries extra terms that +encode the instantaneous "yield" of $M$: discount rates, Brownian risk +prices, jump multipliers. + +That is exactly what we will see when we write down its closed form in +{eq}`eq:extended-generator` below. +``` + +Why is this the right object? + +If $\mathbb A\phi = \rho\phi$, then the candidate + +$$ + \hat M_t := \exp(-\rho t)\, M_t\, \frac{\phi(X_t)}{\phi(X_0)} +$$ + +is automatically a *local* martingale. + +When $\hat M$ is in fact a martingale (the content of Assumption 6.1 in +{cite:t}`HansenScheinkman2009`), taking expectations gives the +continuous-time analogue of $K^n\phi = \lambda^n\phi$: + +$$ + \mathbb M_t \phi = \exp(\rho t)\, \phi . +$$ + +Without that upgrade we get only the supermartingale inequality $\mathbb +M_t \phi \le \exp(\rho t)\, \phi$, which we will revisit below. + +So the long-run behaviour of $\mathbb M_t$ is encoded in an eigenvalue +problem for the local operator $\mathbb A$, together with the +martingale property of $\hat M$. + +### Extended generator + +The limit definition above needs a qualification. + +To make the limit $h \downarrow 0$ rigorous, the textbook definition +requires $(\mathbb M_h\psi - \psi)/h$ to converge to $\mathbb A\psi$ in a +chosen norm, typically uniform convergence over bounded continuous +functions, where the semigroup is a contraction. + +But the functions we care about most are the principal eigenfunctions +$\phi$ solving $\mathbb A\phi = \rho\phi$, and these typically *grow* with +the state $X$ (in the affine-Gaussian benchmark, $\phi$ is +exponential-affine in $x$). + +So they do not lie in this space, and the +limit need not converge for them. + +{cite:t}`HansenScheinkman2009` sidestep this by characterizing $\mathbb A$ +through a *Doob-Meyer style* semimartingale decomposition of +$M_t \psi(X_t)$, a pathwise condition that does not require any norm. + +This is the continuous-time counterpart to writing $K - I$ as the predictable +rate of change of $M_n\psi(X_n)$ in discrete time. + +The resulting **extended generator** admits unbounded $\psi$, has a +strictly larger domain than the textbook generator, and agrees with it +where both are defined. + +Concretely: + +```{prf:definition} Extended Generator +:label: lrr-def-extended-generator + +Fix a Borel function $\psi$, and look for a second Borel function $\chi$ that +will play the role of "the instantaneous rate of change of $M_t \psi(X_t)$ +at the current state". We ask whether there exists $\chi$ such +that + +$$ + N_t + = + M_t \psi(X_t) + - \psi(X_0) + - \int_0^t M_s \chi(X_s)\, ds +$$ + +is a local martingale. + +We then say $\psi$ +lies in the domain of the **extended generator** $\mathbb A$ of $M$, and we +*define* the operator by + +$$ +\mathbb A \psi := \chi. +$$ + +``` + +The three terms play the same roles as in discrete time: + +* $M_t \psi(X_t) - \psi(X_0)$ is the total change in the weighted payoff over + $[0, t]$, +* $\int_0^t M_s \chi(X_s)\, ds$ accumulates the expected rate of change along + the path, +* $N_t$ is the residual. + +Requiring $N_t$ to be a local martingale pins down $\chi = \mathbb A\psi$ as +the instantaneous expected rate of change of $M_t \psi(X_t)$ at the current +state. + +* When $M \equiv 1$, the definition reduces to Dynkin's formula for the + standard Markov generator + $\mathcal L \psi(x) + = \lim_{t \downarrow 0} t^{-1}\bigl[\mathbb{E}\psi(X_t) - \psi(x)\bigr]$. + +* When $X$ is a jump diffusion, Itô's formula applied to $M_t\psi(X_t)$ + produces the closed-form expression for $\mathbb A\psi$ in {eq}`eq:extended-generator` below. + +### A closed form for jump diffusions + +For the jump-diffusion setting introduced above, we can compute $\mathbb A$ +explicitly by applying Itô's formula to $M_t\phi(X_t)$. + +Suppose the continuous part of $X$ satisfies + +$$ + dX_t^c = \xi(X_t)dt + \Gamma(X_t)dB_t +$$ + +with diffusion matrix $\Sigma = \Gamma \Gamma^\top$, and let +$\eta(dy \mid x)$ denote the jump compensator. + +If $M=\exp(A)$ is parameterized by $(\beta,\gamma,\kappa)$ as in +{eq}`eq:additive-functional`, then for smooth $\phi$, + +$$ +\begin{aligned} +\mathbb A \phi(x) +&= +\left[\xi(x)+\Gamma(x)\gamma(x)\right]^\top + \frac{\partial \phi(x)}{\partial x} +\\ +&\quad ++ \frac{1}{2} + \operatorname{trace}\left[ + \Sigma(x) + \frac{\partial^2\phi(x)}{\partial x \partial x^\top} + \right] +\\ +&\quad ++ \int + [\phi(y)-\phi(x)] + \exp[\kappa(y,x)] \eta(dy \mid x) +\\ +&\quad ++ \left[ + \beta(x) + + \frac{\gamma(x)^\top \gamma(x)}{2} + + \int + \left(\exp[\kappa(y,x)]-1\right)\eta(dy \mid x) + \right]\phi(x). +\end{aligned} +$$ (eq:extended-generator) + +The four terms have transparent interpretations: + +1. The first term is the standard Markov drift, modified by $\Gamma\gamma$, + a *covariance correction* between the Brownian shocks driving $X$ and + those driving $M$. +2. The second is the standard diffusion (Itô) term. +3. The third integrates $\phi$ against the jump-compensated transition rates, + reweighted by the jump multiplier $\exp[\kappa(y,x)]$. +4. The fourth is a multiplicative *yield-like* term that multiplies $\phi(x)$ + itself and combines the drift of $M$, the Brownian Itô correction, and the + compensated jumps. + +```{note} +When $M=S$ is a stochastic discount factor, the local risk prices are +spread across the four pieces of the generator rather than concentrated in +the level term. + +* Brownian factor prices enter through the drift modification + $\xi \to \xi + \Gamma\gamma$ in the first line. +* Jump-risk prices enter through the tilted jump measure + $\eta \to \exp[\kappa]\,\eta$ in the third line. +* The level term in the fourth line contains the instantaneous risk-free + rate component (the *short end* of the term structure) plus the + jump-compensator contribution $\int(\exp[\kappa]-1)\,\eta$. + +We ask readers to verify the derivation of {eq}`eq:extended-generator` in +{ref}`lrr_ex4`. +``` + +We will apply this formula directly in the affine-diffusion example below. + +## Principal eigenfunctions + +We now arrive at the central technical question of the lecture: + +> Which positive payoffs grow at a constant proportional rate under the +> valuation semigroup? + +The answer, when it exists, is a positive eigenfunction of the generator. + +```{prf:definition} Eigenfunction of the Extended Generator +:label: lrr-def-generator-eigenfunction + +A Borel function $\phi$ is an **eigenfunction** of $\mathbb A$ with +eigenvalue $\rho$ if + +$$ + \mathbb A \phi = \rho \phi . +$$ (eq:generator-eigen) + +A **principal eigenfunction** is an eigenfunction $\phi$ that is strictly +positive on the state space: $\phi(x) > 0$ for all $x \in \mathcal D_0$. +``` + +The strict-positivity requirement matters because $\phi$ will appear in +denominators throughout: it has to be safe to divide by it. + +### From eigenfunction to factorization + +Why does an eigenfunction of $\mathbb A$ give us the multiplicative +factorization {eq}`eq:hs-factorization`? + +The discrete-time analogy points the way. If $K\phi = \lambda\phi$, then + +$$ + \lambda^{-n}\, M_n\, \frac{\phi(X_n)}{\phi(X_0)} +$$ + +is a martingale: the eigenvalue equation absorbs the one-step drift of +$M_n\phi(X_n)$ exactly. + +In continuous time, $\lambda^n$ becomes $\exp(\rho t)$, and the candidate +martingale is + +$$ + \hat M_t + = + \exp(-\rho t)\, M_t\, \frac{\phi(X_t)}{\phi(X_0)} . +$$ (eq:mhat) + +Let's check that $\hat M$ is indeed a local martingale. + +By the definition of $\mathbb A$, the semimartingale +$Z_t := M_t\phi(X_t)$ admits the decomposition + +$$ + dZ_t = M_t\, \mathbb A\phi(X_t)\, dt + dN_t , +$$ + +where $N$ is a local martingale. + +The eigenvalue equation +$\mathbb A\phi = \rho\phi$ replaces the drift by $\rho Z_t\, dt$, and +integration by parts gives + +$$ + d\bigl(\exp(-\rho t) Z_t\bigr) + = \exp(-\rho t)\,\bigl[dZ_t - \rho Z_t\, dt\bigr] + = \exp(-\rho t)\, dN_t . +$$ + +So $\exp(-\rho t) Z_t$ is a local martingale, and dividing by $\phi(X_0)$ +shows the same for $\hat M$. + +Rearranging {eq}`eq:mhat` for $M_t$ recovers the factorization +{eq}`eq:hs-factorization`, with $\hat M$ in the role of the martingale +component. + +```{prf:definition} Martingale Component and Twisted Measure +:label: lrr-def-martingale-component + +When $\hat M$ is a martingale (not merely a local martingale), it is the +**martingale component** associated with $(\rho,\phi)$ and defines the +**twisted probability measure** by weighting date-$t$ events with +$\hat M_t$: + +$$ + \widehat{\Pr}(F \mid X_0=x) + = + \mathbb{E}[\hat M_t \mathbf 1_F \mid X_0=x], + \qquad F \in \mathcal F_t. +$$ +``` + +The verification establishes only that $\hat M$ is a *local* martingale, but +the definition above (and the change-of-measure interpretation of +$\hat M$) require it to be a martingale. + +We close this gap by adopting Assumption 6.1 of +{cite:t}`HansenScheinkman2009`: + +> The local martingale $\hat M$ defined in {eq}`eq:mhat` is a martingale, +> i.e. $\mathbb{E}[\hat M_t \mid X_0 = x] = 1$ for every $t \geq 0$ and $x$. + +We carry this assumption from here on. + +Even without closing the gap we still get one-sided control. + +Since $\hat M$ is nonnegative with $\hat M_0 = 1$, it is a supermartingale, +so $\mathbb{E}[\hat M_t \mid X_0=x] \leq 1$. + +Taking expectations in {eq}`eq:mhat`, + +$$ + \mathbb M_t \phi(x) \leq \exp(\rho t)\, \phi(x) , +$$ + +so $\rho$ is at least an upper bound on the long-run growth rate of +$\mathbb M_t \phi$. + +When $\hat M$ is in fact a martingale, $\mathbb{E}[\hat M_t] = 1$, the inequality +becomes an equality, and the local condition $\mathbb A\phi = \rho\phi$ lifts +to the semigroup eigenvalue equation + +$$ + \mathbb M_t \phi = \exp(\rho t)\, \phi, + \qquad t \geq 0. +$$ (eq:semigroup-eigen) + +### Stability of the twisted process + +We now have a factorization {eq}`eq:hs-factorization` for *any* principal +eigenfunction. + +But for $(\rho,\phi)$ to describe **long-run** behaviour of +$\mathbb M_t$ the twisted +process must settle into a stationary regime as $t \to \infty$. + +If it doesn't, the transient factor $\phi(X_0)/\phi(X_t)$ will not vanish, +and we cannot read off the asymptotics from $\rho$ alone. + +We need three conditions, each ruling out a specific way in which the twisted process can fail to settle down. + +Let $\hat E$ and $\widehat{\Pr}$ denote expectation and probability under the +twisted measure, and let $\hat{\mathbb A}$ be the generator of $X$ under +that measure. + +*Condition 1: a stationary distribution exists.* + +```{prf:definition} Stationary Distribution of the Twisted Process +:label: lrr-def-stationary-distribution + +A probability measure $\hat\varsigma$ on $\mathcal D_0$ is a **stationary +distribution** for the twisted process if + +$$ + \int \hat{\mathbb A}\psi\, d\hat\varsigma = 0 +$$ + +for every $\psi$ in the $L^\infty$ domain of $\hat{\mathbb A}$. +``` + +$\hat\varsigma$ is the candidate long-run distribution. + +Without it, the twisted process has no steady state, and the long-run limit cannot be expressed as a state-space integral. + +*Condition 2: every important region is reachable.* + +```{prf:definition} Irreducible Skeleton +:label: lrr-def-irreducible-skeleton + +The discretely sampled skeleton $\{X_{\Delta j} : j = 0, 1, \ldots\}$ is +**irreducible** relative to $\hat\varsigma$ if there exists $\Delta > 0$ +such that, for every Borel set $\Lambda \subseteq \mathcal D_0$ with +$\hat\varsigma(\Lambda) > 0$, + +$$ + \hat E\!\left[ + \sum_{j=0}^\infty \mathbf 1_{\{X_{\Delta j} \in \Lambda\}} + \,\bigg|\, X_0 = x + \right] > 0 + \qquad \text{for all } x \in \mathcal D_0 . +$$ +``` + +Without it, the long-run distribution could depend on the +starting state; different basins of attraction would give different +limits. + +*Condition 3: every important region is visited infinitely often.* + +```{prf:definition} Harris Recurrence +:label: lrr-def-harris-recurrence + +The process $X$ is **Harris recurrent** under the twisted measure if, for +every Borel set $\Lambda \subseteq \mathcal D_0$ with $\hat\varsigma(\Lambda) > 0$, + +$$ + \widehat{\Pr}\!\left\{ + \int_0^\infty \mathbf 1_{\{X_t \in \Lambda\}}\, dt = \infty + \,\bigg|\, X_0 = x + \right\} = 1 + \qquad \text{for all } x \in \mathcal D_0 . +$$ +``` + +Reachability (Condition 2) is not enough. + +A set may be reachable but visited with vanishingly small probability, so time averages fail to converge to $\hat\varsigma$-averages. + +Harris recurrence is the +continuous-state counterpart to a "recurrent state" in a finite chain. + +Collecting the three conditions: + +```{prf:definition} Stochastically Stable Twisted Process +:label: lrr-def-stochastic-stability + +The $\hat M$-twisted Markov process is **stochastically stable** if it has +a stationary distribution $\hat\varsigma$, the skeleton $\{X_{\Delta j}\}$ +is irreducible relative to $\hat\varsigma$, and $X$ is Harris recurrent +under the twisted measure. +``` + +### The long-run approximation + +Under the martingale condition for $\hat M$, strict positivity of $M$, and +stochastic stability, the long-run limit takes a clean form: + +$$ + \lim_{t \to \infty} + \exp(-\rho t)\, \mathbb M_t \psi + = + \phi + \int \frac{\psi}{\phi}\, d\hat\varsigma . +$$ (eq:long-run-limit) + +Read this as follows: + +* The factor $\exp(\rho t)$ captures the exponential growth or decay of the semigroup; once we divide it out, what remains has a finite limit. +* The state dependence in that limit is *entirely* captured by $\phi(x)$. +* The scalar $\int (\psi/\phi)\, d\hat\varsigma$ is the **long-run intensity** + of the payoff $\psi$, weighted by $1/\phi$ and averaged against the + twisted stationary distribution. + +The two precise cases of Proposition 7.1 of +{cite:t}`HansenScheinkman2009` are: + +* **Sampled grid, $\hat\varsigma$-almost every starting state.** Fix any + $\Delta>0$ and assume $\int |\psi|/\phi\, d\hat\varsigma < \infty$; + then the limit holds along $t = \Delta j$ for $\hat\varsigma$-almost + every $x \in \mathcal D_0$. +* **Continuous $t$, every starting state.** If $\psi/\phi$ is bounded + then the limit holds for every $x \in \mathcal D_0$ and every + $t \to \infty$, with no continuity assumption on $\psi$. + +```{note} +There can be more than one positive eigenfunction of $\mathbb A$ for which +the associated $\hat M$ is a martingale, possibly with different +eigenvalues. + +Stochastic stability selects a particular one. + +By Proposition 7.2 of {cite:t}`HansenScheinkman2009`, the stable +eigenfunction's eigenvalue $\rho$ is the **smallest** among all +eigenvalues of $\mathbb A$ that admit a strictly positive eigenfunction +satisfying the maintained conditions. + +Any other positive eigenfunction sharing this $\rho$ is proportional to +$\phi$ $\hat\varsigma$-almost surely. + +The finite-state section below states the same selection in the more +familiar Perron-Frobenius language, calling $\rho$ the eigenvalue with the +*largest* real part among all eigenvalues of $A$. + +These two descriptions identify the same eigenvalue because in the +irreducible finite-state case only one eigenvalue of $A$ admits a +strictly positive eigenvector. + +In the affine example below the two sets pull apart, since the quadratic +{eq}`eq:cf-roots` has two roots $c_f$ that both give strictly positive +exponential-affine eigenfunctions with distinct eigenvalues. + +Stochastic +stability picks the smaller $\rho$ by rejecting the root that produces an +explosive twisted process. +``` + +## A finite-state Markov chain + +We now apply the framework to a concrete example. + +We start with the simplest case: a finite-state Markov chain. + +For background on finite Markov chains in discrete time, see +{doc}`finite_markov`. + +For the asset-pricing applications of finite-state +chains that motivate the construction here, see {doc}`markov_asset`. + +Here, every abstract object collapses to a familiar one: + +| Abstract object | Finite-state version | +|:---|:---| +| Markov process $X$ | continuous-time chain with intensity matrix $U$ | +| Generator $\mathbb A$ | a matrix $A$ | +| Semigroup $\mathbb M_t$ | matrix exponential $\exp(tA)$ | +| Principal eigenfunction $\phi$ | Perron right eigenvector | +| Principal eigenvalue $\rho$ | dominant real eigenvalue of $A$ | +| Stationary distribution $\hat\varsigma$ | left eigenvector of twisted generator | + +So the long-run analysis reduces to Perron-Frobenius theory. + +(For an introduction to the Perron-Frobenius theorem, see +{doc}`intro:eigen_II`.) + +### Setup + +Let $X$ take values in $\{x_1,\ldots,x_N\}$ and let $U$ be its intensity +matrix. + +```{prf:definition} Intensity Matrix +:label: lrr-def-intensity-matrix + +An **intensity matrix** $U$ for a finite-state continuous-time Markov chain +satisfies $u_{ij} \geq 0$ for $i \neq j$ and $\sum_j u_{ij}=0$ for each +state $i$. + +Off-diagonal entries $u_{ij}$ are the jump rates from state $i$ to state +$j$; the diagonal entry $u_{ii} = -\sum_{j \neq i}u_{ij}$ is minus the exit +rate from state $i$. +``` + +Let the multiplicative functional have + +* a **discount or decay rate** $r_i$ in state $i$ (the analogue of the drift + $\beta(X_s)$ in the additive parameterization), and +* a **jump multiplier** $\exp[\kappa(x_j,x_i)]$ that fires whenever the + state jumps from $i$ to $j$. + +In code below, `κ[j, i]` means $\kappa(x_j,x_i)$. + +Then the generator matrix $A$ for the multiplicative semigroup is + +$$ + a_{ij} + = + \begin{cases} + u_{ii} - r_i, & i=j, \\ + u_{ij}\exp[\kappa(x_j,x_i)], & i \neq j . + \end{cases} +$$ (eq:finite-a) + +The off-diagonal entries are the chain's jump rates *weighted* by the +jump multipliers; the diagonal entries combine the exit rate with the +in-state decay rate. + +The semigroup is then just $\mathbb M_t = \exp(tA)$. + +For an irreducible chain with strictly positive jump multipliers, the +principal eigenvalue $\rho$ is the unique real eigenvalue of $A$ with +largest real part, and the associated right eigenvector is strictly +positive. + +The twisted generator under the principal eigenpair $(\rho,\phi)$ is + +$$ + \hat A = D_\phi^{-1} A D_\phi - \rho I, +$$ + +where $D_\phi = \operatorname{diag}(\phi)$. + +The row sums of $\hat A$ vanish, +so $\hat A$ is itself a valid intensity matrix. + +The stationary distribution +$\hat\varsigma$ solves $\hat\varsigma^\top \hat A = 0$. + +The helper functions below implement these three calculations. + +```{code-cell} ipython3 +def build_generator(U, r, κ): + """Generator matrix for a finite-state multiplicative semigroup. + + κ[j, i] is the log jump multiplier for a transition i -> j. + """ + U = np.asarray(U, dtype=float) + r = np.asarray(r, dtype=float) + κ = np.asarray(κ, dtype=float) + + A = U * np.exp(κ.T) + np.fill_diagonal(A, np.diag(U) - r) + return A + + +def principal_eigenpair(A): + """Perron eigenpair with a positive right eigenvector.""" + vals, vecs = eig(A) + idx = np.argmax(vals.real) + + ρ = vals[idx].real + φ = vecs[:, idx].real + + if φ.sum() < 0: + φ = -φ + + if np.any(φ <= 0): + if np.min(φ) > -1e-10: + φ = np.maximum(φ, 0) + else: + raise ValueError( + "Dominant eigenvector is not strictly positive.") + + φ = φ / φ.mean() + return ρ, φ + + +def twisted_generator(A, ρ, φ): + """Generator under the twisted measure.""" + D = np.diag(φ) + D_inv = np.diag(1 / φ) + return D_inv @ A @ D - ρ * np.eye(len(φ)) + + +def stationary_distribution(Q): + """Stationary distribution of a finite-state generator.""" + vals, vecs = eig(Q.T) + idx = np.argmin(np.abs(vals)) + π = vecs[:, idx].real + + if π.sum() < 0: + π = -π + + π = np.maximum(π, 0) + return π / π.sum() +``` + +### Two states + +Consider a boom-recession economy. + +State 1 is a *boom* (higher short rate $r_1=0.05$, switching to recession +at rate $\lambda_1 = 0.30$). + +State 2 is a *recession* (lower short rate $r_2=0.02$, switching to boom +at rate $\lambda_2 = 0.50$). + +For now we set the jump multipliers to zero, so the SDF only changes +continuously through the in-state decay rates. + +```{code-cell} ipython3 +λ_1 = 0.30 +λ_2 = 0.50 + +U = np.array([[-λ_1, λ_1], + [ λ_2, -λ_2]]) + +r = np.array([0.05, 0.02]) +κ = np.zeros((2, 2)) + +A = build_generator(U, r, κ) +ρ, φ = principal_eigenpair(A) + +print("A =") +print(np.round(A, 4)) +print(f"\nρ = {ρ:.6f}") +print(f"φ = {φ}") +print(f"long-run zero-coupon yield = {-ρ:.4f}") +``` + +Note that $-\rho$ is the asymptotic yield on a zero-coupon bond: from +{eq}`eq:hs-factorization`, the date-$0$ price of a long zero-coupon bond +decays like $\exp(\rho t)$, so its yield is $-\rho$. + +Let's verify the semigroup eigenvalue equation +$\mathbb M_t \phi = \exp(\rho t)\phi$ numerically. + +```{code-cell} ipython3 +for t in [1.0, 5.0, 25.0]: + lhs = expm(t * A) @ φ + rhs = np.exp(ρ * t) * φ + err = np.max(np.abs(lhs - rhs)) + print(f"t = {t:4.1f}, error = {err:.2e}") +``` + +The error is at machine precision for every $t$, so the equation holds +exactly up to floating-point noise from the eigendecomposition. + +Next we compute the twisted generator $\hat A$ and the stationary +distribution $\hat\varsigma$ of the chain under the twisted measure. + +This is the candidate long-run distribution that appears in the long-run +limit {eq}`eq:long-run-limit`. + +```{code-cell} ipython3 +A_hat = twisted_generator(A, ρ, φ) +ς_hat = stationary_distribution(A_hat) + +print("twisted generator row sums:") +print(np.round(A_hat.sum(axis=1), 12)) + +print("\ntwisted stationary distribution:") +print(f" boom {ς_hat[0]:.4f}") +print(f" recession {ς_hat[1]:.4f}") +``` + +This twisted stationary distribution (not the original chain's stationary +distribution) is what determines long-horizon valuations. + +It differs from the stationary distribution of the original chain because the eigenfunction $\phi$ +reweights states by how persistently they affect the multiplicative +functional. + +For any payoff function $\psi$, the long-run limit +{eq}`eq:long-run-limit` is the vector + +$$ + \phi + \sum_i \frac{\psi_i}{\phi_i}\hat\varsigma_i . +$$ + +Let's check that the rescaled semigroup converges to this limit as $t$ grows. + +```{code-cell} ipython3 +ψ = np.array([1.0, 2.0]) +limit = φ * np.sum((ψ / φ) * ς_hat) + +for t in [1, 5, 20, 80]: + approx = np.exp(-ρ * t) * expm(t * A) @ ψ + print(f"t = {t:2d}, normalized value = {approx}") + +print("\nlimit =", limit) +``` + +The numerical values converge to the limit; the next plot shows the same +convergence pictorially. + +```{code-cell} ipython3 +--- +mystnb: + figure: + caption: Convergence of the rescaled semigroup to its long-run limit + name: fig-lrr-semigroup-convergence +--- +t_grid = np.linspace(0.01, 80, 400) +rescaled = np.array([np.exp(-ρ * t) * expm(t * A) @ ψ for t in t_grid]) + +fig, ax = plt.subplots() +ax.plot(t_grid, rescaled[:, 0], lw=2, label="starting from boom") +ax.plot(t_grid, rescaled[:, 1], lw=2, label="starting from recession") +ax.axhline(limit[0], color="C0", ls="--", lw=1, alpha=0.7) +ax.axhline(limit[1], color="C1", ls="--", lw=1, alpha=0.7) +ax.set_xlabel("$t$") +ax.set_ylabel(r"$e^{-\rho t}\,(\mathbb{M}_t \psi)(x)$") +ax.legend() +plt.show() +``` + +The two solid curves trace the rescaled values starting from each state, +and the dashed horizontal lines mark the limits predicted by +{eq}`eq:long-run-limit`. + +Both curves settle onto their predicted limits, confirming that the +long-run behaviour depends on the starting state only through $\phi$. + +```{note} +The asymptotic exponential rate of convergence is governed by the gap +between the *real part* of the leading eigenvalue $\rho$ and the largest +real part among the remaining eigenvalues of $A$. + +For an irreducible Metzler matrix the leading eigenvalue is real and its +real part is strictly larger than the others, so this gap is well defined. + +{ref}`lrr_ex3` works through a three-state example where the gap can be +checked directly. +``` + +### Adding jumps + +State transitions in this chain are discontinuous, so it is natural to allow +the multiplicative functional to jump at the transition times. + +These +jumps are the analogue of the $\kappa$ function in the jump-diffusion +parameterization. + +A natural example arises with a stochastic discount factor that jumps +*down* when the economy moves from recession into boom and *up* on the reverse transition. + +The matrix `κ_jump` below encodes this. + +We use the convention +`κ[j, i]` = log jump multiplier of $M$ for the transition $i \to j$, with +state index 0 = boom and state index 1 = recession. + +```{code-cell} ipython3 +# recession (1) -> boom (0): SDF jumps down on good news (exp(-0.20)) +# boom (0) -> recession (1): SDF jumps up on bad news (exp(+0.30)) +κ_jump = np.array([[ 0.0, -0.20], + [ 0.30, 0.0]]) + +A_jump = build_generator(U, r, κ_jump) +ρ_jump, φ_jump = principal_eigenpair(A_jump) + +print(f"ρ without jumps = {ρ:.6f}") +print(f"ρ with jumps = {ρ_jump:.6f}") +print("\nφ with jumps:") +print(φ_jump) +``` + +To see how the long-run rate $\rho$ responds to jump risk, we hold the +boom-to-recession multiplier fixed and trace out $\rho$ as the +recession-to-boom multiplier varies. + +```{code-cell} ipython3 +--- +mystnb: + figure: + caption: Jumps and the long-run growth rate + name: fig-lrr-jumps-eigenvalue +--- +κ_grid = np.linspace(-0.5, 0.5, 100) +ρ_grid = np.empty_like(κ_grid) + +for n, k in enumerate(κ_grid): + κ_temp = np.array([[0.0, k], + [0.30, 0.0]]) + A_temp = build_generator(U, r, κ_temp) + ρ_grid[n], _ = principal_eigenpair(A_temp) + +fig, ax = plt.subplots() +ax.plot(κ_grid, ρ_grid, lw=2) +ax.axhline(ρ, color="black", ls="--", lw=1) +ax.axvline(0, color="black", ls=":", lw=1) +ax.set_xlabel("jump log multiplier for recession to boom") +ax.set_ylabel("principal eigenvalue") +plt.show() +``` + +The principal eigenvalue is monotonically increasing in the recession-to-boom +log multiplier: as that multiplier rises, $M$ jumps less downward (or more +upward) on good news, which mechanically pushes $\rho$ up. + +The economically sensible SDF region is to the left of zero, where the +multiplier is negative. + +## The affine diffusion example + +We now move to a continuous-state model. + +We will use a two-factor affine specification that captures the two main +empirical features of asset returns: + +* **stochastic volatility**, where the dispersion of shocks is itself a + state variable, and +* **predictable growth**, where a small, persistent state variable shifts + expected growth rates. + +This is the kind of state process used in long-run risk models like +{cite:t}`Bansal_Yaron_2004`. + +We work with two independent state components: a Feller square-root process +$X^f$ (stochastic volatility) and an Ornstein-Uhlenbeck process $X^o$ +(predictable growth): + +$$ +\begin{aligned} +dX_t^f +&= +\xi_f(\bar x_f - X_t^f)dt ++ \sqrt{X_t^f}\sigma_f dB_t^f, +\\ +dX_t^o +&= +\xi_o(\bar x_o - X_t^o)dt ++ \sigma_o dB_t^o. +\end{aligned} +$$ (eq:affine-state) + +The parameters $\xi_f, \xi_o>0$ are mean-reversion speeds, $\bar x_f, +\bar x_o$ are the unconditional means, and $\sigma_f, \sigma_o$ are +diffusion coefficients. + +The OU process $X^o$ is the continuous-time analogue of the AR(1) process +studied in {doc}`intro:ar1_processes`, and continuous-time linear +asset-pricing models in the same family are developed in +{doc}`affine_risk_prices`. + +We follow a sign convention with $\sigma_o>0$ and $\sigma_f<0$: a positive +$B^f$ shock then *reduces* volatility, in line with the empirical +"leverage effect." + +Now consider a multiplicative functional $M=\exp(A)$ with affine +parameters: + +$$ +\begin{aligned} +A_t +&= +\bar\beta t ++ \int_0^t \beta_f X_s^f\, ds ++ \int_0^t \beta_o X_s^o\, ds +\\ +&\quad ++ \int_0^t \sqrt{X_s^f}\,\gamma_f\, dB_s^f ++ \int_0^t \gamma_o\, dB_s^o . +\end{aligned} +$$ (eq:affine-additive) + +So the drift of $A$ is affine in the state ($\bar\beta + \beta_f X^f + +\beta_o X^o$), the Brownian loadings are constant in the $B^o$ direction +and proportional to $\sqrt{X^f}$ in the $B^f$ direction. + +### Why exponential-affine eigenfunctions work + +When the state is affine and the drift of $A$ is affine, applying the +generator to an exponential-affine function +$\phi(x^f,x^o) = \exp(c_f x^f + c_o x^o)$ returns another exponential-affine function. + +This closure property turns the eigenvalue equation +$\mathbb A\phi = \rho\phi$ into a small system of algebraic equations in $(c_f, c_o, \rho)$. + +```{prf:definition} Exponential-Affine Eigenfunction +:label: lrr-def-exponential-affine-eigenfunction + +An eigenfunction $\phi$ of $\mathbb A$ on a state space $\mathcal D_0 +\subseteq \mathbb R^n$ is **exponential-affine** if + +$$ + \phi(x) = \exp(c_0 + c^\top x) + \qquad \text{for all } x \in \mathcal D_0 , +$$ + +for some constant $c_0 \in \mathbb R$ and vector $c \in \mathbb R^n$. +``` + +Substituting $\phi(x^f,x^o) = \exp(c_f x^f + c_o x^o)$ into the generator +formula {eq}`eq:extended-generator` and matching coefficients of $x^f$, +$x^o$, and the constant term gives + +$$ +0 += +\beta_f ++ \frac{\gamma_f^2}{2} ++ c_f(\gamma_f\sigma_f-\xi_f) ++ c_f^2\frac{\sigma_f^2}{2}, +$$ (eq:cf-eq) + +and + +$$ + c_o = \frac{\beta_o}{\xi_o}. +$$ (eq:co-eq) + +The two candidate values for $c_f$ are + +$$ +c_f += +\frac{ + \xi_f-\gamma_f\sigma_f + \pm + \sqrt{ + (\xi_f-\gamma_f\sigma_f)^2 + - \sigma_f^2(2\beta_f+\gamma_f^2) + } +}{\sigma_f^2}. +$$ (eq:cf-roots) + +The eigenvalue is then determined by matching the constant term: + +$$ +\rho += +\bar\beta ++ \frac{\gamma_o^2}{2} ++ c_f \xi_f \bar x_f ++ c_o(\xi_o\bar x_o+\gamma_o\sigma_o) ++ c_o^2 \frac{\sigma_o^2}{2}. +$$ (eq:affine-rho) + +Equation {eq}`eq:cf-roots` gives two candidate +values of $c_f$, and we need to know which one is the principal +eigenfunction. + +This is where stochastic stability +({prf:ref}`lrr-def-stochastic-stability`) does real work. + +Under the twisted measure, the drift of $X^f$ is + +$$ + \xi_f(\bar x_f - x^f) + + x^f\sigma_f(\gamma_f+c_f\sigma_f), +$$ + +so the mean-reversion coefficient becomes + +$$ + \xi_f - \sigma_f(\gamma_f+c_f\sigma_f) . +$$ + +If this is positive, the twisted square-root process stays stationary; if +it is negative, the twisted process is explosive and the eigenfunction is +not the long-run-relevant one. + +So we **pick the root that keeps the twisted process mean-reverting**, +exactly the way stochastic stability selects the principal eigenfunction +in the abstract theory. + +```{code-cell} ipython3 +def solve_affine_eigenfunction(params): + """Solve the exponential-affine eigenvalue problem.""" + ξ_f = params["ξ_f"] + xbar_f = params["xbar_f"] + σ_f = params["σ_f"] + ξ_o = params["ξ_o"] + xbar_o = params["xbar_o"] + σ_o = params["σ_o"] + β_bar = params["β_bar"] + β_f = params["β_f"] + β_o = params["β_o"] + γ_f = params["γ_f"] + γ_o = params["γ_o"] + + co = β_o / ξ_o + + disc = ((ξ_f - γ_f * σ_f) ** 2 + - σ_f ** 2 * (2 * β_f + γ_f ** 2)) + + if disc < 0: + raise ValueError("No real affine eigenfunction for these parameters.") + + root = np.sqrt(disc) + cf_roots = ( + ((ξ_f - γ_f * σ_f) - root) / σ_f ** 2, + ((ξ_f - γ_f * σ_f) + root) / σ_f ** 2 + ) + + def mean_reversion(cf): + return ξ_f - σ_f * (γ_f + cf * σ_f) + + for cf in cf_roots: + mr = mean_reversion(cf) + if mr > 0: + break + else: + raise ValueError("Neither root gives a stationary twisted process.") + + ρ = (β_bar + + γ_o ** 2 / 2 + + cf * ξ_f * xbar_f + + co * (ξ_o * xbar_o + γ_o * σ_o) + + co ** 2 * σ_o ** 2 / 2) + + return cf, co, ρ, mr +``` + +### A Breeden SDF + +To make things concrete, we now plug in a specific stochastic discount +factor: the Breeden CRRA consumption-based SDF. + +{cite:t}`Breeden1979` derived the continuous-time SDF for an investor with +time-separable CRRA preferences over a consumption stream. + +We specify log consumption with the same affine state $X^o$ driving +expected growth and $\sqrt{X^f}$ driving volatility: + +$$ + dc_t + = + X_t^o\, dt + + \sqrt{X_t^f}\,\vartheta_f\, dB_t^f + + \vartheta_o\, dB_t^o . +$$ + +With time-separable CRRA utility (risk aversion $a$) and subjective discount +rate $b$, the stochastic discount factor is + +$$ + S_t + = + \exp\!\big(-bt - a(c_t-c_0)\big), +$$ + +i.e. an exponential of $-b$ times time minus $a$ times log consumption growth. + +Reading off the additive functional coefficients gives + +$$ + \bar\beta^s = -b, + \quad + \beta_f^s = 0, + \quad + \beta_o^s = -a, + \quad + \gamma_f^s = -a\vartheta_f, + \quad + \gamma_o^s = -a\vartheta_o . +$$ (eq:breeden-sdf-params) + +We will use these parameters in the numerical example below. + +### Recursive preferences (optional) + +A famous limitation of CRRA preferences is that they conflate risk aversion +with the elasticity of intertemporal substitution. + +Recursive preferences {cite:t}`Kreps_Porteus1978, Epstein_Zin1989` separate +the two, and add a forward-looking continuation-value term to the +discount-factor expression. + +This is what powers the equity-premium results in +{cite:t}`Bansal_Yaron_2004`. + +A QuantEcon lecture that studies long-run dynamics under recursive +preferences in a different setting is +{doc}`survival_recursive_preferences`. + +This section derives the SDF coefficients for the unit-elasticity +recursive specification. + +You can skip on a first read and come back later +--- the numerical example uses the simpler Breeden parameters above. + +For the unit-elasticity recursive specification, conjecture a continuation +value of the form + +$$ + W_t + = + \frac{1}{1-a} + \exp\left[ + (1-a)(w_f X_t^f + w_o X_t^o + c_t + \bar w) + \right], + \qquad a>1 . +$$ (eq:kp-continuation-value) + +Matching the local mean of this continuation value gives + +$$ +\begin{aligned} +0 +&= +-\xi_f w_f ++ \frac{(1-a)\sigma_f^2}{2}w_f^2 ++ (1-a)\vartheta_f\sigma_f w_f ++ \frac{(1-a)\vartheta_f^2}{2} +- b w_f, +\\ +0 +&= +-\xi_o w_o + 1 - b w_o, +\\ +b\bar w +&= +\xi_f \bar x_f w_f ++ \xi_o \bar x_o w_o ++ \frac{(1-a)\sigma_o^2}{2}w_o^2 ++ (1-a)\vartheta_o\sigma_o w_o ++ \frac{(1-a)\vartheta_o^2}{2}. +\end{aligned} +$$ (eq:kp-continuation-coefficients) + +The relevant solution has $w_o=1/(\xi_o+b)$, selects the stable root of the +quadratic for $w_f$, and then determines $\bar w$ from the constant equation. + +The stochastic discount factor is the product $S_t=\exp(A_t^B)\exp(A_t^W)$, +where the Breeden-like logarithmic component is + +$$ + A_t^B + = + -bt + - \int_0^t X_s^o ds + - \int_0^t \sqrt{X_s^f}\vartheta_f dB_s^f + - \int_0^t \vartheta_o dB_s^o +$$ + +The continuation-value martingale component is + +$$ +\begin{aligned} + A_t^W + &= + (1-a)\int_0^t + \sqrt{X_s^f}(\vartheta_f+w_f\sigma_f)dB_s^f + + (1-a)\int_0^t + (\vartheta_o+w_o\sigma_o)dB_s^o +\\ + &\quad + - \frac{(1-a)^2}{2} + \int_0^t X_s^f(\vartheta_f+w_f\sigma_f)^2ds + - \frac{(1-a)^2}{2} + (\vartheta_o+w_o\sigma_o)^2t . +\end{aligned} +$$ (eq:kp-sdf-components) + +Thus the recursive-utility SDF has affine parameters + +$$ +\begin{aligned} +\bar\beta^s +&= +-b-\frac{(1-a)^2}{2}(\vartheta_o+w_o\sigma_o)^2, +\\ +\beta_f^s +&= +-\frac{(1-a)^2}{2}(\vartheta_f+w_f\sigma_f)^2, +\\ +\beta_o^s +&= -1, +\\ +\gamma_f^s +&= +-a\vartheta_f-(a-1)w_f\sigma_f, +\\ +\gamma_o^s +&= +-a\vartheta_o-(a-1)w_o\sigma_o . +\end{aligned} +$$ (eq:kp-sdf-params) + +The local Brownian risk prices are therefore +$\sqrt{x^f}[a\vartheta_f+(a-1)w_f\sigma_f]$ for $B^f$ exposure and +$a\vartheta_o+(a-1)w_o\sigma_o$ for $B^o$ exposure. + +The numerical example below uses the simpler Breeden specification, but the +same operator calculation applies once the SDF parameters are replaced by +{eq}`eq:kp-sdf-params`. + +### Numerical example + +Let's set up parameters and solve for the principal eigenpair. + +We use parameters in the standard long-run-risk neighbourhood: a +mean-reverting volatility factor $X^f$ with mean $0.04$, a slower-moving +predictable-growth factor $X^o$ with mean $0.02$, risk aversion $a=4$, and +a time discount rate $b=0.03$. + +```{code-cell} ipython3 +params_state = { + "ξ_f": 0.70, + "xbar_f": 0.04, + "σ_f": -0.20, + "ξ_o": 0.50, + "xbar_o": 0.02, + "σ_o": 0.01, +} + +a = 4.0 +b = 0.03 +ϑ_f = 0.06 +ϑ_o = 0.02 + +params_sdf = { + **params_state, + "β_bar": -b, + "β_f": 0.0, + "β_o": -a, + "γ_f": -a * ϑ_f, + "γ_o": -a * ϑ_o, +} + +cf_s, co_s, ρ_s, mr_s = solve_affine_eigenfunction(params_sdf) + +print("principal eigenfunction φ(xf, xo) = exp(cf xf + co xo)") +print(f"cf = {cf_s:.6f}") +print(f"co = {co_s:.6f}") +print(f"ρ = {ρ_s:.6f}") +print(f"twisted mean-reversion coefficient for Xf = {mr_s:.6f}") +print(f"long-run zero-coupon yield = {-ρ_s:.4f}") +``` + +The long-run zero-coupon yield $-\rho_s$ represents the asymptotic decay +rate in the SDF expectation $\mathbb{E}[S_t]$. + +We can also check that the rejected root for $c_f$ would have produced a +non-stationary twisted process, a clear example of stochastic stability +selecting one of two algebraically valid eigenfunctions. + +```{code-cell} ipython3 +ξ_f = params_sdf["ξ_f"] +σ_f = params_sdf["σ_f"] +γ_f = params_sdf["γ_f"] +β_f = params_sdf["β_f"] + +disc = ((ξ_f - γ_f * σ_f) ** 2 + - σ_f ** 2 * (2 * β_f + γ_f ** 2)) +root = np.sqrt(disc) + +cf_candidates = np.array([ + ((ξ_f - γ_f * σ_f) - root) / σ_f ** 2, + ((ξ_f - γ_f * σ_f) + root) / σ_f ** 2 +]) + +for cf in cf_candidates: + mr = ξ_f - σ_f * (γ_f + cf * σ_f) + print(f"cf = {cf:8.4f}, twisted mean reversion = {mr:8.4f}") +``` + +### The martingale component + +Now that we have the eigenpair $(\rho,\phi)$, we can write down all three +pieces of the factorization {eq}`eq:hs-factorization` explicitly. + +The martingale component $\hat M_t = \exp(\hat A_t)$ defined in +{eq}`eq:mhat` has log + +$$ +\begin{aligned} +\hat A_t +&= +\int_0^t \sqrt{X_s^f}(\gamma_f+c_f\sigma_f)\, dB_s^f ++ \int_0^t (\gamma_o+c_o\sigma_o)\, dB_s^o +\\ +&\quad +- \frac{1}{2}\int_0^t X_s^f(\gamma_f+c_f\sigma_f)^2\, ds +- \frac{1}{2}\int_0^t (\gamma_o+c_o\sigma_o)^2\, ds . +\end{aligned} +$$ + +The first line is the Brownian integral (the "exponential martingale" piece); +the second is the Itô correction needed to make it a martingale. + +Under the twisted measure induced by $\hat M$, the drifts of the state +variables shift to + +$$ +\begin{aligned} +dX_t^f: +\quad& +\xi_f(\bar x_f-X_t^f) ++ X_t^f \sigma_f(\gamma_f+c_f\sigma_f), +\\ +dX_t^o: +\quad& +\xi_o(\bar x_o-X_t^o) ++ \sigma_o(\gamma_o+c_o\sigma_o). +\end{aligned} +$$ + +The drift distortions are exactly the Girsanov shifts induced by the +Brownian loadings of $\hat M$. + +Let's now simulate the state and check the factorization numerically. + +The first check is the *algebraic identity*: once we define $\hat M$ +through {eq}`eq:mhat`, the equation $M_t = \exp(\rho t)\hat M_t +\phi(X_0)/\phi(X_t)$ is automatic for any choice of $(\rho,\phi)$, and the +error below is just floating-point round-off. + +The second, substantive, check is whether the eigenpair $(\rho,\phi)$ we +solved for really makes $\hat M$ a martingale, which we approximate by +computing $\mathbb{E}[\hat M_t]$ across many simulated paths. + +```{code-cell} ipython3 +def brownian_increments(n, dt, seed=1234): + """Independent Brownian increments for the simulation.""" + rng = np.random.default_rng(seed) + draws = rng.normal(scale=np.sqrt(dt), size=(n, 2)) + return draws[:, 0], draws[:, 1] + + +def simulate_states(params, T=40.0, dt=0.01, seed=1234): + """Euler simulation of the affine state process.""" + n = int(T / dt) + t = np.linspace(0, T, n + 1) + Xf = np.empty(n + 1) + Xo = np.empty(n + 1) + dBf, dBo = brownian_increments(n, dt, seed) + + Xf[0] = params["xbar_f"] + Xo[0] = params["xbar_o"] + + for k, (dBf_k, dBo_k) in enumerate(zip(dBf, dBo)): + xf = max(Xf[k], 1e-10) + xo = Xo[k] + + Xf[k + 1] = (xf + + params["ξ_f"] * (params["xbar_f"] - xf) * dt + + np.sqrt(xf) * params["σ_f"] * dBf_k) + Xf[k + 1] = max(Xf[k + 1], 1e-10) + + Xo[k + 1] = (xo + + params["ξ_o"] * (params["xbar_o"] - xo) * dt + + params["σ_o"] * dBo_k) + + return t, Xf, Xo, dBf, dBo + + +def additive_log_M(params, t, Xf, Xo, dBf, dBo): + """Additive log functional along a simulated path.""" + dt = t[1] - t[0] + A = np.zeros_like(t) + + for k, (dBf_k, dBo_k) in enumerate(zip(dBf, dBo)): + xf = max(Xf[k], 1e-10) + xo = Xo[k] + + drift = (params["β_bar"] + + params["β_f"] * xf + + params["β_o"] * xo) + + shock = (np.sqrt(xf) * params["γ_f"] * dBf_k + + params["γ_o"] * dBo_k) + + A[k + 1] = A[k] + drift * dt + shock + + return A + + +t, Xf, Xo, dBf, dBo = simulate_states(params_sdf) +A_log = additive_log_M(params_sdf, t, Xf, Xo, dBf, dBo) + +φ_0 = np.exp(cf_s * Xf[0] + co_s * Xo[0]) +φ_t = np.exp(cf_s * Xf + co_s * Xo) + +M = np.exp(A_log) +M_hat = np.exp(-ρ_s * t) * M * φ_t / φ_0 +transient = φ_0 / φ_t + +identity_error = np.max(np.abs(M - np.exp(ρ_s * t) * M_hat * transient)) +print(f"algebraic identity error = {identity_error:.2e}") +``` + +The error above is up to machine precision, as expected. + +Next we estimate $\mathbb{E}[\hat M_t \mid X_0 = \bar x]$ over a Monte Carlo sample +of paths. + +If $\hat M$ is a martingale, the population mean is exactly $1$ at every +$t$, and the sample mean should lie within a few standard errors of $1$. + +```{code-cell} ipython3 +def simulate_M_hat(params, ρ, cf, co, n_paths=2000, T=20.0, dt=0.01, seed=2024): + """Monte Carlo paths of hat M_t along an ensemble of trajectories.""" + rng = np.random.default_rng(seed) + n = int(T / dt) + t = np.linspace(0, T, n + 1) + M_hat_paths = np.empty((n_paths, n + 1)) + + for k in range(n_paths): + seed_k = rng.integers(1, 10**9) + t_k, Xf_k, Xo_k, dBf_k, dBo_k = simulate_states( + params, T=T, dt=dt, seed=int(seed_k) + ) + A_k = additive_log_M(params, t_k, Xf_k, Xo_k, dBf_k, dBo_k) + φ_t_k = np.exp(cf * Xf_k + co * Xo_k) + φ_0_k = np.exp(cf * Xf_k[0] + co * Xo_k[0]) + M_hat_paths[k] = np.exp(-ρ * t_k) * np.exp(A_k) * φ_t_k / φ_0_k + + return t, M_hat_paths + + +t_mc, M_hat_paths = simulate_M_hat(params_sdf, ρ_s, cf_s, co_s) +M_hat_mean = M_hat_paths.mean(axis=0) +M_hat_se = M_hat_paths.std(axis=0, ddof=1) / np.sqrt(M_hat_paths.shape[0]) + +print(" t mean se (mean - 1) / se") +for t_check in [1.0, 5.0, 10.0, 20.0]: + idx = np.argmin(np.abs(t_mc - t_check)) + mean = M_hat_mean[idx] + se = M_hat_se[idx] + z = (mean - 1.0) / se + print(f"{t_mc[idx]:5.2f} {mean:7.4f} {se:7.4f} {z:+6.2f}") +``` + +```{code-cell} ipython3 +--- +mystnb: + figure: + caption: Affine state paths and multiplicative factorization + name: fig-lrr-factorization-paths +--- +fig, axes = plt.subplots(2, 2, figsize=(12, 8)) + +axes[0, 0].plot(t, Xf) +axes[0, 0].set_ylabel("$X_t^f$") +axes[0, 0].set_xlabel("$t$") + +axes[0, 1].plot(t, Xo) +axes[0, 1].set_ylabel("$X_t^o$") +axes[0, 1].set_xlabel("$t$") + +axes[1, 0].plot(t, M, label="$M_t$") +axes[1, 0].plot(t, np.exp(ρ_s * t) * M_hat * transient, + "--", label="factorization") +axes[1, 0].set_ylabel("multiplicative factorization") +axes[1, 0].set_xlabel("$t$") +axes[1, 0].legend() + +axes[1, 1].plot(t, np.exp(ρ_s * t), label="$\\exp(\\rho t)$") +axes[1, 1].plot(t, M_hat, label="$\\hat M_t$", alpha=0.8) +axes[1, 1].plot(t, transient, label="$\\phi(X_0)/\\phi(X_t)$", alpha=0.8) +axes[1, 1].set_ylabel("three components") +axes[1, 1].set_xlabel("$t$") +axes[1, 1].legend() + +plt.tight_layout() +plt.show() +``` + +The figure shows how the three components evolve over time. + +## Long-run risk prices + +We can now use the factorization to compute long-run analogues of the +instantaneous risk prices that arise in standard continuous-time asset +pricing. + +We can ask: + +> If an investor takes on a small exposure to a shock today, how much extra +> expected return do they need when that return is measured as a long-horizon +> rate rather than an instantaneous one? + +The two answers, local and long-run, need not agree. + +A shock that moves a persistent state variable has a small *immediate* +effect on the cash flow but a large *cumulative* effect on future expected +growth and discounting, which is why the two answers come apart. + +So the long-run risk price is the local price *plus a persistence +correction.* + +The size of the correction depends on the speed of mean reversion. + +### Defining the prices + +```{prf:definition} Local Brownian Risk Price +:label: lrr-def-local-brownian-risk-price + +The **local Brownian risk price** is the state-dependent vector +$-\gamma^s(x)$. + +A small Brownian exposure $\gamma^v_i$ earns a required expected return of +$-\gamma^v_i \gamma^s_i$ per unit time, so a unit of exposure $\gamma^v_i$ +is priced at $-\gamma^s_i$. +``` + +For the local price we just read off the SDF coefficients. + +```{prf:definition} Long-Run Risk Price +:label: lrr-def-long-run-risk-price + +The **long-run risk price** is the marginal change in the long-run required +return on a cash flow with respect to a small change in its risk exposure. + +When we work with growing cash flows, the long-run required return is +$R_\infty = -\rho + \delta$, where $\rho$ is the principal eigenvalue of +the $GS$ semigroup and $\delta$ is the trend growth rate, held fixed. +``` + +Computing the long-run price requires solving the principal eigenvalue +problem, which captures how a shock propagates through the persistent +state component. + +### Two frontiers + +We will see *two* related ways to vary risk exposure, each leading to a +slightly different long-run risk price: + +1. **Valuation-functional frontier:** + - Hold the SDF $S$ fixed and vary the + asset's Brownian exposures $(\gamma^v_f, \gamma^v_o)$. + + - Use the local + pricing restriction to determine the drift $\beta^v$, then compute + $\rho^v$ for the $V$-semigroup. + +2. **Cash-flow frontier:** + - Hold the SDF $S$ fixed and vary the cash-flow's + growth exposures $(\gamma^g_f, \gamma^g_o)$. + - Set $M = GS$ and compute + the principal eigenvalue $\rho$ of the cash-flow valuation semigroup. + +In simple log-normal examples, these two frontiers coincide. + +But they can differ with stochastic volatility, nonlinear dynamics, or jump risk. + +We will work out both types of examples in the affine model below. + +### Stochastic discount factor decomposition + +Before getting into risk prices, a natural benchmark is the case $M=S$: +applying the factorization {eq}`eq:hs-factorization` directly to the SDF +itself. + +The factorization becomes + +$$ + S_t + = + \exp(\rho t)\hat M_t + \frac{\phi(X_0)}{\phi(X_t)} . +$$ + +This is the **permanent-transitory decomposition** of +{cite:t}`AlvarezJermann2005`, linked now to a concrete eigenfunction +construction. + +The factor $\exp(\rho t)$ is the deterministic trend in the SDF and the +martingale $\hat M$ is its random *permanent* component; the +state-dependent ratio is *transient* and washes out. + +```{seealso} +The same spectral decomposition of the pricing operator is the central +tool in {doc}`ross_recovery`, which uses it to "recover" subjective beliefs +from observed prices, and in {doc}`misspecified_recovery`, which examines +what goes wrong when the permanent martingale component is mistakenly +assumed away. +``` + +For a long zero-coupon bond, + +$$ + \exp(-\rho t)\, \mathbb{E}[S_t \mid X_0=x] + \to + \phi(x) + \int \frac{1}{\phi}\, d\hat\varsigma , +$$ + +so long-maturity discount bond prices depend on the current state primarily +through the eigenfunction $\phi$. + +### Comparison in the affine model + +For the affine specification, we can write closed-form expressions for both +local and long-run prices of a $B^o$ shock. + +The local price is just + +$$ + \text{local price of } B^o = -\gamma_o^s. +$$ + +The long-run price (which we will derive below using the valuation-functional +frontier) is + +$$ + \text{long-run price of } B^o + = + -\gamma_o^s + - \frac{\beta_o^s}{\xi_o}\sigma_o . +$$ (eq:long-run-price-o) + +The extra term $-(\beta_o^s/\xi_o)\sigma_o$ is the **persistence correction**. + +It arises because: + +* a $B^o$ shock moves the persistent growth predictor $X^o$, and +* $X^o$ mean reverts at rate $\xi_o$, so the cumulative effect of the shock + on future SDF growth scales like $1/\xi_o$. + +As $\xi_o$ shrinks, persistence grows and the long-run price diverges from +the local one, which is the central economic content of long-run risk +models. + +The local price of $B^f$ exposure is state dependent (it scales with +$\sqrt{X^f_t}$), and the long-run price of $B^f$ exposure is nonlinear, +since $c_f$ is the root of a quadratic. + +```{code-cell} ipython3 +γ_s_o = params_sdf["γ_o"] +β_s_o = params_sdf["β_o"] +ξ_o = params_sdf["ξ_o"] +σ_o = params_sdf["σ_o"] + +local_price_o = -γ_s_o +long_run_price_o = -γ_s_o - (β_s_o / ξ_o) * σ_o + +print(f"local price of B^o exposure = {local_price_o:.4f}") +print(f"long-run price of B^o exposure = {long_run_price_o:.4f}") +``` + +The next cell illustrates how persistence changes the wedge between local and +long-run prices. + +```{code-cell} ipython3 +--- +mystnb: + figure: + caption: Persistence and long-run risk prices + name: fig-lrr-persistence-risk-prices +--- +ξ_o_grid = np.array([0.10, 0.20, 0.50, 1.00, 2.00, 5.00]) +local_grid = np.full_like(ξ_o_grid, local_price_o) +long_grid = -γ_s_o - (β_s_o / ξ_o_grid) * σ_o + +fig, ax = plt.subplots() +ax.plot(ξ_o_grid, local_grid, "--", lw=2, label="local") +ax.plot(ξ_o_grid, long_grid, "o-", lw=2, label="long-run") +ax.set_xscale("log") +ax.set_xlabel("mean-reversion speed $\\xi_o$") +ax.set_ylabel("risk price") +ax.legend() +plt.show() +``` + +As we can see, the long-run price of $B^o$ exposure is sensitive to +the mean-reversion speed $\xi_o$, but the local price is a constant. + +### Changing valuation functionals + +Now we work out the long-run risk price formula by varying the asset's +exposure, the **valuation-functional frontier** introduced above. + +We hold the SDF $S$ fixed and pick Brownian exposures +$(\gamma_f^v,\gamma_o^v)$ for the asset return, parameterizing the +valuation functional as + +$$ +\begin{aligned} +A_t^v +&= +\bar\beta^v t ++ \int_0^t \beta_f^v X_s^f ds ++ \int_0^t \beta_o^v X_s^o ds +\\ +&\quad ++ \int_0^t \sqrt{X_s^f}\gamma_f^v dB_s^f ++ \int_0^t \gamma_o^v dB_s^o . +\end{aligned} +$$ + +The martingale restriction on $VS$ determines the drift coefficients from the +chosen Brownian exposures $(\gamma_f^v,\gamma_o^v)$: + +$$ +\begin{aligned} +\bar\beta^v +&= +-\bar\beta^s +- \frac{1}{2}(\gamma_o^s+\gamma_o^v)^2, +\\ +\beta_f^v +&= +-\beta_f^s +- \frac{1}{2}(\gamma_f^s+\gamma_f^v)^2, +\\ +\beta_o^v +&= +-\beta_o^s . +\end{aligned} +$$ (eq:valuation-local-restriction-affine) + +Applying the affine eigenvalue formula to $M=V$ gives + +$$ +\begin{aligned} +\rho^v +&= +\bar\beta^v ++ \frac{(\gamma_o^v)^2}{2} ++ c_f^v \xi_f \bar x_f ++ c_o^v(\xi_o\bar x_o+\gamma_o^v\sigma_o) ++ (c_o^v)^2\frac{\sigma_o^2}{2} +\\ +&= +-\bar\beta^s +- \frac{(\gamma_o^s)^2}{2} +- \gamma_o^s\gamma_o^v ++ c_f^v \xi_f \bar x_f ++ c_o^v(\xi_o\bar x_o+\gamma_o^v\sigma_o) ++ (c_o^v)^2\frac{\sigma_o^2}{2}, +\end{aligned} +$$ (eq:valuation-rho-affine) + +where $c_o^v=\beta_o^v/\xi_o=-\beta_o^s/\xi_o$ and $c_f^v$ solves the same +quadratic equation as in {eq}`eq:cf-eq` with $(\beta_f,\gamma_f)$ replaced by +$(\beta_f^v,\gamma_f^v)$. + +Holding $\gamma_f^v$ fixed, differentiating {eq}`eq:valuation-rho-affine` +with respect to $\gamma_o^v$ gives the long-run valuation-functional price of +$B^o$ exposure: + +$$ + \frac{\partial \rho^v}{\partial \gamma_o^v} + = + -\gamma_o^s + + c_o^v\sigma_o + = + -\gamma_o^s + - \frac{\beta_o^s}{\xi_o}\sigma_o . +$$ (eq:valuation-long-run-price-o) + +This matches the formula {eq}`eq:long-run-price-o` we previewed above, +namely the local price plus the persistence correction +$-(\beta_o^s/\xi_o)\sigma_o$. + +Let's verify the formula numerically by finite-differencing the eigenvalue +computation. + +```{code-cell} ipython3 +def valuation_params_from_exposure(γ_v_o, γ_v_f=0.0): + """Affine parameters for a valuation functional V.""" + p = dict(params_sdf) + p.update({ + "β_bar": (-params_sdf["β_bar"] + - 0.5 * (params_sdf["γ_o"] + γ_v_o) ** 2), + "β_f": (-params_sdf["β_f"] + - 0.5 * (params_sdf["γ_f"] + γ_v_f) ** 2), + "β_o": -params_sdf["β_o"], + "γ_f": γ_v_f, + "γ_o": γ_v_o, + }) + return p + + +def valuation_eigenvalue_for_exposure(γ_v_o, γ_v_f=0.0): + """Principal eigenvalue for the valuation functional frontier.""" + p = valuation_params_from_exposure(γ_v_o, γ_v_f) + _, _, ρ, _ = solve_affine_eigenfunction(p) + return ρ +``` + +```{code-cell} ipython3 +--- +mystnb: + figure: + caption: Changing valuation functionals + name: fig-lrr-valuation-frontier +--- +γ_v_o_grid = np.linspace(-0.5, 0.5, 101) +ρ_v_grid = np.array([ + valuation_eigenvalue_for_exposure(g) for g in γ_v_o_grid +]) + +fig, ax = plt.subplots() +ax.plot(γ_v_o_grid, ρ_v_grid, lw=2) +ax.set_xlabel("valuation exposure $\\gamma_o^v$") +ax.set_ylabel("principal eigenvalue $\\rho^v$") +plt.show() +``` + +```{code-cell} ipython3 +valuation_slope = ( + valuation_eigenvalue_for_exposure(0.001) + - valuation_eigenvalue_for_exposure(-0.001) +) / 0.002 + +print(f"finite-difference slope = {valuation_slope:.6f}") +print(f"formula = {long_run_price_o:.6f}") +``` + +### Changing cash-flow risk + +The second long-run frontier varies the cash-flow's exposure to risk rather +than the return. + +We pick a growth functional $G_t = \exp(A_t^g)$ with the affine +parameterization + +$$ +\begin{aligned} +A_t^g +&= +\delta t ++ \int_0^t \sqrt{X_s^f}\gamma_f^g dB_s^f ++ \int_0^t \gamma_o^g dB_s^o +\\ +&\quad +- \frac{1}{2} + \int_0^t + \left[ + X_s^f(\gamma_f^g)^2 + (\gamma_o^g)^2 + \right] ds . +\end{aligned} +$$ (eq:growth-functional) + +The last line is the Itô compensator that makes +$\exp(A_t^g-\delta t) = \hat G_t$ a *local* martingale, with $\delta$ the +constant trend growth rate. + +Stochastic stability of the growth-twisted process needs three conditions. + +The **Feller-type nonattainment** inequality + +$$ + 2(\xi_f+\sigma_f\gamma_f^g)\bar x_f \geq \sigma_f^2 +$$ + +keeps the twisted $X^f$ from hitting zero. + +*Mean reversion* of the twisted $X^f$ is picked by the same root-selection +argument we used for the SDF in {eq}`eq:cf-roots`. + +$\hat G$ itself must be a martingale, the Assumption-6.1 analogue for the +growth twist. + +The Feller inequality is necessary but not sufficient on its own. + +```{note} +This Feller restriction is a concrete instance of a general point we +flagged earlier: changing growth risk can violate stability and invalidate +the long-run approximation, so the choice of $(\gamma_f^g, \gamma_o^g)$ +isn't free. +``` + +To price the cash flow $D_t=D_0G_t\psi(X_t)$, use the semigroup generated by +$M=GS$. + +The combined affine parameters are + +$$ +\begin{aligned} +\bar\beta &= \bar\beta^s+\delta-\frac{(\gamma_o^g)^2}{2},\\ +\beta_f &= \beta_f^s-\frac{(\gamma_f^g)^2}{2},\\ +\beta_o &= \beta_o^s,\\ +\gamma_f &= \gamma_f^s+\gamma_f^g,\\ +\gamma_o &= \gamma_o^s+\gamma_o^g. +\end{aligned} +$$ + +Let $\rho$ be the principal eigenvalue of this $GS$ semigroup. + +Then $-\rho$ is the long-run decay rate in value, and + +$$ + R_\infty = -\rho + \delta +$$ + +is the asymptotic required return net of the cash-flow growth rate. + +```{code-cell} ipython3 +def required_return_for_growth_exposure(γ_g_o, γ_g_f=0.0, δ=0.02): + """Long-run required return for a cash-flow growth exposure.""" + p = dict(params_sdf) + p.update({ + "β_bar": params_sdf["β_bar"] + δ - 0.5 * γ_g_o ** 2, + "β_f": params_sdf["β_f"] - 0.5 * γ_g_f ** 2, + "β_o": params_sdf["β_o"], + "γ_f": params_sdf["γ_f"] + γ_g_f, + "γ_o": params_sdf["γ_o"] + γ_g_o, + }) + + _, _, ρ, _ = solve_affine_eigenfunction(p) + return -ρ + δ +``` + +```{code-cell} ipython3 +--- +mystnb: + figure: + caption: Local and long-run pricing of persistent growth risk + name: fig-lrr-cashflow-frontier +--- +γ_g_o_grid = np.linspace(-0.5, 0.5, 101) +required_returns = np.array([ + required_return_for_growth_exposure(g) for g in γ_g_o_grid +]) + +local_line = (required_return_for_growth_exposure(0.0) + + local_price_o * γ_g_o_grid) + +fig, ax = plt.subplots() +ax.plot(γ_g_o_grid, required_returns, lw=2, + label="long-run required return") +ax.plot(γ_g_o_grid, local_line, "--", lw=2, + label="local slope") +ax.set_xlabel("cash-flow exposure $\\gamma_o^g$") +ax.set_ylabel("rate of return") +ax.legend() +plt.show() +``` + +The slope of the long-run line is the risk price in +{eq}`eq:long-run-price-o`, and the dashed line shares the same value at +$\gamma_o^g = 0$ but with slope equal to the local Brownian risk price +$-\gamma_o^s$. + +The gap between the two slopes is the *persistence correction*; the +dashed line is a slope comparator, not the actual Breeden local +expected-return frontier (which is state dependent in $X^f$ and $X^o$). + +```{code-cell} ipython3 +finite_difference = ( + required_return_for_growth_exposure(0.001) + - required_return_for_growth_exposure(-0.001) +) / 0.002 + +print(f"finite-difference slope = {finite_difference:.6f}") +print(f"formula = {long_run_price_o:.6f}") +``` + +## Assumptions behind the scenes + +The examples above make the eigenfunction calculation look routine. + +For finite-state chains and the affine model, it really is; Perron-Frobenius theory and closed-form algebra handle every requirement. + +But in a general state space, three things can go wrong, each corresponding to one of the assumptions we have been carrying. + +The rest of this section examines each in turn. + +### Issue 1: $\hat M$ might fail to be a martingale + +A positive eigenfunction $\phi$ gives us a candidate martingale $\hat M$ +from {eq}`eq:mhat`, but $\hat M$ is only a nonnegative +local martingale, hence a supermartingale. + +A supermartingale is not enough to define a probability measure: we need +$\mathbb{E}[\hat M_t] = 1$, i.e. a genuine martingale, the content of Assumption 6.1 +in {cite:t}`HansenScheinkman2009`. + +A standard way to verify this is a two-sided **Girsanov construction**: +write the drift and jump distortion induced by $\hat M$, check that the +distorted Markov process is well-behaved, and verify that the reverse +density (the inverse of $\hat M$) is locally integrable. + +### Issue 2: the twisted process might fail to be stable + +Even with $\hat M$ a martingale, the long-run limit +{eq}`eq:long-run-limit` requires that the twisted process actually settles +into a steady state. + +This is where stochastic stability (our trio of stationary distribution, +irreducibility of the skeleton, and Harris recurrence) does real work. + +The affine example illustrates this concretely, since we *rejected* one +of the two algebraically valid eigenfunctions because it implied an +explosive twisted square-root process. + +### Issue 3: a principal eigenfunction might not exist + +In a general state space, even *existence* of a strictly positive +eigenfunction is not automatic. + +A standard sufficient condition starts with a **Lyapunov-type drift bound**: +there is a function $V \geq 1$ on the state space and a constant $a_0$ such +that + +$$ + \frac{\mathbb A V}{V} \leq a_0 . +$$ + +Roughly: $V$ doesn't grow too fast under the semigroup. + +With this in hand, +for any $\alpha > a_0$ define the **resolvent operator** + +$$ + F_\alpha \psi(x) + = + \int_0^\infty + \exp(-\alpha t)\, + \mathbb{E}\!\left[ + M_t\, \frac{V(X_t)}{V(x)}\, \psi(X_t) + \,\Big|\, X_0=x + \right] dt . +$$ (eq:existence-resolvent) + +$F_\alpha$ is the Laplace transform of the semigroup generated by the +*rescaled* multiplicative functional $M_t V(X_t)/V(X_0)$. + +The existence proof then proceeds in three steps: + +1. **Irreducibility for the resolvent.** There exists a reference measure + $\nu$ such that $F_\alpha\mathbf 1_\Lambda(x) > 0$ for every $x$ + whenever $\nu(\Lambda) > 0$, so the resolvent doesn't "miss" any + region of state space. + +2. **Nummelin minorization.** Irreducibility yields a *bounded nonnegative + function* $s$ on the state space, with $\int s\, d\nu > 0$, such that + for every nonnegative $\psi$, + + $$ + F_\alpha \psi(x)\, \geq\, s(x) \int \psi\, d\nu . + $$ + + The function $s$ (often called the *minorization function*) measures + how strongly the resolvent dominates a fixed reference measure $\nu$. + +3. **Eigenfunction extraction.** The minorization, combined with additional + boundedness or strengthened drift assumptions, identifies a critical + spectral value for $F_\alpha$ and an associated positive + eigenfunction. + + - Inverting the resolvent transform produces a positive + eigenfunction for the original semigroup. + +These steps are all nontrivial and are out of scope for this lecture. + +The details are in Section 9 of {cite:t}`HansenScheinkman2009`. + +We can summarize the chain of conditions as: + +| Want | Need | +|:---|:---| +| A factorization {eq}`eq:hs-factorization` | A positive eigenfunction $\phi$ | +| $\hat M$ to define a probability measure | $\hat M$ is a martingale (Assumption 6.1) | +| The long-run limit {eq}`eq:long-run-limit` | Stochastic stability of the twisted process | +| A unique principal eigenfunction | Stability selects among positive eigenfunctions | + +In the finite-state case, all four follow from one Perron-Frobenius +calculation; in the affine model, they reduce to picking the right root of +a quadratic. In general, each must be checked separately. + +The full theory in {cite:t}`HansenScheinkman2009` also delivers stronger +$L^p$ approximation results and Lyapunov criteria for stochastic stability, +which we don't reproduce here. + +## Summary + +The Hansen-Scheinkman approach studies long-run risk by studying +positive eigenfunctions of valuation semigroups. + +The main steps are: + +1. Model discounting, growth, or cumulated returns by a positive + multiplicative functional $M$. + +2. Build the semigroup + $\mathbb M_t\psi(x)=\mathbb{E}[M_t\psi(X_t)\mid X_0=x]$. + +3. When $M = VS$ is the product of a valuation functional and an SDF, + impose the local pricing restriction that $VS$ is a martingale; for + cash-flow valuation semigroups $\mathbb Q_t = GS$, the pricing + restriction is on $S$ alone, and $G$ enters only as a growth twist. + +4. Solve the principal eigenvalue problem + $\mathbb A\phi=\rho\phi$. + +5. Use the factorization + $M_t=\exp(\rho t)\hat M_t\phi(X_0)/\phi(X_t)$. + +6. Under the twisted probability measure induced by $\hat M$, use stability + to obtain long-run approximations of the form {eq}`eq:long-run-limit`. + +In finite-state problems, this is Perron-Frobenius theory. + +In affine diffusion problems, exponential-affine eigenfunctions often produce +closed-form formulas. + +The long-run risk prices that emerge can differ sharply from local risk prices +when shocks move persistent state variables. + +This persistence effect is the economic channel emphasized in long-run risk +asset-pricing models and in the empirical work of {cite:t}`hansen2008consumption`. + +## Exercises + +```{exercise} +:label: lrr_ex1 + +Consider a two-state Markov chain with intensity matrix + +$$ +U = +\begin{bmatrix} + -\lambda & \lambda \\ + \mu & -\mu +\end{bmatrix}. +$$ + +Let the multiplicative functional have decay rate $r_1>0$ in state 1, decay +rate $r_2=0$ in state 2, and no jumps. + +1. Write down the generator matrix $A$. + +2. Find the principal eigenvalue $\rho$ in terms of $\lambda$, $\mu$, and +$r_1$. + +3. Verify numerically with $\lambda=0.4$, $\mu=0.6$, and $r_1=0.05$. + +4. Show that $-r_1 < \rho < 0$. +``` + +```{solution-start} lrr_ex1 +:class: dropdown +``` + +Here is one solution: + +*1.* The generator is + +$$ +A = +\begin{bmatrix} + -\lambda-r_1 & \lambda \\ + \mu & -\mu +\end{bmatrix}. +$$ + +*2.* The characteristic equation is + +$$ + \rho^2 + (\lambda+\mu+r_1)\rho + \mu r_1 = 0. +$$ + +Hence the principal eigenvalue is the larger root + +$$ +\rho += +\frac{ + -(\lambda+\mu+r_1) + + \sqrt{(\lambda+\mu+r_1)^2 - 4\mu r_1} +}{2}. +$$ + +*3.* Numerical verification: + +```{code-cell} ipython3 +λ, μ, r1 = 0.4, 0.6, 0.05 + +disc = (λ + μ + r1) ** 2 - 4 * μ * r1 +ρ_formula = (-(λ + μ + r1) + np.sqrt(disc)) / 2 + +U_ex = np.array([[-λ, λ], + [μ, -μ]]) +r_ex = np.array([r1, 0.0]) +κ_ex = np.zeros((2, 2)) + +A_ex = build_generator(U_ex, r_ex, κ_ex) +ρ_numeric, φ_numeric = principal_eigenpair(A_ex) + +print(f"formula ρ = {ρ_formula:.8f}") +print(f"numeric ρ = {ρ_numeric:.8f}") +print(f"difference = {abs(ρ_formula-ρ_numeric):.2e}") +``` + +*4.* Let + +$$ +q(x)=x^2+(\lambda+\mu+r_1)x+\mu r_1. +$$ + +Then $q(0)=\mu r_1>0$ and + +$$ +q(-r_1) += +-\lambda r_1 +<0. +$$ + +Since the parabola opens upward, one root lies in $(-r_1,0)$. + +The principal eigenvalue is the larger root, so $-r_1<\rho<0$. + +```{solution-end} +``` + +```{exercise} +:label: lrr_ex2 + +In the affine model, compute the local and long-run prices of exposure to +$B^o$ for + +$$ + \xi_o \in \{0.1, 0.2, 0.5, 1, 2, 5\}. +$$ + +Use the formulas + +$$ + \text{local price} = -\gamma_o^s +$$ + +and + +$$ + \text{long-run price} + = + -\gamma_o^s + - \frac{\beta_o^s}{\xi_o}\sigma_o . +$$ + +Explain why the two prices converge as $\xi_o \to \infty$. +``` + +```{solution-start} lrr_ex2 +:class: dropdown +``` + +Here is one solution: + +```{code-cell} ipython3 +ξ_vals = np.array([0.1, 0.2, 0.5, 1.0, 2.0, 5.0]) +local_vals = np.full_like(ξ_vals, -params_sdf["γ_o"]) +long_vals = (-params_sdf["γ_o"] + - (params_sdf["β_o"] / ξ_vals) * params_sdf["σ_o"]) + +for ξ, lp, lrp in zip(ξ_vals, local_vals, long_vals): + print(f"ξ_o = {ξ:3.1f}: local = {lp:.4f}, long-run = {lrp:.4f}") + +fig, ax = plt.subplots() +ax.plot(ξ_vals, local_vals, "--", lw=2, label="local") +ax.plot(ξ_vals, long_vals, "o-", lw=2, label="long-run") +ax.set_xscale("log") +ax.set_xlabel("$\\xi_o$") +ax.set_ylabel("risk price") +ax.legend() +plt.show() +``` + +As $\xi_o$ increases, $X^o$ mean reverts faster. + +A shock to $B^o$ then has a shorter-lived effect on future expected growth. + +The persistence term $(\beta_o^s/\xi_o)\sigma_o$ converges to zero, so the +long-run price converges to the local price. + +```{solution-end} +``` + +```{exercise} +:label: lrr_ex3 + +Consider a three-state chain with states {expansion, normal, contraction}, +intensity matrix + +$$ +U = +\begin{bmatrix} + -0.40 & 0.30 & 0.10 \\ + 0.20 & -0.50 & 0.30 \\ + 0.10 & 0.20 & -0.30 +\end{bmatrix}, +$$ + +decay-rate vector $r = (0.06, 0.04, 0.01)$, and no jumps in the +multiplicative functional. Let $\psi=(3,1,2)$. + +1. Compute the principal eigenpair $(\rho,\phi)$ and twisted stationary +distribution $\hat\varsigma$, and report the theoretical limit + +$$ + \phi \sum_i \frac{\psi_i}{\phi_i}\hat\varsigma_i . +$$ + +2. Plot + +$$ + \max_i + \left| + \exp(-\rho t)(\mathbb M_t\psi)_i + - + \phi_i \sum_j \frac{\psi_j}{\phi_j}\hat\varsigma_j + \right| +$$ + +on a logarithmic scale. + +3. Compare the convergence rate to the spectral gap between the largest and +second-largest real parts of the eigenvalues of $A$. +``` + +```{solution-start} lrr_ex3 +:class: dropdown +``` + +Here is one solution: + +```{code-cell} ipython3 +state_names = ["expansion", "normal", "contraction"] + +U3 = np.array([[-0.40, 0.30, 0.10], + [ 0.20, -0.50, 0.30], + [ 0.10, 0.20, -0.30]]) + +r3 = np.array([0.06, 0.04, 0.01]) +κ3 = np.zeros((3, 3)) + +A3 = build_generator(U3, r3, κ3) +ρ3, φ3 = principal_eigenpair(A3) +A3_hat = twisted_generator(A3, ρ3, φ3) +ς3 = stationary_distribution(A3_hat) + +ψ = np.array([3.0, 1.0, 2.0]) +limit = φ3 * np.sum((ψ / φ3) * ς3) + +print("limit:") +for name, value in zip(state_names, limit): + print(f" {name:11s} {value:.6f}") + +t_vals = np.linspace(0.1, 40, 300) +errors = np.array([ + np.max(np.abs(np.exp(-ρ3 * t_val) * expm(t_val * A3) @ ψ - limit)) + for t_val in t_vals +]) + +eigenvalues = eig(A3, right=False) +real_parts = np.sort(eigenvalues.real)[::-1] +gap = real_parts[0] - real_parts[1] + +fig, ax = plt.subplots() +ax.semilogy(t_vals, errors, lw=2) +ax.set_xlabel("$t$") +ax.set_ylabel("error") +plt.show() + +print(f"spectral gap = {gap:.6f}") +``` + +The normalized semigroup converges at an exponential rate governed by the +separation between the dominant eigenvalue and the remaining eigenvalues. + +In this finite-state example, that separation is the spectral gap computed +above. + +```{solution-end} +``` + +```{exercise} +:label: lrr_ex_local_mg + +Derive the local martingale restriction +{eq}`eq:local-martingale-restriction` from Itô's formula. + +Let $M = \exp(A)$ for the additive functional $A$ in +{eq}`eq:additive-functional`, with parameters $(\beta,\gamma,\kappa)$. + +1. Decompose $A_t = A_t^c + A_t^j$ into its continuous and pure-jump parts +and write down $dA_t^c$ and the jump magnitudes $\Delta A_t$. + +2. Apply Itô's formula for semimartingales to $f(a) = e^a$ to show that + +$$ + dM_t + = + M_{t-}\, dA_t^c + + \tfrac{1}{2}\, M_{t-}\, d\langle A^c, A^c\rangle_t + + M_{t-}\big(\exp[\Delta A_t] - 1\big)\quad\text{at jumps}. +$$ + +3. Use $d\langle A^c, A^c\rangle_t = \gamma^\top\gamma\, dt$ and rewrite the +jump term as an integral against the random counting measure $\zeta$. + +4. Split $\zeta$ into its compensator $\eta(dy \mid X_{t-})\, dt$ and the +compensated martingale measure +$\tilde\zeta = \zeta - \eta(dy\mid X_{t-})\, dt$. + +5. Collect drift (predictable) and martingale terms and conclude that $M$ is +a local martingale iff the drift vanishes at every state, which gives +{eq}`eq:local-martingale-restriction`. +``` + +```{solution-start} lrr_ex_local_mg +:class: dropdown +``` + +Here is one solution. + +*1.* From the parameterization {eq}`eq:additive-functional`, + +$$ + dA_t^c = \beta(X_t)\, dt + \gamma(X_{t-})^\top\, dB_t, + \qquad + \Delta A_t = \kappa(X_t, X_{t-}) \text{ at a jump time}. +$$ + +*2.* For $f(a) = e^a$ we have $f'(a) = f''(a) = e^a$, so $f'(A_{t-}) = +f''(A_{t-}) = M_{t-}$. + +The [(generalized) Itô's formula](https://almostsuremath.com/2010/01/25/the-generalized-ito-formula/) for a semimartingale gives + +$$ + dM_t + = + f'(A_{t-})\, dA_t^c + + \tfrac{1}{2}\, f''(A_{t-})\, d\langle A^c, A^c\rangle_t + + \big[f(A_t) - f(A_{t-})\big] . +$$ + +Since $A_t = A_{t-} + \Delta A_t$ at a jump, $f(A_t) - f(A_{t-}) = +M_{t-}\big(\exp[\Delta A_t] - 1\big)$, which is the stated expression. + +*3.* Substituting $d\langle A^c, A^c\rangle_t = \gamma(X_{t-})^\top +\gamma(X_{t-})\, dt$ and rewriting the jump contribution as an integral +against the random counting measure $\zeta$ of $(X, A)$ gives + +$$ +\begin{aligned} +\frac{dM_t}{M_{t-}} +&= +\beta(X_t)\, dt ++ \gamma(X_{t-})^\top dB_t ++ \tfrac{1}{2}\,\gamma(X_{t-})^\top\gamma(X_{t-})\, dt +\\ +&\quad ++ \int \big(\exp[\kappa(y, X_{t-})] - 1\big)\, \zeta(dy, dt) . +\end{aligned} +$$ + +*4.* Writing $\zeta = \tilde\zeta + \eta(dy\mid X_{t-})\, dt$ separates the +jump integral into a martingale and a predictable drift contribution: + +$$ +\int \big(\exp[\kappa(y,X_{t-})] - 1\big)\zeta(dy,dt) += +\int\big(\exp[\kappa(y,X_{t-})] - 1\big)\tilde\zeta(dy,dt) ++ \int\big(\exp[\kappa(y,X_{t-})] - 1\big)\eta(dy\mid X_{t-})\, dt . +$$ + +*5.* Collecting drift and martingale terms, + +$$ +\begin{aligned} +\frac{dM_t}{M_{t-}} +&= +\bigg[\beta(X_t) ++ \tfrac{1}{2}\gamma^\top\gamma ++ \int\big(\exp[\kappa(y,X_{t-})] - 1\big)\,\eta(dy\mid X_{t-})\bigg] dt +\\ +&\quad ++ \gamma^\top dB_t ++ \int\big(\exp[\kappa(y,X_{t-})] - 1\big)\,\tilde\zeta(dy,dt) . +\end{aligned} +$$ + +The Brownian and compensated-jump terms are local martingales, so $M$ is a +local martingale iff the bracketed drift vanishes for every state $x$, +giving {eq}`eq:local-martingale-restriction`. + +```{solution-end} +``` + +```{exercise} +:label: lrr_ex4 + +Derive the closed-form expression for the extended generator in +{eq}`eq:extended-generator`. + +Take the jump-diffusion setting in which the Markov state satisfies + +$$ + dX_t^c = \xi(X_t)dt + \Gamma(X_t)dB_t +$$ + +between jumps, with $\Sigma = \Gamma\Gamma^\top$ and jump compensator +$\eta(dy \mid x)$. + +Let $M = \exp(A)$ for the additive functional $A$ in +{eq}`eq:additive-functional` and let $\phi$ be a smooth, strictly positive +function. + +Recall from {prf:ref}`lrr-def-extended-generator` that +$\mathbb A\phi = \chi$ if + +$$ + N_t = M_t\phi(X_t) - \phi(X_0) - \int_0^t M_s \chi(X_s)\, ds +$$ + +is a local martingale. The task therefore has two pieces: identify the +predictable drift of $M_t\phi(X_t)$ to read off a candidate $\chi$, and +verify that the residual $N_t$ really is a local martingale. + +(1) Apply Itô's formula to $Y_t = \exp(A_t)\phi(X_t)$ between jumps and +show that the continuous part of $dY_t$ has drift + +$$ + M_t + \left[ + (\xi + \Gamma\gamma)^\top + \frac{\partial \phi}{\partial x} + + \frac{1}{2} + \operatorname{trace}\!\left( + \Sigma \frac{\partial^2 \phi}{\partial x \partial x^\top} + \right) + + \left(\beta + \frac{\gamma^\top \gamma}{2}\right)\phi + \right] dt . +$$ + +(2) Show that at a jump time $t$ with $X_{t-}=x$ and $X_t=y$, + +$$ + \Delta Y_t = M_{t-}\big[\exp[\kappa(y,x)]\phi(y) - \phi(x)\big] , +$$ + +and conclude that the predictable jump compensator contributes drift + +$$ + M_{t-} + \int + \big\{ + \exp[\kappa(y,x)]\phi(y) - \phi(x) + \big\} + \eta(dy \mid x)\, dt . +$$ + +(3) Decompose + +$$ + \exp[\kappa(y,x)]\phi(y) - \phi(x) + = + \exp[\kappa(y,x)] + \big[\phi(y) - \phi(x)\big] + + \big[\exp[\kappa(y,x)] - 1\big]\phi(x), +$$ + +combine with part (1) to obtain the full predictable drift coefficient +$\chi(x)$, and check that it matches the closed form +{eq}`eq:extended-generator`. + +(4) Identify the continuous Itô +integrand from part (1) as a local martingale $N^c_t$ and the compensated +jump sum from part (2) as a local martingale $N^j_t$. + +Show that the +semimartingale decomposition of $Y_t = M_t\phi(X_t)$ implies + +$$ + M_t\phi(X_t) - \phi(X_0) - \int_0^t M_s\, \chi(X_s)\, ds + = N^c_t + N^j_t , +$$ + +which is a local martingale. Conclude via +{prf:ref}`lrr-def-extended-generator` that $\mathbb A \phi = \chi$. +``` + +```{solution-start} lrr_ex4 +:class: dropdown +``` + +Here is one solution: + +*(1)* Set $g(a, x) = e^a \phi(x)$, so that $Y_t = g(A_t, X_t)$. + +Between jumps, the continuous parts of $A$ and $X$ are + +$$ + dA_t^c = \beta(X_t)\, dt + \gamma(X_t)^\top dB_t, + \qquad + dX_t^c = \xi(X_t)\, dt + \Gamma(X_t)\, dB_t , +$$ + +with quadratic covariations + +$$ + d\langle A^c, A^c\rangle_t = \gamma^\top \gamma\, dt, + \qquad + d\langle X^c, X^c\rangle_t = \Sigma\, dt, + \qquad + d\langle A^c, X^c\rangle_t = \Gamma\gamma\, dt . +$$ + +The partial derivatives of $g$ satisfy + +$$ + \partial_a g = g, + \quad + \partial_{aa} g = g, + \quad + \partial_x g = e^a \frac{\partial \phi}{\partial x}, + \quad + \partial_{ax} g = e^a \frac{\partial \phi}{\partial x}, + \quad + \partial_{xx} g = e^a \frac{\partial^2 \phi}{\partial x \partial x^\top} . +$$ + +Itô's formula yields a continuous local martingale $N^c_t$ (the $dB_t$ +part) plus the drift + +$$ +\begin{aligned} + M_t \Big[ + \beta \phi + + \tfrac{1}{2}\gamma^\top \gamma\, \phi + + \xi^\top \tfrac{\partial \phi}{\partial x} + + \tfrac{1}{2}\operatorname{trace}\!\big(\Sigma\, \tfrac{\partial^2 \phi}{\partial x \partial x^\top}\big) + + (\Gamma\gamma)^\top \tfrac{\partial \phi}{\partial x} + \Big]\, dt . +\end{aligned} +$$ + +Grouping the gradient terms gives the expression in the question. + +*(2)* At a jump time $t$, +$\Delta A_t = \kappa(X_t, X_{t-}) = \kappa(y, x)$, so +$M_t = M_{t-}\exp[\kappa(y,x)]$ and + +$$ + \Delta Y_t + = M_t \phi(X_t) - M_{t-}\phi(X_{t-}) + = M_{t-}\big[\exp[\kappa(y,x)]\phi(y) - \phi(x)\big] . +$$ + +The sum of jumps minus its predictable compensator is a local martingale +$N^j_t$, and the compensator itself contributes the predictable drift +quoted in the question. + +*(3)* Adding the jump drift from (2) to the continuous drift from (1), the +predictable drift of $Y_t = M_t \phi(X_t)$ at state $x$ is $M_t\, \chi(x)\, dt$ +with + +$$ +\begin{aligned} + \chi(x) + &= + (\xi + \Gamma\gamma)^\top \frac{\partial \phi}{\partial x} + + \frac{1}{2}\operatorname{trace}\!\left( + \Sigma \frac{\partial^2 \phi}{\partial x \partial x^\top} + \right) + + \left(\beta + \frac{\gamma^\top \gamma}{2}\right)\phi(x) + \\ + &\quad + + \int \exp[\kappa(y,x)]\big[\phi(y) - \phi(x)\big]\, \eta(dy \mid x) + + \phi(x)\int \big[\exp[\kappa(y,x)] - 1\big]\, \eta(dy \mid x) . +\end{aligned} +$$ + +Collecting the terms multiplying $\phi(x)$ recovers +{eq}`eq:extended-generator`. + +*(4)* Putting the two martingale +pieces together and integrating the drift, steps (1) and (2) give the +semimartingale decomposition + +$$ + M_t \phi(X_t) + = + \phi(X_0) + + \int_0^t M_s\, \chi(X_s)\, ds + + N^c_t + N^j_t . +$$ + +Rearranging, + +$$ + N_t + := + M_t \phi(X_t) - \phi(X_0) - \int_0^t M_s\, \chi(X_s)\, ds + = N^c_t + N^j_t , +$$ + +which is a local martingale because it is a sum of local martingales. + +This is exactly the property required by +{prf:ref}`lrr-def-extended-generator`, so $\chi = \mathbb A \phi$. + +```{solution-end} +``` diff --git a/lectures/ls_learning.md b/lectures/ls_learning.md new file mode 100644 index 000000000..590172add --- /dev/null +++ b/lectures/ls_learning.md @@ -0,0 +1,1678 @@ +--- +jupytext: + text_representation: + extension: .md + format_name: myst + format_version: 0.13 + jupytext_version: 1.17.1 +kernelspec: + display_name: Python 3 (ipykernel) + language: python + name: python3 +--- + +(ls_learning)= +```{raw} jupyter +
+ + QuantEcon + +
+``` + +# Least Squares Learning in Self-Referential Models + +```{contents} Contents +:depth: 2 +``` + +## Overview + +This lecture is a companion to {doc}`rational_learning_re`, which presents the +Bray-Kreps perspective on rational learning. + +We examine the related but distinct question of whether *least squares* learning +converges to a rational expectations equilibrium in self-referential models. + +We present the framework of {cite:t}`MarcetSargent1989jet` for studying +**least squares learning** in a class of **self-referential** linear stochastic models. + +A self-referential model is one where the *actual* law of motion for the +economy depends on the *perceived* law of motion of agents within it. + +In a rational expectations equilibrium (REE) the two coincide: the +perceived and actual laws of motion are the same. + +But if agents start away +from equilibrium and update their beliefs by running least squares regressions, +will they converge to the REE? + +{cite:t}`MarcetSargent1989jet` answer this question by using a powerful +technique from systems-control engineering: the differential equation +approach of {cite:t}`Ljung1977`. + +The key insight is that the stochastic difference equation of belief +evolution can be approximated by a deterministic ordinary differential +equation (ODE) in the limit. + +Almost-sure convergence can be studied through the stability of that ODE. + +Local stability of the small ODE is closely related to local convergence, while +global almost-sure convergence also requires boundedness and +domain-of-attraction conditions. + +The framework unifies and extends earlier work by {cite:t}`Bray1982` and +{cite:t}`BraySavin1986` and connects naturally to the distinction between learning +*within* a rational expectations equilibrium (Bayesian updating inside a +correctly specified model) and learning *about* one (adapting an OLS estimator +whose data-generating process shifts with beliefs) discussed in +{cite:t}`BrayKreps1987`. + + + +Let's begin with the imports we'll use throughout. + +```{code-cell} ipython3 +import numpy as np +import matplotlib.pyplot as plt +from numpy import linalg as la +from scipy.integrate import solve_ivp +from scipy.optimize import fsolve +``` + +Before simulating anything, we describe the object being learned. + +## The self-referential structure + +### Perceived and actual laws of motion + +At each date $t$, agents hold a **perceived law of motion** summarized by a +parameter matrix $\beta_t$. + +They believe that the variable $z_{1t}$ they care +about evolves according to + +$$ +z_{1t} = \beta_t z_{2,t-1} + \eta_t , +$$ (eq:perceived_lom) + +where $z_{2t}$ is a vector of variables agents use to forecast $z_{1,t+1}$, and +$\eta_t$ is orthogonal to all past $z_2$'s. + +Because agents optimize (or behave) on the basis of this belief, their actions +feed back into the economy. + +To write the actual law of motion for the full state vector +$z_t = (z_{1t}, z_{1t}^c)^\top$, partition $A(\beta_t)$ conformably with +$(z_{2,t-1}^c, z_{2,t-1})$ as +$A(\beta_t) = [A_c(\beta_t)\; A_2(\beta_t)]$. + +$$ +z_t = \begin{bmatrix} + 0 & T(\beta_t) \\ + A_c(\beta_t) & A_2(\beta_t) + \end{bmatrix} + \begin{bmatrix} z_{2,t-1}^c \\ z_{2,t-1} \end{bmatrix} + + \begin{bmatrix} V(\beta_t) \\ B(\beta_t) \end{bmatrix} u_t , +$$ (eq:actual_lom) + +where $u_t$ is IID white noise with covariance $\Sigma$. + +The mapping $T$ is the key object, as it maps the *perceived* coefficient $\beta$ +to the coefficient that *actually* governs $z_{1t}$ in equilibrium. + +A +**rational expectations equilibrium** is a fixed point $\beta_f = T(\beta_f)$. + +### The learning scheme + +Agents update $\beta_t$ each period using **recursive least squares** (RLS). + +Define $R_t$ as a running estimate of the second-moment matrix $E z_{2t}z_{2t}^\top$. + +Updating equations are + +$$ +\beta_t^\top += +\beta_{t-1}^\top ++ \frac{\alpha_t}{t} R_{t-1}^{-1} +\left\{ +z_{2,t-2} z_{2,t-2}^\top +\bigl[ T(\beta_{t-1}) - \beta_{t-1} \bigr]^\top ++ z_{2,t-2} u_{t-1}^\top V(\beta_{t-1})^\top +\right\}, +$$ (eq:rls_beta) + +$$ +R_t = R_{t-1} + \frac{\alpha_t}{t} \bigl[ z_{2,t-1} z_{2,t-1}^\top - R_{t-1}/\alpha_t \bigr] , +$$ (eq:rls_R) + +where $\{\alpha_t\}$ is a positive, non-decreasing sequence with $\alpha_t \to 1$ +as $t \to \infty$. + +When $\alpha_t = 1$ for all $t$, equations +{eq}`eq:rls_beta`-{eq}`eq:rls_R` reduce to **ordinary least squares** updated +recursively. + +### Lagged and contemporaneous data + +The recursion above is written with *lagged information*, so the estimate +$\beta_t$ uses observations available through date $t-1$. + +{cite:t}`MarcetSargent1989jet` also treat a *contemporaneous-data* +version in which agents update using $z_{1t}$ and $z_{2,t-1}$ at date $t$. + +That timing creates simultaneous determination, because $z_t$ depends on the +same estimate $\beta_t$ that is being updated from $z_t$. + +An extra requirement is that the date-$t$ system must have a unique solution +$(\beta_t, R_t, z_t)$ for each history. + +If this uniqueness condition holds, and if the regularity and boundedness +conditions used below also hold, convergence is still governed by the same full +ODE {eq}`eq:full_ode` and small ODE {eq}`eq:small_ode`. + +```{note} +As {cite:t}`BraySavin1986` and {cite:t}`BrayKreps1987` emphasize, the RLS algorithm +cannot be derived from Bayes' rule applied to a correctly specified model, because +during the learning transition the data-generating process is non-stationary --- +beliefs shift the equilibrium, which shifts the data. + +The algorithm is +*"irrational"* in the sense that it acts as if the environment were stationary, +when it is not. +``` + +Thus, any state variable that matters for the actual law of motion must appear +among the regressors in the perceived law. + +## Why a differential equation governs the limit + +The RLS recursion {eq}`eq:rls_beta`-{eq}`eq:rls_R` is a *stochastic difference equation* with two key features. + +First, the *step size* in front of each update is $\alpha_t / t$, which shrinks to zero as $t$ grows. + +Second, the bracketed expression on the right-hand side of {eq}`eq:rls_beta` is, at the long-run average values of the regressors and noise, just the discrepancy $T(\beta_{t-1}) - \beta_{t-1}$ that measures how far perceived beliefs are from the law of motion they actually generate. + +Combine these two facts and a clear picture emerges. + +The recursion makes only small adjustments to $\beta_t$ each period and those adjustments average out, by the law of large numbers, to the deterministic drift $T(\beta) - \beta$. + +As the gain $\alpha_t/t$ vanishes, the time-rescaled trajectory $\beta_t$ looks more and more like a solution to the continuous-time differential equation + +$$ +\frac{d\beta}{dt} = T(\beta) - \beta . +$$ (eq:small_ode) + +To compare the ODE with RLS after $t$ observations, evaluate the ODE at $\tau_t = \sum_{s=1}^t \alpha_s/s$, the total step size accumulated by the learning algorithm. + +When $\alpha_t=1$, this accumulated step size is $\tau_t = \sum_{s=1}^t 1/s \approx \log t$. + +This idea, due to {cite:t}`Ljung1977`, is what lets {cite:t}`MarcetSargent1989jet` reduce the analysis of a noisy adaptive learning rule to the much easier study of a deterministic ODE. + +The rest of this section makes the connection precise. + +## The governing ODE + +### Small and full ODEs + +The *small ODE* {eq}`eq:small_ode` keeps only the drift in $\beta$, holding the variance estimator $R$ at its long-run value. + +Its rest points are precisely the rational expectations equilibria of the model: $\dot\beta = 0$ if and only if $T(\beta) = \beta$. + +The *full ODE* tracks both $\beta$ and $R$ jointly: + +$$ +\frac{d}{dt}\begin{bmatrix} \beta^\top \\ R \end{bmatrix} += \begin{bmatrix} R^{-1} M_{z_2}(\beta)\,[T(\beta) - \beta]^\top \\ M_{z_2}(\beta) - R \end{bmatrix} , +$$ (eq:full_ode) + +where $M_{z_2}(\beta) = \mathbb{E}[z_{2t}z_{2t}^\top]$ is computed at the stationary distribution of $z_{2t}$ that prevails when agents believe the perceived law has constant parameter $\beta$. + +The fixed point of {eq}`eq:full_ode` is $(\beta_f, R_f)$ with $R_f = M_{z_2}(\beta_f)$ — the same $\beta_f$ as the small ODE, paired with the second-moment matrix consistent with it. + +### Regularity assumptions + +{cite:t}`MarcetSargent1989jet` distinguish two groups of assumptions, with quite different roles. + +The first five are standard regularity conditions on the operator $T$, the shocks $u_t$, and the gain sequence; they are usually easy to check in applications. + +Let $D_s \subset \mathbb{R}^{n_1 \times n_2}$ be the set on which +$T(\beta)$, $A(\beta)$, $B(\beta)$, $V(\beta)$ are well defined and the +eigenvalues of + +$$ +\begin{bmatrix} +0 & T(\beta) \\ +A_c(\beta) & A_2(\beta) +\end{bmatrix} +$$ + +are less than one in modulus, so that the state process induced by belief +$\beta$ is covariance-stationary. + +```{prf:assumption} Unique REE +:label: ass-ms-a1 + +The operator $T$ has a unique fixed point $\beta_f = T(\beta_f)$ with $\beta_f \in D_s$. +``` + +```{prf:assumption} Smoothness of T, A, B, V +:label: ass-ms-a2 + +$T$ is twice differentiable and $A, B, V$ each have one derivative in $D_s$. +``` + +```{prf:assumption} Nonsingular limit covariance +:label: ass-ms-a3 + +The covariance matrix $M_{z_2}(\beta_f)$ is nonsingular. +``` + +```{prf:assumption} Gain sequence +:label: ass-ms-a4 + +For all $t$, $\alpha_t > 0$; $\alpha_t$ is non-decreasing in $t$; $\alpha_t \to 1$ as $t \to \infty$; and $\limsup_{t \to \infty} t\,|\alpha_t - \alpha_{t-1}| < \infty$. +``` + +```{prf:assumption} Shock moments +:label: ass-ms-a5 + +The vector $u_t$ is serially independent, and $E|u_{it}|^p < \infty$ for all $p > 1$ and all $i = 1, \ldots, m$. +``` + +These five say: there is a unique target, the model is smooth around it, the regression has a well-defined precision matrix in the limit, the gain shrinks at the right speed, and the shocks have enough moments for laws of large numbers to work. + +The remaining two are *boundedness* conditions. + +They are needed because Ljung's theorem requires the relevant sample path to +return to a bounded region infinitely often. + +In this model that includes the regressor process $z_{2t}$ and the covariance +estimate $R_t$. + +```{prf:assumption} Boundedness along a subsequence +:label: ass-ms-a6 + +There exist a set $\Omega_0$ with $\mathbb{P}(\Omega_0) = 1$, random variables $C_1(\omega)$ and $C_2(\omega)$, and a subsequence $\{t_k(\omega)\}$ such that + +$$ +|z_{2t_k}(\omega)| < C_1(\omega) \quad\text{and}\quad |R_{t_k}(\omega)| < C_2(\omega) +$$ + +for all $\omega \in \Omega_0$ and all $k = 1, 2, \ldots$. +``` + +```{prf:assumption} Sample path stays in a workable domain +:label: ass-ms-a7 + +Either the compact-state version or the projection-set version holds. + +- *Compact-state version.* + - $D_1 = D_2 = \mathbb{R}^{n_1 \times (n_2)^3}$. + - There exists a compact $D' \subset D_s$ that contains $\beta_{t_k}(\omega)$ for all $k$ and all $\omega \in \Omega_0$. + - For every initial condition $(\beta(0), R(0))$ with $\beta(0) \in D'$ and $R(0)$ bounded as in {prf:ref}`ass-ms-a6`, the $\beta$-component of the trajectory of {eq}`eq:full_ode` remains in a closed subset of $D_s$. + +- *Projection-set version.* + - $D_2$ is closed. + - $D_1$ is open and bounded. + - $\beta \in D_s$ for every $(\beta, R) \in D_1$. + - Trajectories of {eq}`eq:full_ode` with initial conditions in $D_2$ never leave a closed subset of $D_1$. +``` + +{prf:ref}`ass-ms-a6` is automatic when the regressors $z_{2t}$ are *exogenous* and ergodic, but it can be delicate when $z_{2t}$ contains endogenous variables. + +{prf:ref}`ass-ms-a7` is satisfied in the compact-state version when the model has a natural bounded domain on which $T$ is well-defined; otherwise the projection-set version corresponds to using the projection facility described below. + +Let $D_A$ denote the domain of attraction of the unique equilibrium $(\beta_f, R_f)$ of {eq}`eq:full_ode`. + +### Convergence of least squares + +```{prf:proposition} Least-squares convergence +:label: prop-ms-convergence + +Assume {prf:ref}`ass-ms-a1`, {prf:ref}`ass-ms-a2`, +{prf:ref}`ass-ms-a3`, {prf:ref}`ass-ms-a4`, {prf:ref}`ass-ms-a5`, +and {prf:ref}`ass-ms-a6`. + +If either + +- the compact-state version of {prf:ref}`ass-ms-a7` is satisfied and + $D' \subset D_A$, or +- the projection-set version of {prf:ref}`ass-ms-a7` is satisfied and + $D_1 \subset D_A$, + +then $\beta_t \to \beta_f$ almost surely as $t \to \infty$. +``` + +{prf:ref}`prop-ms-convergence` reduces the problem of almost-sure convergence +of recursive least squares to checking the *stability* of the ODE +{eq}`eq:full_ode` at $(\beta_f, R_f)$ and guaranteeing the boundedness of the +sample path. + +### Stability governs convergence + +Let $\mathcal{M}$ be the Jacobian matrix of $T(\beta) - \beta$ evaluated at the +REE $\beta_f$: + +$$ +\mathcal{M} = \frac{d\,\operatorname{col}(T(\beta) - \beta)}{d\,\operatorname{col}(\beta)^\top}\Bigg|_{\beta=\beta_f} , +$$ (eq:jacobian) + +and let $h(\beta, R)$ denote the Jacobian of the right-hand side of the full +ODE {eq}`eq:full_ode` after stacking $(\beta^\top, R)$ into a column vector. + +```{prf:proposition} Jacobian reduction +:label: prop-ms-jacobian-eigenvalues + +The matrix $h(\beta_f, R_f)$ has $(n_2)^2$ repeated eigenvalues equal to +$-1$; its remaining $n_1 \times n_2$ eigenvalues coincide with the +eigenvalues of $\mathcal{M}$. +``` + +Consequently: + +* If all eigenvalues of $\mathcal{M}$ have *strictly negative real parts*, both + {eq}`eq:small_ode` and {eq}`eq:full_ode` are locally stable. + +* Under the boundedness and domain-of-attraction conditions in + {prf:ref}`prop-ms-convergence`, this local stability can be used to obtain + almost-sure convergence of $\beta_t$ to $\beta_f$. + +* If any eigenvalue of $\mathcal{M}$ has *positive real part*, then the next + proposition shows that convergence is impossible. + +```{prf:proposition} Necessity +:label: prop-ms-necessity + +Assume {prf:ref}`ass-ms-a1`, {prf:ref}`ass-ms-a2`, +{prf:ref}`ass-ms-a3`, {prf:ref}`ass-ms-a4`, and {prf:ref}`ass-ms-a5`. + +1. Let $\hat\beta \neq \beta_f$ and suppose $M_{z_2}(\hat\beta)$ is positive + definite and $\hat\beta \in \mathrm{int}(D_2)$. + + Then $\mathbb{P}(\beta_t \to \hat\beta) = 0$. + +2. If $h(\beta_f, R_f)$ has at least one eigenvalue with strictly positive real + part, then $\mathbb{P}(\beta_t \to \beta_f) = 0$. +``` + +The first part says that recursive least squares cannot settle on a +non-equilibrium belief in the interior of the admissible domain. + +If learning has a limit, that limit must be a fixed point of $T$. + +The second part says that local instability is not just slow convergence. + +If the REE is unstable for the learning ODE, convergence to that REE has +probability zero. + +The stability condition $\mathrm{Re}(\lambda_i(\mathcal{M})) < 0$ for all $i$ is +what is called **E-stability** (See {cite:t}`Evans1985`): +the REE is a stable rest point of the expectational dynamics +$\dot\beta = T(\beta) - \beta$. + +E-stability plays the role here that prior support plays in Bayesian learning: +it tells us when the learning process can find its way to the equilibrium. + +### The projection facility + +E-stability is the local condition that makes the REE attractive for the +learning ODE. + +By itself, it is not an almost-sure convergence theorem. + +The stochastic recursion must also remain in a bounded region where the ODE +approximation is valid. + +Conversely, a strictly positive eigenvalue rules out convergence to the REE, +while boundary cases with zero real parts are not covered by the theorem. + +Ljung's theorem requires the learning process and the relevant regressors to +return to bounded regions with probability one. + +The **projection facility** is a procedure that enforces boundedness of the +estimated coefficients and covariance matrix. + +#### What the projection facility does + +The full learning algorithm augments the plain RLS update with a constraint set +$D_1 \supset D_2$ in $(\beta, R)$-space. + +After each unconstrained RLS step +produces a candidate $(\tilde\beta_t, \tilde R_t)$, the projection facility +enforces: + +$$ +(\beta_t, R_t) = \begin{cases} + (\tilde\beta_t,\, \tilde R_t) & \text{if } (\tilde\beta_t, \tilde R_t) \in D_1 , \\ + \text{some point in } D_2 & \text{otherwise.} +\end{cases} +$$ (eq:projection) + +The set $D_1$ is chosen so that the model remains well-defined (e.g., $R_t$ +stays positive definite; $\beta_t$ stays in a region where $T(\beta)$ is +well-defined and the state process is covariance-stationary). + +The set $D_2 +\subset D_1$ is a slightly smaller "safe" region to which the algorithm is +retracted whenever it threatens to leave $D_1$. + +Without the projection facility, the stochastic path $(\beta_t, R_t)$ might +temporarily wander to regions where the system {eq}`eq:actual_lom` is +non-stationary (e.g., an explosive VAR). + +The projection facility keeps $(\beta_t, R_t)$ inside a chosen admissible +region. + +When regressors include endogenous variables, the separate boundedness +condition {prf:ref}`ass-ms-a6` still has to control $z_{2t}$ along a +subsequence. + +Formally, {cite:t}`MarcetSargent1989jet` require that trajectories of the full +ODE {eq}`eq:full_ode` originating in $D_1$ do not leave $D_1$. + +This is often checked by verifying that the full vector field points toward the +interior at the boundary $\partial D_1$. + +```{prf:corollary} +:label: cor-ms-projection-dichotomy + +Assume {prf:ref}`ass-ms-a1`, {prf:ref}`ass-ms-a2`, +{prf:ref}`ass-ms-a3`, {prf:ref}`ass-ms-a4`, {prf:ref}`ass-ms-a5`, +and {prf:ref}`ass-ms-a6`. + +Suppose also that $(\beta, R) \in D_1$ implies $\beta \in D_s$, and that $D_1$ +is open and bounded with $D_1 \subset D_A$. + +Then for some subsequence $\{t_k(\omega)\}$, + +$$ +\mathbb{P}(\beta_t \to \beta_f) + \mathbb{P}\bigl(\beta_{t_k} \to (D_1 \setminus D_2)\bigr) = 1. +$$ +``` + +The second event has probability zero whenever the ODE trajectories point +inward at $\partial D_1$, in which case +{prf:ref}`cor-ms-projection-dichotomy` reduces to $\beta_t \to \beta_f$ almost +surely. + +#### The exogenous-regressor case + +When the regressors $z_{2t}$ are *exogenous*, so that $E(z_{2t}z_{2t}^\top) = +M_{z_2}(\beta) \equiv M$ does not depend on $\beta$, the verification of the +boundary condition becomes routine. + +Let $H(\beta)$ be the mean-value slope of $T$, i.e. the matrix +satisfying + +$$ +\operatorname{col}\{T(\beta)-T(\beta_f)\} += +H(\beta)\operatorname{col}(\beta-\beta_f). +$$ (eq:corollary2_cond) + +```{prf:corollary} +:label: cor-ms-exogenous + +Consider the algorithm defined by {eq}`eq:rls_beta`-{eq}`eq:rls_R` with +projection rule {eq}`eq:projection`. + +Choose $0 < K' < K < \infty$ and assume + +1. {prf:ref}`ass-ms-a1`, {prf:ref}`ass-ms-a2`, {prf:ref}`ass-ms-a3`, + {prf:ref}`ass-ms-a4`, and {prf:ref}`ass-ms-a5` hold; +2. $z_{2t}$ is exogenous, so that $E(z_{2t}z_{2t}^\top) = M_{z_2}(\beta) \equiv M$; +3. the small ODE $\dot\beta = T(\beta) - \beta$ is globally stable in + $\mathbb{R}^{n_1 \times n_2}$; +4. there exists $\bar\varepsilon > 0$ such that for all + $0 < \varepsilon \leq \bar\varepsilon$ and all $\beta$ with + $|\beta - \beta_f| = K$, every eigenvalue of + $[I(1-\varepsilon) + \varepsilon H(\beta)]^\top + [I(1-\varepsilon) + \varepsilon H(\beta)]$ has modulus less than + $\alpha^2$ with $\alpha < 1$. + +Take +$D_1 = \{(\beta, R) : |\beta - \beta_f| < K\}$ and +$D_2 = \{(\beta, R) : |\beta - \beta_f| \leq K'\}$, and let the projection +rule retract $\beta_t$ to any value with $|\beta - \beta_f| \leq K'$, while +leaving $R_t = \tilde R_t$. + +Then $\beta_t \to \beta_f$ almost surely. +``` + +For the scalar linear examples below, condition (4) reduces to checking that +the feedback slope of $T$ is not too strong. + +For the first four examples below, $T$ is linear and $M_{z_2}$ is independent of $\beta$, so {prf:ref}`cor-ms-exogenous` uses $D_1$ and $D_2$ only to justify the projection argument and leaves the examples with the scalar ODE stability checks. + +$D_1$ and $D_2$ are therefore not economic primitives in the examples below. + +They are proof devices for the projected learning algorithm: $D_1$ is the outer admissible region where the model and ODE remain well defined, and $D_2$ is the smaller region used to reset the estimates if an update tries to leave $D_1$. + +Once the corollary says suitable sets can be chosen, the examples no longer need to display them and can focus on $T$, $\beta_f$, and the local stability slope. + +## Five examples + +We now work through five examples from {cite:t}`MarcetSargent1989jet`. + +Each substantive learning example follows the same template. + +1. Write down the economic equations that determine the equilibrium. +2. Substitute the perceived law of motion for any expectational variables to obtain the actual law of motion as a function of $\beta$. +3. Read off the operator $T$ and the REE $\beta_f = T(\beta_f)$. +4. Check E-stability by computing $\mathcal M = dT/d\beta - I$ at $\beta_f$. +5. Plot the RLS paths, the small ODE evaluated at cumulative-gain time, and the drift $T(\beta)-\beta$. + +In each case, $\beta_t$ is the law of motion agents currently use when making decisions, while $T(\beta_t)$ is the law of motion their decisions actually produce. + +Least-squares learning asks whether repeated observations move $\beta_t$ toward a fixed point of this map. + +The first example is the control case with no self-referential feedback. + +For the remaining scalar examples, the simulation figure appears immediately +after the model description. + +## Example 1: Ordinary linear stochastic difference equations + +The first example has no self-referential component. + +Let the actual law of motion be fixed, with $T(\beta)=\Gamma$ for a stable +matrix $\Gamma$ and with $V(\beta)=I$. + +Economically, this is the control case. + +Agents are estimating a stable, exogenous data-generating process. + +Their beliefs do not feed back into prices, quantities, or future data. + +The REE is $\beta_f=\Gamma$. + +Since $T$ is constant, $H(\beta)=0$ in {eq}`eq:corollary2_cond`. + +The small-ODE Jacobian is $\mathcal{M}=-I$, so the small ODE is globally +stable. + +{prf:ref}`cor-ms-exogenous` then implies that recursive least squares converges almost surely +to the true law of motion. + +In this no-feedback benchmark, the Marcet-Sargent result reduces to the +standard consistency of least squares for stable linear stochastic difference equations. + +## Example 2: Bray's cobweb model + +{cite:t}`Bray1982` studied a simple cobweb economy in which the equilibrium price +satisfies + +$$ +p_t = a + b \beta_t + \tilde{u}_t , +$$ (eq:bray_price) + +where $\beta_t$ is agents' OLS estimate of the price (their point forecast of +$p_t$), and $\tilde{u}_t$ is IID noise with mean zero and variance +$\sigma_u^2$. + +Here the forecast itself is a state variable for the economy. + +If producers expect a high price, their current supply decisions alter the +market-clearing price. + +The parameter $b$ measures the strength of this expectational feedback. + +When $b < 1$, the actual price response is weaker than the forecast error, so +least squares has a force pushing beliefs back toward the fixed point. + +When $b > 1$, the feedback is too strong and the same learning rule moves +beliefs away from the REE. + +The mapping $T$ is simply $T(\beta) = a + b\beta$. + +The REE is + +$$ +\beta_f = \frac{a}{1 - b} , \quad b \neq 1 . +$$ (eq:bray_ree) + +The small ODE is + +$$ +\dot\beta = T(\beta) - \beta = a + b\beta - \beta = a - (1-b)\beta , +$$ (eq:bray_ode) + +which has the unique fixed point $\beta_f = a/(1-b)$. + +Its Jacobian is +$\mathcal{M} = b - 1 < 0$ when $b < 1$. + +Under the boundedness and domain conditions above, RLS then converges almost +surely. + +When $b > 1$, $\mathcal{M} > 0$ and convergence fails. + +The code below sets $a=1$ and $b=0.6$. + +The rational expectations price forecast is then $\beta_f=2.5$. + +The three panels show the noisy RLS paths, the small-ODE approximation, and +the learning drift $T(\beta)-\beta$. + +The next cell sets up the simulator and plotting helpers used in the Bray figures. + +```{code-cell} ipython3 +def simulate_rls_scalar(T_map, σ_u, β0, T_periods=500, N_paths=100, + a_seq=None, seed=0): + """ + Simulate the RLS recursion for z1_t = T(β_t) + u_t, z2_t = 1. + Returns an (N_paths, T_periods) array of belief paths. + """ + rng = np.random.default_rng(seed) + if a_seq is None: + a_seq = np.ones(T_periods) + + β_paths = np.empty((N_paths, T_periods)) + + for i in range(N_paths): + β = β0 + R = 1.0 + + for t in range(T_periods): + α_t = a_seq[t] + z2 = 1.0 + u_t = rng.normal(0, σ_u) + z1 = T_map(β) * z2 + u_t + + R_old = max(R, 1e-8) + β = β + (α_t / (t + 1)) / R_old * z2 * (z1 - β * z2) + R = R + (α_t / (t + 1)) * (z2**2 - R / α_t) + R = max(R, 1e-8) + + β_paths[i, t] = β + + return β_paths + + +def solve_ode_calendar(f_ode, β0, T_periods, a_seq=None): + """ + Solve dβ/dτ = f_ode(β) and evaluate it at RLS cumulative-gain time. + """ + if a_seq is None: + a_seq = np.ones(T_periods) + + periods = np.arange(T_periods + 1) + gains = a_seq / np.arange(1, T_periods + 1) + ode_time = np.concatenate(([0.0], np.cumsum(gains))) + sol = solve_ivp( + lambda τ, y: [f_ode(y[0])], + (0.0, ode_time[-1]), + [β0], + t_eval=ode_time, + method='RK45', + max_step=0.05 + ) + return periods, sol.y[0] + + +def plot_scalar_drift(ax, β_grid, drift, β_f, color): + """Plot the one-dimensional learning drift T(β) - β.""" + ax.plot(β_grid, drift, color=color, lw=2) + ax.axhline(0, color='black', lw=1.5) + ax.axvline(β_f, color='red', ls='--', lw=2, + label=f'$\\beta_f = {β_f:.2f}$') + ax.fill_between(β_grid, drift, 0, where=(drift > 0), + color=color, alpha=0.12) + ax.fill_between(β_grid, drift, 0, where=(drift < 0), + color=color, alpha=0.12) + + for β_arrow in np.linspace(β_grid[20], β_grid[-20], 7): + dβ = np.interp(β_arrow, β_grid, drift) + if abs(dβ) > 1e-10: + ax.annotate( + '', xy=(β_arrow + 0.25 * np.sign(dβ), 0), + xytext=(β_arrow, 0), + arrowprops=dict(arrowstyle='->', color=color, lw=1.8) + ) + + ax.set_xlabel('$\\beta$') + ax.set_ylabel('$T(\\beta) - \\beta$') + ax.legend(fontsize=9) + + +T_sim = 400 +N_sim = 80 +``` + +```{code-cell} ipython3 +--- +mystnb: + figure: + caption: Bray learning dynamics + name: fig-bray-learning-dynamics +--- +a_bray, b_bray, σ_bray = 1.0, 0.6, 1.0 + + +def T_bray(β): + return a_bray + b_bray * β + + +β_f_bray = a_bray / (1 - b_bray) + +β0_bray = 0.0 + +β_paths_bray = simulate_rls_scalar( + T_bray, σ_bray, β0_bray, + T_periods=T_sim, N_paths=N_sim +) + + +def ode_bray(β): + return a_bray + b_bray * β - β + + +t_ode, sol_low = solve_ode_calendar(ode_bray, 0.0, T_sim) +_, sol_high = solve_ode_calendar(ode_bray, 4.5, T_sim) + +β_grid_bray = np.linspace(-0.5, 5.0, 300) +drift_bray = np.array([ode_bray(b) for b in β_grid_bray]) + +fig, axes = plt.subplots(1, 3, figsize=(15, 4.8)) + +ax = axes[0] +for i in range(min(30, N_sim)): + ax.plot(β_paths_bray[i], color='steelblue', alpha=0.25, lw=2) +ax.plot(np.mean(β_paths_bray, axis=0), color='navy', lw=2, + label='cross-path average') +ax.axhline(β_f_bray, color='red', ls='--', lw=2, + label=f'$\\beta_f = {β_f_bray:.2f}$') +ax.set_xlabel('$t$') +ax.set_ylabel('$\\beta_t$') +ax.legend() + +ax = axes[1] +ax.plot( + t_ode, sol_low, color='steelblue', lw=2, + label='ODE at $\\tau_t$, $\\beta_0=0$' +) +ax.plot( + t_ode, sol_high, color='darkorange', lw=2, + label='ODE at $\\tau_t$, $\\beta_0=4.5$' +) +ax.axhline(β_f_bray, color='red', ls='--', lw=2, + label=f'$\\beta_f = {β_f_bray:.2f}$') +ax.set_xlabel('$t$') +ax.set_ylabel('$\\beta(\\tau_t)$') +ax.legend() + +plot_scalar_drift( + axes[2], β_grid_bray, drift_bray, β_f_bray, 'steelblue' +) + +plt.tight_layout() +plt.show() +print(f"REE: β_f = a/(1-b) = {β_f_bray:.4f}") +print(f"Jacobian M = b - 1 = {b_bray - 1:.4f} (< 0: E-stable)") +``` + +The stochastic paths are noisy because prices contain $\tilde u_t$. + +The average path and the ODE paths remove most of that noise and reveal the +mean learning direction. + +## Counterexample: Unstable Bray feedback + +To see what happens when E-stability is violated, repeat Bray's model with +$b > 1$. + +It represents an economy where expectations affect actual prices more than +one-for-one. + +If agents start with a forecast that is too high, the market outcome induced by +that forecast is higher still, so least squares raises the forecast. + +The same logic works in reverse below the REE. + +The REE exists, but it is not learnable by this adaptive rule. + +The same three diagnostic panels now show how beliefs are pushed away from the REE rather than toward it, and the drift panel shows that the learning force points away from the fixed point on both sides. + +```{code-cell} ipython3 +--- +mystnb: + figure: + caption: Unstable Bray dynamics + name: fig-unstable-bray-dynamics +--- +b_unstable = 1.4 + + +def T_unstable(β): + return a_bray + b_unstable * β + + +β_f_unstable = a_bray / (1 - b_unstable) + +β_paths_unstable = simulate_rls_scalar( + T_unstable, σ_bray, β0=0.0, + T_periods=200, N_paths=50 +) + + +def ode_unstable(β): + return T_unstable(β) - β + + +β_grid = np.linspace(-5, 5, 300) +drift = np.array([ode_unstable(b) for b in β_grid]) + +t_ode_un, sol_un_low = solve_ode_calendar(ode_unstable, -4.0, 200) +_, sol_un_high = solve_ode_calendar(ode_unstable, 0.0, 200) + +fig, axes = plt.subplots(1, 3, figsize=(15, 4.8)) + +ax = axes[0] +for i in range(min(30, 50)): + ax.plot(β_paths_unstable[i], color='crimson', alpha=0.3, lw=2) +ax.axhline(β_f_unstable, color='black', ls='--', lw=2, + label=f'$\\beta_f = {β_f_unstable:.2f}$ (unstable)') +ax.set_xlabel('$t$') +ax.set_ylabel('$\\beta_t$') +ax.legend() + +ax = axes[1] +ax.plot( + t_ode_un, sol_un_low, color='crimson', lw=2, + label='ODE at $\\tau_t$, $\\beta_0=-4$' +) +ax.plot( + t_ode_un, sol_un_high, color='steelblue', lw=2, + label='ODE at $\\tau_t$, $\\beta_0=0$' +) +ax.axhline(β_f_unstable, color='black', ls='--', lw=2, + label=f'$\\beta_f = {β_f_unstable:.2f}$') +ax.set_xlabel('$t$') +ax.set_ylabel('$\\beta(\\tau_t)$') +ax.legend() + +plot_scalar_drift( + axes[2], β_grid, drift, β_f_unstable, 'crimson' +) + +plt.tight_layout() +plt.show() +print(f"Jacobian M = b - 1 = {b_unstable - 1:.2f} (> 0: NOT E-stable)") +``` + +## Example 3: Bray-Savin supply-shifter model + +{cite:t}`BraySavin1986` studied a model where + +$$ +p_t = x_t^\top(m + a\beta_{t-1}) + \tilde{u}_t , \quad p_t^e = x_t^\top\beta_{t-1} , +$$ (eq:bs_price) + +with $x_t$ an exogenous supply-shifter, $a$ a scalar feedback parameter, and +agents running an OLS regression of $p$ on $x$. + +This is the same learning problem with one extra economic ingredient: +expectations are conditional on an observed shifter. + +Agents do not merely forecast the average price. + +They estimate how price responds to $x_t$. + +The actual coefficient on $x_t$ is $m+a\beta$, so the perceived slope changes +the true slope generated by the market. + +If $a < 1$, a mistaken slope feeds back into the actual price equation with +attenuation, and the least-squares estimate is pulled toward the REE slope. + +The mapping is $T(\beta) = m + a\beta$ (scalar case), giving + +$$ +\dot\beta = (a-1)\beta + m , \quad \beta_f = \frac{m}{1-a} , +$$ (eq:bs_ode) + +with Jacobian $\mathcal{M} = a - 1 < 0$ iff $a < 1$. + +The simulation below draws the exogenous shifter $x_t$ and lets agents update +the slope in the regression of $p_t$ on $x_t$. + +It uses $a=0.7$. + +The drift panel shows that mistaken slopes are pushed back toward the REE +slope rather than amplified. + +The next cell adapts the RLS simulator to the supply-shifter regression. + +```{code-cell} ipython3 +def simulate_bray_savin(m, a, σ_x, σ_u, β0, T_periods=500, + N_paths=100, seed=0): + """ + Simulate RLS for p_t = x_t (m + a β_t) + u_t. + Agents regress p_t on x_t. + """ + rng = np.random.default_rng(seed) + β_paths = np.empty((N_paths, T_periods)) + + for i in range(N_paths): + β = β0 + R = 1.0 + + for t in range(T_periods): + x_t = rng.normal(0.0, σ_x) + u_t = rng.normal(0.0, σ_u) + p_t = x_t * (m + a * β) + u_t + step = 1.0 / (t + 1) + + R_old = max(R, 1e-8) + β = β + step / R_old * x_t * (p_t - β * x_t) + R = R + step * (x_t**2 - R) + R = max(R, 1e-8) + β_paths[i, t] = β + + return β_paths +``` + +```{code-cell} ipython3 +--- +mystnb: + figure: + caption: Bray-Savin learning dynamics + name: fig-bray-savin-learning-dynamics +--- +m_bs, a_bs = 0.5, 0.7 +σ_x_bs, σ_u_bs = 1.0, 1.0 + + +def T_bs(β): + return m_bs + a_bs * β + + +β_f_bs = m_bs / (1 - a_bs) + +β_paths_bs = simulate_bray_savin( + m_bs, a_bs, σ_x_bs, σ_u_bs, 0.0, + T_periods=T_sim, N_paths=N_sim +) + + +def ode_bs(β): + return T_bs(β) - β + + +t_ode_bs, sol_bs_low = solve_ode_calendar(ode_bs, 0.0, T_sim) +_, sol_bs_high = solve_ode_calendar(ode_bs, 4.0, T_sim) + +β_grid_bs = np.linspace(-0.5, 4.0, 300) +drift_bs = np.array([ode_bs(b) for b in β_grid_bs]) + +fig, axes = plt.subplots(1, 3, figsize=(15, 4.8)) + +ax = axes[0] +for i in range(min(30, N_sim)): + ax.plot(β_paths_bs[i], color='darkorange', alpha=0.25, lw=2) +ax.plot(np.mean(β_paths_bs, axis=0), color='saddlebrown', lw=2, + label='cross-path average') +ax.axhline(β_f_bs, color='red', ls='--', lw=2, + label=f'$\\beta_f = {β_f_bs:.2f}$') +ax.set_xlabel('$t$') +ax.set_ylabel('$\\beta_t$') +ax.legend() + +ax = axes[1] +ax.plot( + t_ode_bs, sol_bs_low, color='darkorange', lw=2, + label='ODE at $\\tau_t$, $\\beta_0=0$' +) +ax.plot( + t_ode_bs, sol_bs_high, color='steelblue', lw=2, + label='ODE at $\\tau_t$, $\\beta_0=4$' +) +ax.axhline(β_f_bs, color='red', ls='--', lw=2, + label=f'$\\beta_f = {β_f_bs:.2f}$') +ax.set_xlabel('$t$') +ax.set_ylabel('$\\beta(\\tau_t)$') +ax.legend() + +plot_scalar_drift( + axes[2], β_grid_bs, drift_bs, β_f_bs, 'darkorange' +) + +plt.tight_layout() +plt.show() +print(f"REE: β_f = m/(1-a) = {β_f_bs:.4f}") +print(f"Jacobian M = a - 1 = {a_bs - 1:.4f} (< 0: E-stable)") +``` + +The interpretation is parallel to Bray's cobweb model. + +The difference is that agents are now learning how prices co-move with an +exogenous variable, not just learning an unconditional mean. + +## Example 4: Hyperinflation / asset prices + +Consider the present-value asset pricing model + +$$ +y_t = \lambda \mathbb{E}_t y_{t+1} + x_t , \quad x_t = \rho x_{t-1} + \varepsilon_t , +$$ (eq:pv_model) + +where $|\lambda| < 1$, $|\rho| < 1$, and agents perceive $y_t = \beta_t x_{t-1}+ v_t$. + +Under the perceived law, $\mathbb{E}_t y_{t+1} = \beta_t x_t$, so {eq}`eq:pv_model` becomes + +$$ +y_t = (\lambda \beta_t + 1) x_t = (\lambda \beta_t + 1)\rho x_{t-1} + (\lambda \beta_t + 1)\varepsilon_t. +$$ + +The coefficient on $x_{t-1}$ in the actual law of motion is therefore $(\lambda \beta_t + 1)\rho$, which gives the operator $T$ below. + +If $y_t$ is a price level, the equation resembles a Cagan-style hyperinflation model. + +If $y_t$ is an asset price and $x_t$ is a dividend or fundamental, it is a present-value relation. + +In both cases, beliefs about the future value of $y$ enter the current value of $y$. + +The product $\lambda\rho$ measures the strength of the forward-looking feedback: $\lambda$ discounts the future and $\rho$ measures how persistent the fundamental is. + +When $|\lambda\rho|<1$, a mistaken perceived coefficient does not amplify without bound. + +The mapping is $T(\beta) = (\lambda\beta + 1)\rho$ and the REE is + +$$ +\beta_f = \frac{\rho}{1 - \lambda\rho} . +$$ (eq:pv_ree) + +The small ODE is + +$$ +\dot\beta = (\lambda\rho - 1)\beta + \rho , +$$ (eq:pv_ode) + +with Jacobian $\mathcal{M} = \lambda\rho - 1 < 0$ for $|\lambda\rho| < 1$, so +the small ODE is stable. + +The convergence theorem then applies under the exogenous-regressor conditions +above. + +The simulation uses $\lambda=0.8$ and $\rho=0.9$, so $\lambda\rho=0.72$. + +This means the feedback from expectations is strong enough to matter but still +less than one. + +The ODE panel below uses $\tau$ itself on the horizontal axis, where $\tau$ is the total step size accumulated by least squares. + +The code simulates the autoregressive fundamental $x_t$ and updates an OLS +regression of $y_t$ on $x_{t-1}$. + +The next cell simulates the autoregressive fundamental and the matching RLS update. + +It keeps the covariance estimate $R_t$ bounded away from zero, mirroring the projection idea above and avoiding misleading early-sample explosions. + +```{code-cell} ipython3 +def simulate_present_value_rls(λ, ρ, σ_ε, β0, T_periods=500, + N_paths=100, seed=0): + """ + Simulate RLS for y_t = (λ β_t + 1) x_t, + x_t = ρ x_{t-1} + ε_t, with regression of y_t on x_{t-1}. + """ + rng = np.random.default_rng(seed) + β_paths = np.empty((N_paths, T_periods)) + σ_x = σ_ε / np.sqrt(1 - ρ**2) + R_min = 0.05 * σ_x**2 + + for i in range(N_paths): + β = β0 + R = σ_x**2 + x_lag = rng.normal(0.0, σ_x) + + for t in range(T_periods): + ε_t = rng.normal(0.0, σ_ε) + x_t = ρ * x_lag + ε_t + y_t = (λ * β + 1.0) * x_t + step = 1.0 / (t + 1) + + R_old = max(R, R_min) + β = β + step / R_old * x_lag * (y_t - β * x_lag) + R = R + step * (x_lag**2 - R) + R = max(R, R_min) + β_paths[i, t] = β + x_lag = x_t + + return β_paths +``` + +```{code-cell} ipython3 +--- +mystnb: + figure: + caption: Present-value learning dynamics + name: fig-present-value-learning-dynamics +--- +λ, ρ_pv, σ_pv = 0.8, 0.9, 1.0 +T_pv_sim = T_sim +N_pv_sim = N_sim + + +def T_pv(β): + return (λ * β + 1) * ρ_pv + + +β_f_pv = ρ_pv / (1 - λ * ρ_pv) + +β_paths_pv = simulate_present_value_rls( + λ, ρ_pv, σ_pv, 0.0, + T_periods=T_pv_sim, N_paths=N_pv_sim +) + + +def ode_pv(β): + return T_pv(β) - β + + +τ_grid_pv = np.linspace(0.0, 30.0, 300) +sol_pv_low = solve_ivp( + lambda τ, y: [ode_pv(y[0])], + (0.0, τ_grid_pv[-1]), + [0.0], + t_eval=τ_grid_pv, + max_step=0.05 +).y[0] +sol_pv_high = solve_ivp( + lambda τ, y: [ode_pv(y[0])], + (0.0, τ_grid_pv[-1]), + [10.0], + t_eval=τ_grid_pv, + max_step=0.05 +).y[0] + +β_grid_pv = np.linspace(-1.0, 7.0, 300) +drift_pv = np.array([ode_pv(b) for b in β_grid_pv]) + +fig, axes = plt.subplots(1, 3, figsize=(15, 4.8)) + +ax = axes[0] +for i in range(min(30, N_pv_sim)): + ax.plot(β_paths_pv[i], color='seagreen', alpha=0.25, lw=2) +ax.plot(np.mean(β_paths_pv, axis=0), color='darkgreen', lw=2, + label='cross-path average') +ax.axhline(β_f_pv, color='red', ls='--', lw=2, + label=f'$\\beta_f = {β_f_pv:.2f}$') +ax.set_xlabel('$t$') +ax.set_ylabel('$\\beta_t$') +ax.legend() + +ax = axes[1] +ax.plot( + τ_grid_pv, sol_pv_low, color='seagreen', lw=2, + label='ODE, $\\beta_0=0$' +) +ax.plot( + τ_grid_pv, sol_pv_high, color='steelblue', lw=2, + label='ODE, $\\beta_0=10$' +) +ax.axhline(β_f_pv, color='red', ls='--', lw=2, + label=f'$\\beta_f = {β_f_pv:.2f}$') +ax.set_xlabel('Accumulated step size $\\tau$') +ax.set_ylabel('$\\beta(\\tau)$') +ax.legend() + +plot_scalar_drift( + axes[2], β_grid_pv, drift_pv, β_f_pv, 'seagreen' +) + +plt.tight_layout() +plt.show() +print(f"REE: β_f = ρ/(1 - lambda*ρ) = {β_f_pv:.4f}") +print(f"Jacobian M = lambda*ρ - 1 = {λ*ρ_pv - 1:.4f} (< 0: E-stable)") +``` + +The REE coefficient is larger than $\rho$ because current prices capitalize +expected future fundamentals. + +Learning converges because each revision in $\beta_t$ changes expectations, +but the discounted persistence term $\lambda\rho$ prevents revisions from +feeding back explosively. + +## Example 5: Investment under uncertainty + +Let's now consider a version of the Lucas-Prescott investment model where agents learn about the +aggregate capital stock $K_t$ by regressing on $(K_{t-1}, w_{t-1})$ where $w_t$ +is an exogenous cost shock. + + +Firms choose investment using a perceived law of motion for aggregate capital. + +Those investment choices then determine the actual law of motion for aggregate +capital through market clearing. + +Learning is therefore about a state variable that agents themselves help +create through their investment decisions. + +The perceived law of motion is + +$$ +K_t = \beta_1 K_{t-1} + \beta_2 w_{t-1} + \eta_t , +$$ + +while the actual law (from firms' optimal investment decisions and market clearing) is + +$$ +K_t = T_1(\beta) K_{t-1} + T_2(\beta) w_{t-1} + V(\beta) u_t , +$$ (eq:inv_actual) + +where the nonlinear mappings $T_1, T_2$ come from solving the firms' linear +quadratic control problems. + +The two coefficients have different economic roles. + +$\beta_1$ describes persistence in aggregate capital, while $\beta_2$ describes +how the exogenous shock $w_t$ affects next period's capital. + +Because the optimal investment rule depends on the whole perceived law of +motion, the map $T$ is nonlinear. + +This is why the larger ODE is harder to analyze here than in the scalar +examples with exogenous regressors. + +The small ODE decomposes as: + +$$ +\dot\beta_1 = T_1(\beta_1) - \beta_1 , \quad +\dot\beta_2 = T_2(\beta_1, \beta_2) - \beta_2 , +$$ (eq:inv_ode) + +and E-stability can be verified analytically for $|\beta_1| < b^{-1/2}$ (where +$b$ is the discount factor). + + +The phase portrait below plots the vector field $T(\beta)-\beta$ over +$(\beta_1,\beta_2)$ space. + +Each arrow shows how the perceived law of motion would be revised if the +economy were currently operating under that belief. + +The plotted trajectories are deterministic ODE paths, not noisy least-squares +sample paths. + +```{code-cell} ipython3 +--- +mystnb: + figure: + caption: Investment phase portrait + name: fig-investment-phase-portrait +--- +def T_invest(β, b=0.95, d=1.0, f=1.0, A1=1.0, N=1.0, ρ_w=0.5): + """Mapping T for the investment model with β = [β1, β2].""" + b1, b2 = β + denom1 = 1 - b1 * b + (1 / d) * f**2 * A1 * N + T1 = (1 - b1 * b) / denom1 + numer2 = 1 - b1 * b + f**2 * A1 * b2 * b * ρ_w + T2 = (-N / (d * (1 - ρ_w * b))) * (numer2 / denom1) * ρ_w + return np.array([T1, T2]) + + +def ode_invest(t, β, **kwargs): + Tb = T_invest(β, **kwargs) + return Tb - β + + +params = dict(b=0.95, d=1.0, f=1.0, A1=1.0, N=1.0, ρ_w=0.5) +β1_bound = params["b"] ** (-0.5) +β_f_inv = fsolve(lambda b: T_invest(b, **params) - b, [0.5, 0.1]) +print(f"REE: β_f = {β_f_inv}") + +eps = 1e-6 +J = np.zeros((2, 2)) +for j in range(2): + e = np.zeros(2) + e[j] = eps + J[:, j] = ( + T_invest(β_f_inv + e, **params) + - T_invest(β_f_inv - e, **params) + ) / (2 * eps) +M = J - np.eye(2) +eigs = la.eigvals(M) +print(f"Jacobian M eigenvalues: {eigs}") +print(f"E-stable: {np.all(eigs.real < 0)}") + +fig, ax = plt.subplots(figsize=(8, 6)) + +b1_grid = np.linspace(-0.1, min(1.0, β1_bound - 1e-3), 20) +b2_grid = np.linspace(-0.8, 0.5, 20) +B1, B2 = np.meshgrid(b1_grid, b2_grid) +U = np.zeros_like(B1) +V_field = np.zeros_like(B2) +for i in range(B1.shape[0]): + for j in range(B1.shape[1]): + β_ij = np.array([B1[i, j], B2[i, j]]) + drift = T_invest(β_ij, **params) - β_ij + U[i, j] = drift[0] + V_field[i, j] = drift[1] + +speed = np.sqrt(U**2 + V_field**2) +speed[speed == 0] = 1e-8 +ax.streamplot(b1_grid, b2_grid, U, V_field, color=speed, + cmap='Blues', density=1.3, linewidth=1) + +starts = [(0.1, 0.0), (0.9, 0.4), (0.98, -0.6), (0.3, -0.7)] +colors_traj = ['red', 'darkorange', 'green', 'purple'] +for (b10, b20), col in zip(starts, colors_traj): + sol = solve_ivp(lambda t, β: ode_invest(t, β, **params), + [0, 30], [b10, b20], + t_eval=np.linspace(0, 30, 300), + method='RK45') + ax.plot(sol.y[0], sol.y[1], color=col, lw=2) + ax.plot(b10, b20, 'o', color=col, ms=7) + +ax.plot(*β_f_inv, 'k*', ms=14, label='REE $\\beta_f$') +ax.set_xlabel('$\\beta_1$', fontsize=12) +ax.set_ylabel('$\\beta_2$', fontsize=12) +ax.legend() +plt.tight_layout() +plt.show() +``` + +The star marks the REE. + +The paths converge because the capital-persistence coefficient $\beta_1$ is +stabilized first, and then the shock coefficient $\beta_2$ adjusts given the +limiting value of $\beta_1$. + +This recursive structure is why the small ODE is tractable even though the full +least-squares system has endogenous regressors. + +## Connection to rational learning + +The framework of {cite:t}`MarcetSargent1989jet` belongs to the program of learning +*about* a rational expectations equilibrium, as distinct from learning *within* +one --- a distinction emphasized by {cite:t}`BrayKreps1987`. + +Learning *within* an REE (the subject of the companion lecture +[](rational_learning_re)) refers to Bayesian inference inside a correctly +specified model. + +In that setting the data-generating process is stationary from +the agent's perspective, and Bayes' rule is fully rationalized. + +**Learning *about* an REE** involves an agent who +does not know the equilibrium price function. + +Because the agent's beliefs shift +the equilibrium price, the data the agent uses to update beliefs are themselves +generated by a non-stationary process. + +As {cite:t}`MarcetSargent1989jet` put it, + +> The models do not incorporate fully optimal behavior or rational expectations, +> because agents operate under the continually falsified assumption that the law of +> motion is time invariant and known for sure. + +Yet it is a compelling rule. + +Convergence holds despite the misspecification whenever E-stability combines with the required boundedness and domain-of-attraction conditions. + +Unlike Bayesian learning, it does not require strong prior assumptions about the statistical structure of the economy. + + +## Summary + +This lecture studied least-squares learning in the self-referential models of +{cite:t}`MarcetSargent1989jet`. + +The central object is the map $T$ from a perceived law of motion to the actual +law of motion generated when agents act on that perception. + +A rational expectations equilibrium is a fixed point of this map. + +Recursive least squares converges to that fixed point when the associated ODE +$\dot\beta = T(\beta)-\beta$ is locally stable and the learning process remains +in a region where the model is well defined. + +It complements rational learning, studied in {doc}`rational_learning_re`, where +Bayesian agents learn *within* an equilibrium structure that is already +specified. + +## Exercises + +```{exercise} +:label: ls_ex1 + +Consider the scalar model with $T(\beta) = a + b\beta$. + +1. Derive a formula for the unique REE $\beta_f$ in terms of $a$ and $b$. + +2. Show that the small ODE $\dot\beta = T(\beta) - \beta$ is globally stable if and only if $b < 1$. + +3. Simulate $N = 200$ paths of length $T = 500$ for $a = 1$ and each of $b \in \{0.3, 0.7, 0.9, 0.99\}$ (all less than 1). + +Plot the cross-path average of $\beta_t$ for each $b$ value on the same figure and comment on how the rate of convergence changes as $b \to 1$. +``` + +```{solution-start} ls_ex1 +:class: dropdown +``` + +Here is one solution: + +*Part 1.* The REE satisfies $\beta_f = T(\beta_f) = a + b\beta_f$, so + +$$ +\beta_f (1 - b) = a \implies \beta_f = \frac{a}{1-b} . +$$ + +*Part 2.* The small ODE is $\dot\beta = a + b\beta - \beta = a - (1-b)\beta$. + +This is linear with slope $-(1-b)$, so the unique fixed point $\beta_f = a/(1-b)$ is globally stable iff $1-b > 0$, i.e., $b < 1$. + +*Part 3.* + +```{code-cell} ipython3 +a_ex, T_ex, N_ex = 1.0, 500, 200 +b_values = [0.3, 0.7, 0.9, 0.99] +colors_ex = ['steelblue', 'darkorange', 'seagreen', 'purple'] + +fig, ax = plt.subplots(figsize=(11, 5)) +for b_val, col in zip(b_values, colors_ex): + def T_fn(β, b_val=b_val): + return a_ex + b_val * β + + paths = simulate_rls_scalar(T_fn, σ_u=1.0, β0=0.0, + T_periods=T_ex, N_paths=N_ex, seed=0) + bf = a_ex / (1 - b_val) + ax.plot(np.mean(paths, axis=0), color=col, lw=2, + label=f'$b={b_val}$, $\\beta_f={bf:.2f}$') + +ax.set_xlabel('$t$') +ax.set_ylabel('$E[\\beta_t]$') +ax.set_title('Convergence Rate Slows as $b \\to 1$') +ax.legend() +plt.tight_layout() +plt.show() +``` + +As $b \to 1$, the Jacobian $\mathcal M = b - 1$ approaches zero, so the ODE +becomes slow to return to the fixed point. + +Convergence still occurs, but it takes longer. + +```{solution-end} +``` + +```{exercise} +:label: ls_ex2 + +{prf:ref}`prop-ms-necessity` states that $\mathbb{P}(\beta_t \to \hat\beta) = 0$ for any $\hat\beta \neq \beta_f$ in the interior. + +1. Using the Bray model with $a=1$, $b=0.6$, simulate 100 paths of length $T = 600$ starting from $\beta_0 = 6$ (far from $\beta_f = 2.5$) and show that paths still converge to $\beta_f$. + +2. Now consider the *unstable* case $b = 1.5$, simulate 50 paths of length $T = 200$ starting from $\beta_0 = -1.9$ (close to the REE $\beta_f = -2$), and describe what happens. +``` + +```{solution-start} ls_ex2 +:class: dropdown +``` + +Here is one solution: + +*Parts 1 and 2.* + +```{code-cell} ipython3 +fig, axes = plt.subplots(1, 2, figsize=(14, 5)) + +def T_st(β): + return 1.0 + 0.6 * β + + +paths_far = simulate_rls_scalar(T_st, 1.0, β0=6.0, + T_periods=600, N_paths=100, seed=1) +ax = axes[0] +for i in range(40): + ax.plot(paths_far[i], color='steelblue', alpha=0.2, lw=2) +ax.plot(np.mean(paths_far, axis=0), color='navy', lw=2, label='average') +ax.axhline(2.5, color='red', ls='--', lw=2, label='$\\beta_f = 2.5$') +ax.set_title('Stable ($b=0.6$): far start still converges') +ax.set_xlabel('$t$') +ax.set_ylabel('$\\beta_t$') +ax.legend() + +def T_un(β): + return 1.0 + 1.5 * β + + +β_f_un = 1.0 / (1 - 1.5) +paths_un = simulate_rls_scalar(T_un, 1.0, β0=-1.9, + T_periods=200, N_paths=50, seed=2) +ax = axes[1] +for i in range(50): + ax.plot(paths_un[i], color='crimson', alpha=0.3, lw=2) +ax.axhline(β_f_un, color='black', ls='--', lw=2, + label=f'$\\beta_f = {β_f_un}$ (unstable)') +ax.set_title('Unstable ($b=1.5$): diverges even near REE') +ax.set_xlabel('$t$') +ax.set_ylabel('$\\beta_t$') +ax.legend() + +plt.tight_layout() +plt.show() +``` + +Geometrically, the slope $dT/d\beta - 1 = b - 1 = 0.5$ is positive at the +REE. + +The ODE therefore pushes $\beta$ away from $\beta_f$ in both directions. + +```{solution-end} +``` + +```{exercise} +:label: ls_ex3 + +The present-value model: effect of $\lambda$ on E-stability + +In the present-value model {eq}`eq:pv_model`, $T(\beta) = (\lambda\beta + 1)\rho$ and the Jacobian is $\mathcal{M} = \lambda\rho - 1$. + +1. For $\rho = 0.9$ and each of $\lambda \in \{0.5, 0.8, 0.95, 0.99\}$, compute $\beta_f$ and $\mathcal{M}$ and determine whether the REE is E-stable. + +2. For the E-stable cases, simulate 100 paths of length $T=400$ and plot representative noisy paths in calendar time, then plot the limiting ODE paths in accumulated-gain time. + +3. At $\lambda = 0.99$, $\mathcal{M} = 0.99\rho - 1 < 0$. + + Simulate paths for this near-boundary case and compare the convergence speed with the $\lambda = 0.5$ case, providing an intuitive explanation. +``` + +```{solution-start} ls_ex3 +:class: dropdown +``` + +Here is one solution: + +*Part 1.* + +```{code-cell} ipython3 +ρ_ex = 0.9 +λ_values = [0.5, 0.8, 0.95, 0.99] + +print(f"{'lambda':>8} {'β_f':>10} {'M = λ*ρ-1':>15} {'E-stable':>10}") +print("-" * 50) +for lv in λ_values: + bf = ρ_ex / (1 - lv * ρ_ex) if abs(lv * ρ_ex) < 1 else float('inf') + M_jac = lv * ρ_ex - 1 + estab = "YES" if M_jac < 0 else "NO" + print(f"{lv:>8.2f} {bf:>10.4f} {M_jac:>15.4f} {estab:>10}") +``` + +*Parts 2 and 3.* + +```{code-cell} ipython3 +fig, axes = plt.subplots(len(λ_values), 2, figsize=(13, 14)) +colors_λ = ['steelblue', 'darkorange', 'seagreen', 'purple'] + +for row, (lv, col) in enumerate(zip(λ_values, colors_λ)): + def ode_fn(β, λ_val=lv): + return (λ_val * β + 1) * ρ_ex - β + + bf = ρ_ex / (1 - lv * ρ_ex) + + paths_λ = simulate_present_value_rls( + lv, ρ_ex, 1.0, β0=0.0, + T_periods=400, N_paths=100, seed=3 + ) + + ax = axes[row, 0] + for i in range(20): + ax.plot(paths_λ[i], color=col, alpha=0.2, lw=2) + ax.axhline(bf, color='red', ls=':', lw=2, + label=f'$\\beta_f={bf:.2f}$') + ax.set_title(f'RLS paths, $\\lambda={lv}$') + ax.set_xlabel('$t$') + ax.set_ylabel('$\\beta_t$') + ax.legend(fontsize=8) + + τ_grid = np.linspace(0.0, 30.0, 300) + sol_low = solve_ivp( + lambda τ, y: [ode_fn(y[0])], + (0.0, τ_grid[-1]), + [0.0], + t_eval=τ_grid, + max_step=0.05 + ).y[0] + sol_high = solve_ivp( + lambda τ, y: [ode_fn(y[0])], + (0.0, τ_grid[-1]), + [1.5 * bf], + t_eval=τ_grid, + max_step=0.05 + ).y[0] + + ax = axes[row, 1] + ax.plot(τ_grid, sol_low, color=col, lw=2, + label='ODE, $\\beta_0=0$') + ax.plot(τ_grid, sol_high, color='black', ls='--', lw=2, + label='ODE, high start') + ax.axhline(bf, color='red', ls=':', lw=2, + label=f'$\\beta_f={bf:.2f}$') + M_jac = lv * ρ_ex - 1 + ax.set_title(f'ODE, $\\mathcal{{M}}={M_jac:.3f}$') + ax.set_xlabel('Accumulated step size $\\tau$') + ax.set_ylabel('$\\beta(\\tau)$') + ax.legend(fontsize=8) + +plt.tight_layout() +plt.show() +``` + +In each row, the left panel shows finite-sample RLS paths in calendar time and the right panel shows deterministic ODE paths in accumulated-gain time. + +When $\lambda=0.99$, $\mathcal M = 0.99\rho-1 \approx -0.109$ is small in absolute +value. + +The ODE is nearly flat near $\beta_f$, so the restoring force is weak and +convergence is slow. + +When $\lambda=0.5$, $\mathcal M=-0.55$, which gives a stronger restoring force +and faster convergence. + +```{solution-end} +``` diff --git a/lectures/misspecified_recovery.md b/lectures/misspecified_recovery.md index 71a073a65..7b360a5c1 100644 --- a/lectures/misspecified_recovery.md +++ b/lectures/misspecified_recovery.md @@ -20,7 +20,7 @@ kernelspec: ``` -# Misspecified recovery +# Misspecified Recovery ```{contents} Contents :depth: 2 diff --git a/lectures/rational_learning_re.md b/lectures/rational_learning_re.md new file mode 100644 index 000000000..21075efe9 --- /dev/null +++ b/lectures/rational_learning_re.md @@ -0,0 +1,1052 @@ +--- +jupytext: + text_representation: + extension: .md + format_name: myst + format_version: 0.13 + jupytext_version: 1.17.1 +kernelspec: + display_name: Python 3 (ipykernel) + language: python + name: python3 +--- + +(rational_learning_re)= +```{raw} jupyter +
+ + QuantEcon + +
+``` + +# Rational Learning and Rational Expectations + +```{contents} Contents +:depth: 2 +``` + +## Overview + +This lecture explores an important question in economic theory: what can agents learn inside a rational expectations equilibrium? + +This question is related to, but distinct from, the adaptive-learning question of whether a rational expectations equilibrium can be justified as a dynamic attractor. + +The starting point is {cite:t}`BrayKreps1987`, which gives a rigorous model of Bayesian learning inside a rational expectations equilibrium. + +In a rational expectations equilibrium, agents use market prices to make inferences about other agents' private information. + +Each agent knows the *statistical relationship* between prices and the underlying payoff-relevant variables and that relationship is *correct* given the equilibrium. + +But this raises a question: where does that knowledge come from? + +Their **rational learning** approach answers a narrower question. + +Agents are uncertain about structural parameters, and the state space is enlarged to include, for each candidate value, the associated equilibrium price and allocation maps. + +Agents then use Bayes' rule to update over those possibilities as prices and returns are observed. + +This lecture develops that Bayesian formulation through an asset-market model. + +The aim is to see what rational learning can explain, and where its limits appear, before turning to the computational illustration. + +The discussion also connects to earlier work by {cite:t}`Bray1982`, {cite:t}`BraySavin1986`, and the rational expectations literature of {cite:t}`Radner1979`, {cite:t}`grossman1976`, and {cite:t}`Jordan1982`. + +Let's start with the following imports + +```{code-cell} ipython3 +import numpy as np +import matplotlib.pyplot as plt +from scipy.optimize import brentq +``` + +## The economy + +The model is a simple asset market built around the recurring information model of {cite:t}`GrossmanStiglitz1980`, repeated across infinitely many dates. + + +### Agents and assets + +Each date is economically disconnected from the others, so agents start each period afresh. + +There are two types of agents and two assets: + +* A **safe asset** with net return normalized to zero. +* A **risky asset** endowed one unit per agent and traded at date $t$ at spot price $p_t$. + +At each date $t = 0, 1, 2, \ldots$ the risky asset yields a gross return $r_t$ at date $t+1/2$. + +An informed signal $s_t$ satisfies + +$$ +r_t = s_t + \epsilon_t, +\qquad +s_t \sim N(\mu_s, \tau^2), +\qquad +\epsilon_t \sim N(0,\sigma^2), +$$ + +where $\{s_t\}$ and $\{\epsilon_t\}$ are IID normal sequences and are mutually independent. + +Common knowledge of the prior moments $(\mu_s, \tau^2)$ is what makes the price observation informative about $\theta^I$, as we will see. + +There are two representative agents: + +* **Agent $I$ (informed)** observes $s_t$ before trading at date $t$. +* **Agent $U$ (uninformed)** observes the equilibrium price $p_t$ but not $s_t$ before trading. + +Both agents observe the previous return before current trading. + +### Preferences + +Agent $n \in \{I, U\}$ has constant absolute risk tolerance $\theta^n$. + +If agent $n$ holds $x^n$ units of the risky asset and $y^n$ units of the safe asset between dates $t$ and $t+1/2$, period utility is + +$$ +-\exp\left[-\frac{x^n r_t + y^n}{\theta^n}\right]. +$$ + +Thus $1/\theta^n$ is the coefficient of absolute risk aversion. + +Given the signal $s_t$, the informed agent's demand is + +$$ +x^I_t += +\frac{\theta^I}{\sigma^2}(s_t - p_t). +$$ (eq:bk-informed-demand) + +Because each of the two agents is endowed with one unit of the risky asset, market clearing is + +$$ +x^I_t + x^U_t = 2. +$$ + +### Rational expectations equilibrium + +If all agents knew $s_t$, agent $n$ would demand + +$$ +x^n_t = \frac{\theta^n}{\sigma^2}(s_t - p_t). +$$ + +With $N$ agents and total risky-asset supply $N$, market clearing gives the **full communication equilibrium price** + +$$ +p_t += +s_t +- +\frac{N\sigma^2}{\sum_{n=1}^N \theta^n}. +$$ (eq:bk-full-communication-price) + +Thus if $\sum_n \theta^n$ is known, the price fully reveals $s_t$. + +Following {cite:t}`Radner1979`, this is called a full communication rational expectations equilibrium. + +Suppose now that $\theta^I$ is unknown to agent $U$. + +Following {cite:t}`BrayKreps1987`, we treat this uncertainty by *expanding the state space*: we let the unknown parameter $\theta^I$ become a coordinate of the state, alongside the per-period shocks $(s_t, \epsilon_t)$. + +Formally, the state space is $\Omega = \Theta \times \Phi^\infty$, where $\Theta = [a,b]$ supports the unknown $\theta^I$ and $\Phi$ supports each $(s_t, \epsilon_t)$. + +Agent $U$ knows $\sigma^2$ and $\theta^U$, and starts with a prior density over $\theta^I$ on $[a,b]$. + +This expansion is what turns the learning problem into Bayesian inference inside a single rational expectations equilibrium on $\Omega$. + +At a date when agent $U$ has posterior density $f$ over $\theta^I$, his own trade reveals $x^I_t=2-x^U_t$ through market clearing. + +Combining this inferred $x^I_t$ with {eq}`eq:bk-informed-demand`, each candidate $\theta^I$ implies + +$$ +s_t += +p_t ++ +\frac{\sigma^2 x^I_t}{\theta^I}. +$$ (eq:bk-signal-implied) + +After trading, agent $U$ observes $r_t$. + +Bayes' rule then updates the posterior over $\theta^I$ using the normal density of the signal implied by {eq}`eq:bk-signal-implied` conditional on the realized return. + +This is the main object learned in the two-agent example. + +Even in this simple case, the equilibrium can be defined recursively but closed-form prices are unavailable. + +## The rational learning equilibrium + +The model has two pieces that interact at each date. + +The first is the within-period equilibrium given the uninformed agent's current posterior on $\theta^I$. + +The second is the Bayesian update of that posterior after the period closes. + +### Uninformed demand given beliefs + +Suppose at date $t$ agent $U$ has posterior density $f_t$ on $\theta^I$, supported on $[a, b]$. + +Suppose the equilibrium price is $p$ and the equilibrium informed trade $X^I = 2 - x^U$ has been inferred from market clearing. + +Conditional on $\theta$, equation {eq}`eq:bk-signal-implied` pins down the signal as $s_t(\theta) = \sigma^2 X^I/\theta + p$. + +Two sources of information about $\theta$ are therefore present at the start of date $t$ trading: the carried-over posterior $f_t(\theta)$ and the Gaussian prior $\phi_s(\cdot;\mu_s,\tau^2)$ on $s_t$ that values some implied signals as more plausible than others. + +Bayes' rule combines them into the *intra-period* posterior + +$$ +f_t^{(p, X^I)}(\theta) +\propto +f_t(\theta)\, +\phi_s\!\left(\frac{\sigma^2 X^I}{\theta} + p\, ;\, \mu_s, \tau^2\right), +$$ (eq:bk-intra-posterior) + +which is the posterior on $\theta^I$ that the agent actually uses to forecast $r_t$ before $r_t$ is observed. + +Conditional on a candidate value $\theta$, the excess payoff on one unit of the risky asset is + +$$ +r_t - p += +\frac{\sigma^2 X^I}{\theta} + \epsilon_t, +\qquad \epsilon_t \sim N(0,\sigma^2). +$$ + +Because CARA preferences have no wealth effects, agent $U$'s problem reduces to + +$$ +\max_{x^U}\, +\mathbb{E}[u^U(x^U, r_t, p)], +\qquad +u^U(x^U, r_t, p) += +-\exp\!\left(-\frac{x^U(r_t-p)}{\theta^U}\right), +$$ + +where the expectation integrates over $\theta^I \sim f_t^{(p, X^I)}$ and $\epsilon_t$. + +Substituting the conditional excess payoff and using the normal moment-generating formula gives + +$$ +\mathbb{E}[u^U] += +-\exp\!\left(\frac{(x^U)^2 \sigma^2}{2(\theta^U)^2}\right) +\int_a^b +f_t(\theta)\, +\phi_s\!\left(\tfrac{\sigma^2 X^I}{\theta} + p; \mu_s, \tau^2\right) +\exp\!\left(-\tfrac{x^U \sigma^2 X^I}{\theta\,\theta^U}\right) +d\theta, +$$ + +up to a $\theta$-independent constant absorbed in normalisation. + +Define the tilted weight + +$$ +w(\theta;\, p, X^I, x^U) += +f_t(\theta)\, +\phi_s\!\left(\tfrac{\sigma^2 X^I}{\theta} + p; \mu_s, \tau^2\right) +\exp\!\left(-\tfrac{x^U \sigma^2 X^I}{\theta\,\theta^U}\right). +$$ (eq:bk-weight) + +The first-order condition rearranges to + +$$ +\frac{x^U}{\theta^U} += +X^I \; +\frac{\int_a^b \theta^{-1}\, w(\theta;\, p, X^I, x^U)\, d\theta} + {\int_a^b w(\theta;\, p, X^I, x^U)\, d\theta}. +$$ (eq:bk-foc) + +The right-hand side is $X^I$ multiplied by a tilted expectation of $1/\theta^I$ under the weighting in {eq}`eq:bk-weight`. + +Equation {eq}`eq:bk-foc` implicitly defines $x^U(p, X^I; f_t)$, the uninformed agent's optimal demand at observed price $p$, conjectured informed trade $X^I$, and prior posterior $f_t$. + +Dependence on $p$ enters through the prior weight $\phi_s$: at higher prices, candidate values of $\theta$ that imply $s_t$ above the prior mean become less plausible, so the agent's demand schedule slopes downward in $p$ as expected. + +### Market clearing + +Equilibrium requires that the informed and uninformed demands sum to the total endowment. + +Substituting {eq}`eq:bk-informed-demand` and the implicit function $x^U(p, X^I; f_t)$, the equilibrium $(p_t, X^I_t)$ satisfies the two equations + +$$ +X^I_t = \frac{\theta^I}{\sigma^2}(s_t - p_t), +\qquad +X^I_t + x^U(p_t, X^I_t; f_t) = 2. +$$ (eq:bk-mc) + +Eliminating $X^I_t$ between the two leaves a single root-finding problem for $p_t$. + +Combining the two equations, the equilibrium price has the form + +$$ +p_t = s_t - \frac{\sigma^2 X^I_t}{\theta^I}. +$$ (eq:bk-price) + +When $f_t$ collapses to a point mass at the true $\theta^I$, equation {eq}`eq:bk-foc` simplifies to $x^U/\theta^U = X^I/\theta^I$, and market clearing gives the full-communication allocation + +$$ +X^I_t = \frac{2\theta^I}{\theta^I + \theta^U}, +\qquad +x^U_t = \frac{2\theta^U}{\theta^I + \theta^U}. +$$ (eq:bk-full-info-trade) + +This is the full-communication allocation we will use to check the simulation. + +### Bayesian update + +After trading, agent $U$ observes $(p_t, x^U_t, r_t)$. + +Market clearing gives $X^I_t = 2 - x^U_t$, and equation {eq}`eq:bk-signal-implied` assigns a candidate $s_t(\theta) = \sigma^2 X^I_t/\theta + p_t$ to each $\theta$. + +Since $s_t \sim N(\mu_s, \tau^2)$ independently of $\epsilon_t \sim N(0,\sigma^2)$, the conditional density of $s_t$ given $r_t$ is Gaussian: + +$$ +g(s\mid r) += +\phi\!\left(s;\, \frac{\sigma^2 \mu_s + \tau^2 r}{\sigma^2 + \tau^2},\, + \frac{\sigma^2 \tau^2}{\sigma^2 + \tau^2}\right), +$$ + +where $\phi(\cdot; m, v)$ denotes the Normal density with mean $m$ and variance $v$. + +Bayes' rule then produces the posterior update + +$$ +f_{t+1}(\theta) +\propto +f_t(\theta)\; +g\!\left(\frac{\sigma^2 X^I_t}{\theta} + p_t \,\Big|\, r_t\right). +$$ (eq:bk-bayes) + +This is the rule we simulate below. + +## Computing the equilibrium + +We discretise the support $[a,b]$ of $\theta^I$ on a fine grid and represent $f_t$ as a vector of density values. + +The three computational primitives are: + +* `uninformed_demand` solves the FOC in {eq}`eq:bk-foc` for $x^U(p, X^I; f)$ by root-finding. +* `equilibrium_price` solves the market-clearing system {eq}`eq:bk-mc` for $p_t$. +* `bayes_update` applies {eq}`eq:bk-bayes` and renormalises. + +```{code-cell} ipython3 +def uninformed_demand(p, XI, f, θ_grid, θ_U, σ2, μ_s, τ2): + """ + Solve the FOC for x^U(p, X^I; f), the uninformed + agent's optimal demand given observed price p, conjectured + informed trade XI, and carried-over posterior density f. + """ + with np.errstate(divide='ignore'): + log_f = np.log(f) + s_implied = σ2 * XI / θ_grid + p + log_phi_s = -0.5 * (s_implied - μ_s)**2 / τ2 # prior weight on s_t + + def foc(xU): + z = xU * σ2 * XI / (θ_grid * θ_U) + log_w = log_f + log_phi_s - z + M = log_w.max() + w = np.exp(log_w - M) + num = np.sum(w / θ_grid) + den = np.sum(w) + return xU / θ_U - XI * num / den + + return brentq(foc, -50.0, 50.0, xtol=1e-10) +``` + +```{code-cell} ipython3 +def equilibrium_price(s_t, θ_I_true, f, θ_grid, θ_U, σ2, μ_s, τ2): + """ + Solve the market-clearing system for the equilibrium + price p_t given signal s_t, true informed risk tolerance + θ_I_true, and posterior f. + """ + def mc_residual(p): + XI = θ_I_true * (s_t - p) / σ2 + xU = uninformed_demand(p, XI, f, θ_grid, θ_U, σ2, μ_s, τ2) + return XI + xU - 2.0 + + return brentq(mc_residual, s_t - 10.0, s_t, xtol=1e-8) +``` + +```{code-cell} ipython3 +def bayes_update(f, θ_grid, p_t, xU_t, r_t, σ2, τ2, μ_s): + """ + Bayesian update of the posterior on θ^I given the date-t + observations (p_t, x^U_t, r_t). + """ + XI = 2.0 - xU_t + s_mean = (σ2 * μ_s + τ2 * r_t) / (σ2 + τ2) + s_var = σ2 * τ2 / (σ2 + τ2) + s_implied = σ2 * XI / θ_grid + p_t + + log_like = -0.5 * (s_implied - s_mean)**2 / s_var + log_like -= log_like.max() # log-shift for stability + f_new = f * np.exp(log_like) + dθ = θ_grid[1] - θ_grid[0] + f_new /= np.sum(f_new) * dθ + return f_new +``` + +The simulation loop chains $(s_t, \epsilon_t)$ shocks through these three functions. + +```{code-cell} ipython3 +def simulate(θ_I_true, θ_U, σ2, μ_s, τ2, + a, b, n_grid, T, prior=None, seed=42): + """ + Simulate T periods of the Bray-Kreps rational-learning equilibrium. + """ + rng = np.random.default_rng(seed) + θ_grid = np.linspace(a, b, n_grid) + dθ = θ_grid[1] - θ_grid[0] + + if prior is None: + f = np.ones(n_grid) / (b - a) + else: + f = prior(θ_grid) + f /= np.sum(f) * dθ + + s_seq = rng.normal(μ_s, np.sqrt(τ2), T) + eps_seq = rng.normal(0.0, np.sqrt(σ2), T) + + XI_path = np.empty(T) + p_path = np.empty(T) + r_path = np.empty(T) + post_mean = np.empty(T + 1) + post_var = np.empty(T + 1) + post_mean[0] = np.sum(θ_grid * f) * dθ + post_var[0] = np.sum((θ_grid - post_mean[0])**2 * f) * dθ + + snap_times = {0, 5, 20, 50, 100, T} + snapshots = {0: f.copy()} + + for t in range(T): + p_t = equilibrium_price( + s_seq[t], θ_I_true, f, θ_grid, θ_U, σ2, μ_s, τ2 + ) + XI = θ_I_true * (s_seq[t] - p_t) / σ2 + xU = 2.0 - XI + r_t = s_seq[t] + eps_seq[t] + f = bayes_update(f, θ_grid, p_t, xU, r_t, σ2, τ2, μ_s) + + XI_path[t] = XI + p_path[t] = p_t + r_path[t] = r_t + post_mean[t + 1] = np.sum(θ_grid * f) * dθ + post_var[t + 1] = np.sum( + (θ_grid - post_mean[t + 1])**2 * f + ) * dθ + if (t + 1) in snap_times: + snapshots[t + 1] = f.copy() + + return dict( + θ_grid=θ_grid, + snapshots=snapshots, + XI_path=XI_path, + p_path=p_path, + r_path=r_path, + post_mean=post_mean, + post_var=post_var, + ) +``` + +## Posterior concentration + +We run the simulation with a uniform prior on $[0.5, 4]$ and true $\theta^I = 2$. + +```{code-cell} ipython3 +params = dict( + θ_I_true=2.0, + θ_U=1.0, + σ2=1.0, + μ_s=1.0, + τ2=1.0, + a=0.5, + b=4.0, + n_grid=300, + T=200, + seed=42, +) + +res = simulate(**params) +``` + +The first picture shows snapshots of the posterior density at selected dates. + +```{code-cell} ipython3 +--- +mystnb: + figure: + caption: posterior density over $\theta^I$ at selected dates + name: fig-rle-posterior-density + image: + alt: Posterior density on theta^I concentrating around the true value +--- +fig, ax = plt.subplots(figsize=(10, 5)) +for t, ft in sorted(res['snapshots'].items()): + ax.plot(res['θ_grid'], ft, lw=2, label=f't = {t}') +ax.axvline(params['θ_I_true'], color='black', ls='--', lw=1.5, + label=r'$\theta^I_{\rm true}$') +ax.set_xlabel(r'$\theta^I$') +ax.set_ylabel('posterior density') +ax.legend() +plt.tight_layout() +plt.show() +``` + +The posterior tightens around $\theta^I_{\rm true} = 2$ as price and return data accumulate. + +The next picture tracks the posterior mean and variance. + +```{code-cell} ipython3 +--- +mystnb: + figure: + caption: posterior mean and variance over time + name: fig-rle-posterior-moments + image: + alt: Posterior mean of theta^I converging to the true value and posterior variance vanishing +--- +fig, axes = plt.subplots(1, 2, figsize=(13, 5)) + +ax = axes[0] +ax.plot(np.arange(params['T'] + 1), res['post_mean'], lw=2) +ax.axhline(params['θ_I_true'], color='red', ls='--', lw=2, + label=r'$\theta^I_{\rm true}$') +ax.set_xlabel('$t$') +ax.set_ylabel(r'$E_t[\theta^I]$') +ax.legend() + +ax = axes[1] +ax.plot(np.arange(params['T'] + 1), res['post_var'], lw=2) +ax.set_xlabel('$t$') +ax.set_ylabel(r'${\rm Var}_t[\theta^I]$') + +plt.tight_layout() +plt.show() +``` + +The posterior mean converges to the truth and the posterior variance vanishes. + +This is the concrete manifestation of weak convergence of posteriors to a point mass at $\theta^I_{\rm true}$, which we describe in general terms below. + +## Equilibrium trades and prices + +The equilibrium informed trade $X^I_t$ depends on the current signal $s_t$, on $\theta^I_{\rm true}$, and on the carried-over posterior $f_t$, all through the market-clearing system {eq}`eq:bk-mc`. + +As $f_t$ tightens around $\theta^I_{\rm true}$, the average $X^I_t$ approaches the full-communication allocation in {eq}`eq:bk-full-info-trade`. + +```{code-cell} ipython3 +--- +mystnb: + figure: + caption: equilibrium trade and prices over time + name: fig-rle-trade-price + image: + alt: Equilibrium informed trade X^I_t and price p_t over time +--- +XI_full = 2 * params['θ_I_true'] / (params['θ_I_true'] + params['θ_U']) +p_mean_full = params['μ_s'] - params['σ2'] * XI_full / params['θ_I_true'] + +fig, axes = plt.subplots(1, 2, figsize=(13, 5)) + +ax = axes[0] +ax.plot(res['XI_path'], lw=2, label='$X^I_t$ (learning)') +ax.axhline(XI_full, color='red', ls='--', lw=2, + label='$X^I$ (full info)') +ax.set_xlabel('$t$') +ax.set_ylabel('$X^I_t$') +ax.legend() + +ax = axes[1] +ax.plot(res['p_path'], lw=1.5, alpha=0.7, label='$p_t$ (learning)') +ax.axhline(p_mean_full, color='red', ls='--', lw=2, + label='$E[p_t]$ (full info)') +ax.set_xlabel('$t$') +ax.set_ylabel('$p_t$') +ax.legend() + +plt.tight_layout() +plt.show() +``` + +The left panel shows $X^I_t$ approaching the full-information allocation as beliefs concentrate. + +The right panel shows the price path, which fluctuates because $p_t$ inherits the variation in $s_t$. + +The simulation illustrates three features of this equilibrium. + +The posterior density on $\theta^I$ concentrates around the true value, the posterior variance vanishes, and the equilibrium informed trade $X^I_t$ converges to its full-information benchmark. + +The next sections identify the theorems behind these outcomes and the assumptions they require. + +We first state the two convergence results of {cite:t}`BrayKreps1987` for the abstract model, then specialize to the two-agent example to pin down the hypotheses that drive concentration on the true $\theta^I$, and finally explain when those hypotheses can fail. + +## Convergence of posterior assessments + +Let $(\Omega, \mathcal F)$ be a measurable space carrying the equilibrium. + +In the two-agent example, $\Omega = \Theta \times \Phi^{\infty}$, where $\Theta = [a,b] \times \{\theta^U\}$ collects the structural parameters, $\Phi$ collects the per-period shocks $(s_t, \epsilon_t)$, and $\mathcal F$ is the product Borel $\sigma$-field. + +Agent $n$ enters date $0$ with a prior probability measure $P^n$ on $(\Omega, \mathcal F)$. + +Let $G_t^n \subseteq \mathcal F$ denote the $\sigma$-field generated by agent $n$'s private information through date $t$, and let + +$$ +H_t^n(p) += +G_t^n \vee \sigma(p_0, p_1, \dots, p_t) +$$ + +be the $\sigma$-field that adds observation of equilibrium prices through date $t$. + +The tail $\sigma$-field is + +$$ +H_\infty^n(p) += +\bigvee_{t \ge 0} H_t^n(p). +$$ + +The first result, due to {cite:t}`BrayKreps1987`, states that the conditional probability of any event converges almost surely. + +```{prf:proposition} +:label: prop-bk-event-convergence + +Fix an agent $n$ and an event $A \in \mathcal F$. + +The process $M_t = \mathbb{E}^n[\mathbf 1_A \mid H_t^n(p)]$ is a $P^n$-bounded martingale with respect to $(H_t^n(p))_{t \ge 0}$, and + +$$ +\lim_{t\to\infty} +\mathbb{E}^n[\mathbf 1_A \mid H_t^n(p)] += +\mathbb{E}^n[\mathbf 1_A \mid H_\infty^n(p)], +\qquad P^n\text{-a.s.} +$$ +``` + +The proof is the bounded martingale convergence theorem, with $M_t \in [0,1]$ supplying the uniform integrability needed for the limit identification. + +{prf:ref}`prop-bk-event-convergence` is convergence of posterior assessments, not convergence to "correct" beliefs. + +Two qualifications are worth stating. + +The "a.s." statement is relative to agent $n$'s own prior $P^n$, so if two priors $P^n$ and $P^{n'}$ are mutually singular, the conclusion need not hold simultaneously on a common $P$-positive event. + +If the priors share a common null collection, simultaneous convergence holds outside a common null set. + +The second result in {cite:t}`BrayKreps1987` sharpens convergence from individual events to the entire posterior measure on the parameter space, given a topological assumption on $\Theta$. + +```{prf:assumption} +:label: assum-bk-borel + +The parameter space $\Theta$ is a complete separable metric (Polish) space, and the Borel $\sigma$-field on $\Theta$ generated by its open sets makes $(\Theta, \mathcal B(\Theta))$ a Borel space. +``` + +In the two-agent example $\Theta = [a,b]$ trivially satisfies this assumption. + +Under {prf:ref}`assum-bk-borel` one can fix regular versions of the conditional probabilities: maps + +$$ +P_t^n: \Omega \to \mathcal P(\Theta), +\qquad +\omega \mapsto P_t^n(\omega), +$$ + +such that for each measurable $A \subseteq \Theta$, $\omega \mapsto P_t^n(\omega)(A)$ is a version of $\mathbb{E}^n[\mathbf 1_{A \times \Phi^\infty} \mid H_t^n(p)](\omega)$, and $P_t^n(\omega) \in \mathcal P(\Theta)$ is a probability measure $P^n$-a.s. + +The sharpened convergence result says these regular versions converge weakly almost surely. + +```{prf:proposition} +:label: prop-bk-measure-convergence + +Under {prf:ref}`assum-bk-borel`, the regular versions $P_t^n$ converge weakly to a regular version $P_\infty^n$, $P^n$-a.s. + +Equivalently, for $P^n$-a.e. $\omega$ and every bounded continuous $f: \Theta \to \mathbb R$, + +$$ +\int_\Theta f \, dP_t^n(\omega) +\xrightarrow[t \to \infty]{} +\int_\Theta f \, dP_\infty^n(\omega). +$$ +``` + +The proof in {cite:t}`BrayKreps1987` applies {prf:ref}`prop-bk-event-convergence` to a countable disjoint partition of $\Theta$ by $1/k$-balls, which exists because $\Theta$ is Polish, and then invokes the Portmanteau characterisation of weak convergence on bounded continuous functions. + +Rational Bayesian learning therefore always produces a limiting posterior measure. + +But {prf:ref}`prop-bk-measure-convergence` alone does not pin down what that limit is, and additional structure is needed before the limit assesses the truth correctly. + +## Sharpening the convergence result + +We now return to the two-agent example and identify hypotheses under which $P_\infty^U$ is a point mass at the true $\theta^I$. + +Write $F_t$ for the CDF of agent $U$'s posterior on $\theta^I$ at date $t$ after observing $(r_{t-1}, p_{t-1}, x^U_{t-1})$ and all earlier data. + +{prf:ref}`prop-bk-measure-convergence` yields a random CDF $F_\infty$ such that $F_t$ converges weakly to $F_\infty$, $P^U$-a.s. + +Three ingredients sharpen this to concentration on the truth, corresponding to the three steps in {cite:t}`BrayKreps1987`. + +```{prf:assumption} +:label: assum-bk-continuity + +The equilibrium uninformed demand $x^U(p, F)$ is continuous in $F$ with respect to weak convergence, uniformly in $p$ on a $P^U$-full-measure set of prices. +``` + +```{prf:assumption} +:label: assum-bk-identification + +For fixed $\theta^U$ and limiting posterior $F_\infty$, the map + +$$ +\theta^I +\mapsto +\mathcal L\{p_\infty(s; F_\infty, \theta^I, \theta^U)\} +$$ + +is injective, where $s$ is drawn from its marginal distribution. + +A sufficient condition is strict stochastic monotonicity of this marginal price distribution in $\theta^I$. +``` + +In the lecture's CARA-Normal setup, these assumptions are plausible under the maintained uniqueness and regularity of the implicit demand and price equations. + +Continuity requires continuous dependence of the FOC root in {eq}`eq:bk-foc` on $F$, not just pointwise continuity of the integrals. + +Identification also uses the full equilibrium map: the equation $p_t = s_t - \sigma^2 X^I_t / \theta^I$ is informative, but $X^I_t$ itself depends on $\theta^I$, $F_t$, and the equilibrium fixed point. + +The IID assumption on $\{s_t\}$, already part of the model, supplies the ergodicity used in step 2 below. + +Under these three assumptions and the IID signal sequence, the limiting posterior in the two-agent example concentrates on the truth. + +```{prf:proposition} +:label: prop-bk-sharpening + +Suppose $\theta^I_{\rm true} \in [a,b]$ and the prior $f_0$ puts positive density in every neighbourhood of $\theta^I_{\rm true}$. + +Under {prf:ref}`assum-bk-borel`, {prf:ref}`assum-bk-continuity`, and {prf:ref}`assum-bk-identification`, and given the IID signal sequence $\{s_t\}$, the limiting posterior on $\theta^I$ satisfies + +$$ +F_\infty += +\delta_{\theta^I_{\rm true}} +\qquad P^U\text{-a.s.} +$$ +``` + +The proof has three steps. + +*Step 1: price functional convergence.* + +{prf:ref}`assum-bk-continuity` and the weak convergence $F_t \Rightarrow F_\infty$ from {prf:ref}`prop-bk-measure-convergence` imply that equilibrium demands $x^U(p, F_t)$ converge to $x^U(p, F_\infty)$. + +Combining with market clearing and the price equation {eq}`eq:bk-price` gives $p_t - p_\infty(s_t; F_\infty, \theta^I, \theta^U) \to 0$ on a $P^U$-full-measure set. + +*Step 2: the limit price distribution is observable.* + +Since the deviation $p_t - p_\infty(s_t; F_\infty, \theta^I, \theta^U) \to 0$ almost surely and $\{s_t\}$ is IID, the empirical distribution of observed prices has the same limit as the empirical distribution of the limiting price functional. + +The latter equals the distribution of $p_\infty(s; F_\infty, \theta^I, \theta^U)$ for $s \sim N(\mu_s, \tau^2)$, and that limit is $H_\infty^U(p)$-measurable as a long-run frequency of an observable sequence. + +*Step 3: identification.* + +{prf:ref}`assum-bk-identification` makes the marginal distribution of $p_\infty$ identify $\theta^I$ given $(F_\infty, \theta^U)$. + +Combined with step 2, this means $\theta^I$ is itself $H_\infty^U(p)$-measurable, so for any subinterval $[c,d] \subseteq [a,b]$ the limiting posterior satisfies $P_\infty^U(\theta^I \in [c,d]) = \mathbf 1_{\{\theta^I_{\rm true} \in [c,d]\}}$. + +Combining steps 1, 2, and 3 yields $F_\infty = \delta_{\theta^I_{\rm true}}$. + +The numerical simulation above is consistent with this result. + +The posterior density on $\theta^I$ collapses to a spike at $\theta^I_{\rm true}=2$, and the equilibrium informed trade $X^I_t$ converges to the full-information value $2\theta^I_{\rm true}/(\theta^I_{\rm true} + \theta^U)$. + +Hence, the path connecting {prf:ref}`prop-bk-event-convergence` (martingale convergence) to {prf:ref}`prop-bk-sharpening` (concentration on the truth) depends on three model-specific ingredients: continuity, ergodicity, and identification. + +## Obstacles to convergence + +It is natural to ask when these ingredients can fail, and what the consequences are for learning. + +### Obstacle 1: failure of continuity + +If {prf:ref}`assum-bk-continuity` fails, step 1 of the proof breaks. + +When the equilibrium price functional is discontinuous in $F$, small changes in beliefs can produce large changes in the information content of prices, and weak convergence of beliefs need not imply convergence of prices. + +{cite:t}`BrayKreps1987` flag this as the most delicate step in their argument. + +Continuity of $x^U(p, F)$ in $F$ is plausible in this lecture's regular CARA-Normal case, but it also requires uniqueness of the FOC solution and continuous dependence of that solution on $F$. + +Verifying the same property in richer market structures often requires non-trivial regularity arguments. + +### Obstacle 2: failure of identification + +If {prf:ref}`assum-bk-identification` fails, step 3 breaks even when steps 1 and 2 succeed. + +Consider a variant with two informed agents and risk tolerances $\theta^{I1}, \theta^{I2}$ both unknown to the uninformed agent. + +With three agents each endowed with one unit of the risky asset, the full-communication formula {eq}`eq:bk-full-communication-price` gives + +$$ +p_t += +s_t +- +\frac{3\sigma^2}{\theta^{I1} + \theta^{I2} + \theta^U}, +$$ + +which depends on $(\theta^{I1}, \theta^{I2})$ only through the sum $\theta^{I1}+\theta^{I2}$. + +{prf:ref}`prop-bk-measure-convergence` still applies, but $F_\infty$ is supported on the level set + +$$ +\{(\theta_1, \theta_2) \in [a,b]^2 : \theta_1 + \theta_2 = \theta^{I1}_{\rm true} + \theta^{I2}_{\rm true}\}, +$$ + +not on the singleton $\{(\theta^{I1}_{\rm true},\theta^{I2}_{\rm true})\}$. + +Convergence occurs, but to a manifold of observationally equivalent parameter values rather than to the truth. + +### Obstacle 3: misspecification + +A separate obstacle arises if the true pricing relation lies outside the agent's prior support. + +{cite:t}`BlumeEasley1982` give a stylised version of this obstacle, and {doc}`likelihood_ratio_process_2` develops the Blume-Easley heterogeneous-beliefs model in this lecture series. + +Each agent entertains competing conditional likelihoods for other agents' information given his own information and the price. + +An equilibrium can exist in which agents assign asymptotic probability one to an incorrect model that gives the observed events positive likelihood, while the true stable price relation receives zero posterior probability because that relation was absent from the prior model class. + +In strict rational learning the prior already covers the truth: it is supported on Bayesian-consistent models in the expanded state space, and positive weight is placed on the true parameter. + +Bayes' rule can only reweight that initial model class, so a pricing relation with zero prior probability stays at zero no matter what data accumulate. + +## Learning within versus learning about a rational expectations equilibrium + +The framework above points to an important conceptual distinction in {cite:t}`BrayKreps1987`. + +### The distinction + +Learning *within* a rational expectations equilibrium is the topic of this lecture. + +It is Bayesian inference inside a correctly specified model: {prf:ref}`assum-bk-borel`, {prf:ref}`assum-bk-continuity`, and {prf:ref}`assum-bk-identification` all hold, and the prior puts positive weight on the truth. + +Agent $U$ is uncertain about $\theta^I$, but for every candidate value he already knows the equilibrium price and allocation maps. + +The expanded-state-space formulation $\Omega = \Theta \times \Phi^\infty$ embeds a rational expectations equilibrium on the larger space, and inference reduces to conditional probability over $\Theta$. + +Learning *about* a rational expectations equilibrium is a fundamentally different exercise. + +The agent does not begin with the equilibrium map embedded in his probability model. + +Instead he must infer the price-state relation from data generated while his own beliefs and behavior co-evolve with the data. + +### The trade-off + +The two notions sit on opposite sides of a precise trade-off. + +A correctly-specified Bayesian learner enjoys the convergence guarantees in {prf:ref}`prop-bk-event-convergence` and {prf:ref}`prop-bk-measure-convergence`, but only because the equilibrium has been built into the prior from date zero. + +An adaptive learner who treats the price-state relation as something to be estimated can hope to discover it from data, but the estimator he uses cannot be derived from Bayes' rule applied to a correctly specified model. + +Bayesian rational learning can update among equilibrium maps already included in the agent's prior, but it does not explain how agents come to obtain those maps in the first place. + +The literature on learning *about* rational expectations equilibria, beginning with {cite:t}`Bray1982` and {cite:t}`BraySavin1986` and extended by {cite:t}`MarcetSargent1989jet`, takes the second side of the trade-off and replaces Bayes' rule with **ordinary least squares** or related recursive estimators. + +The companion lecture {doc}`ls_learning` develops this least-squares-learning framework in self-referential models and traces the resulting dynamics through the associated ordinary differential equation. + +Those rules are computationally tractable and converge in important examples, but they are not the Bayesian update implied by the fully specified rational-learning equilibrium prior. + +## Summary + +This lecture implemented the rational-learning equilibrium of {cite:t}`BrayKreps1987`. + +Posterior assessments converge by bounded martingale convergence ({prf:ref}`prop-bk-event-convergence`), and posterior measures converge weakly under a Polish-Borel assumption ({prf:ref}`prop-bk-measure-convergence`). + +Concentration on the truth additionally requires continuity ({prf:ref}`assum-bk-continuity`), ergodicity, and identification ({prf:ref}`assum-bk-identification`); each obstacle above is a failure of one of these. + +The simulation illustrates both conclusions: the posterior on $\theta^I$ collapses toward $\theta^I_{\rm true}$ and the equilibrium informed trade approaches its full-information value. + +Rational learning describes the limits of Bayesian inference *given* the equilibrium structure; adaptive learning, in {doc}`ls_learning`, describes how that structure can be learned in the first place. + + +## Exercises + +````{exercise} +:label: rle_ex1 + +*Off-center prior* + +The baseline simulation uses a uniform prior on $\theta^I \in [0.5, 4]$. + +1. Re-run the simulation with a prior whose mass sits *above* the true value, for example + +```python +prior = lambda θ: (θ - 0.5)**3 * (4 - θ) +``` + +which peaks near $\theta = 3.1$. + +2. Plot the posterior mean over time alongside the uniform-prior baseline. + +3. Does the posterior eventually concentrate on $\theta^I_{\rm true}$, and how does the speed compare? +```` + +```{solution-start} rle_ex1 +:class: dropdown +``` + +Here is one solution: + +```{code-cell} ipython3 +res_uniform = simulate(**params) + +params_biased = dict(params) +params_biased['prior'] = lambda θ: (θ - 0.5)**3 * (4 - θ) +res_biased = simulate(**params_biased) + +fig, ax = plt.subplots(figsize=(10, 5)) +ax.plot(res_uniform['post_mean'], lw=2, label='uniform prior') +ax.plot(res_biased['post_mean'], lw=2, label='off-center prior') +ax.axhline(params['θ_I_true'], color='black', ls='--', + label=r'$\theta^I_{\rm true}$') +ax.set_xlabel('$t$') +ax.set_ylabel(r'$E_t[\theta^I]$') +ax.legend() +plt.tight_layout() +plt.show() +``` + +The off-center prior starts the posterior mean well above $\theta^I_{\rm true} = 2$, but Bayesian updating drives it down to the truth. + +This is the rational-learning convergence result in action: any prior that puts positive density on $\theta^I_{\rm true}$ eventually concentrates around it. + +```{solution-end} +``` + +```{exercise} +:label: rle_ex2 + +*Speed of learning across $\theta^I$* + +Information from one period about $\theta^I$ comes through the implied signal + +$$ +s_t(\theta) = \frac{\sigma^2 X^I_t}{\theta} + p_t. +$$ + +The sensitivity $|\partial s_t/\partial \theta| = \sigma^2 X^I_t/\theta^2$ depends on the level of $\theta^I_{\rm true}$ through $X^I_t$ and $\theta^{-2}$. + +1. Run the simulation for $\theta^I_{\rm true} \in \{0.8, 2.0, 3.5\}$, holding everything else at the baseline. + +2. Plot the posterior variance on a log scale for each case. + +3. Which value of $\theta^I_{\rm true}$ yields the fastest concentration, and does the result match the sensitivity formula above? +``` + +```{solution-start} rle_ex2 +:class: dropdown +``` + +Here is one solution: + +```{code-cell} ipython3 +fig, ax = plt.subplots(figsize=(10, 5)) +for θ_val in [0.8, 2.0, 3.5]: + params_θ = dict(params) + params_θ['θ_I_true'] = θ_val + res_θ = simulate(**params_θ) + ax.semilogy(res_θ['post_var'], lw=2, + label=fr'$\theta^I_{{\rm true}} = {θ_val}$') +ax.set_xlabel('$t$') +ax.set_ylabel(r'${\rm Var}_t[\theta^I]$ (log scale)') +ax.legend() +plt.tight_layout() +plt.show() +``` + +The smallest $\theta^I_{\rm true}$ produces the steepest decline in posterior variance. + +The reason is that the sensitivity $\sigma^2 X^I_t/\theta^2$ scales as $\theta^{-2}$ for fixed $X^I_t$, so the same noise level conveys much more information about $\theta^I$ when $\theta^I$ is small. + +```{solution-end} +``` + +```{exercise} +:label: rle_ex3 + +*Effect of return noise* + +Larger $\sigma^2$ widens the conditional density of $s_t$ given $r_t$, which one might guess slows learning. + +But $\sigma^2$ also scales the price intercept in {eq}`eq:bk-price`, so price dispersion across candidate $\theta$ grows with $\sigma^2$. + +1. Run the simulation with $\sigma^2 \in \{0.25, 1.0, 4.0\}$, keeping $\tau^2 = 1$ fixed. + +2. Plot the posterior variance on a log scale for each $\sigma^2$. + +3. Explain which effect dominates in terms of the signal-to-noise ratio for inferring $\theta^I$ from the price. +``` + +```{solution-start} rle_ex3 +:class: dropdown +``` + +Here is one solution: + +```{code-cell} ipython3 +fig, ax = plt.subplots(figsize=(10, 5)) +for σ2_val in [0.25, 1.0, 4.0]: + params_σ = dict(params) + params_σ['σ2'] = σ2_val + res_σ = simulate(**params_σ) + ax.semilogy(res_σ['post_var'], lw=2, + label=fr'$\sigma^2 = {σ2_val}$') +ax.set_xlabel('$t$') +ax.set_ylabel(r'${\rm Var}_t[\theta^I]$ (log scale)') +ax.legend() +plt.tight_layout() +plt.show() +``` + +The posterior variance falls *faster* for larger $\sigma^2$. + +To see why, write $\nu=\sigma^2$ and hold the realized trade $X^I_t$ fixed. + +Two nearby values of $\theta$ imply signals separated by approximately + +$$ +\left|\frac{\partial s_t(\theta)}{\partial \theta}\right| += +\frac{\nu |X^I_t|}{\theta^2}. +$$ + +The likelihood compares these implied signals using $g(s\mid r_t)$, whose conditional variance is + +$$ +\operatorname{Var}(s_t\mid r_t) += +\frac{\nu \tau^2}{\nu+\tau^2}. +$$ + +Thus the local signal-to-noise ratio for distinguishing nearby $\theta$ values is proportional to + +$$ +\frac{\nu |X^I_t|/\theta^2} + {\sqrt{\nu\tau^2/(\nu+\tau^2)}} += +\frac{|X^I_t|}{\theta^2} +\sqrt{\frac{\nu(\nu+\tau^2)}{\tau^2}}, +$$ + +This ratio rises with $\nu$ when $\tau^2$ is fixed. + +The price-revelation effect therefore dominates the extra return noise in this experiment. + +```{solution-end} +```