From fe7261079b2296ba66178477aa141a9b8d718592 Mon Sep 17 00:00:00 2001 From: Humphrey Yang Date: Mon, 12 Aug 2024 15:57:47 +1000 Subject: [PATCH 1/5] update minor typos --- lectures/ge_arrow.md | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lectures/ge_arrow.md b/lectures/ge_arrow.md index cbdf63f9f..17ae0863c 100644 --- a/lectures/ge_arrow.md +++ b/lectures/ge_arrow.md @@ -4,10 +4,10 @@ jupytext: text_representation: extension: .md format_name: myst - format_version: 0.12 - jupytext_version: 1.8.2 + format_version: 0.13 + jupytext_version: 1.16.1 kernelspec: - display_name: Python 3 + display_name: Python 3 (ipykernel) language: python name: python3 --- @@ -30,9 +30,9 @@ This lecture presents Python code for experimenting with competitive equilibria * Common beliefs across agents -* A constant relative risk aversion (CRRA) one-period utility function that implies the existence of a representative consumer whose consumption process can be plugged into a formula for the pricing kernel for one-step Arrow securities and thereby determine equilbrium prices before determining an equilibrium distribution of wealth +* A constant relative risk aversion (CRRA) one-period utility function that implies the existence of a representative consumer whose consumption process can be plugged into a formula for the pricing kernel for one-step Arrow securities and thereby determine equilibrium prices before determining an equilibrium distribution of wealth -Diverse endowments across agents provide motivations for individuals to want to reallocate consumption goods across time and Markov states +* Diverse endowments across agents provide motivations for individuals to want to reallocate consumption goods across time and Markov states We impose restrictions that allow us to **Bellmanize** competitive equilibrium prices and quantities @@ -297,7 +297,7 @@ The setup assumes the following infrastructure * Markov states: $s \in S = \left[\bar{s}_1, \ldots, \bar{s}_n \right]$ governed by an $n$-state Markov chain with transition probability $$ -P_{ij} = \Pr \left\{s_{t+1} = \bar{s}_j \mid s_t = \bar{s}_k \right\} +P_{ij} = \Pr \left\{s_{t+1} = \bar{s}_j \mid s_t = \bar{s}_i \right\} $$ * A collection $h=1,\ldots, H$ of $n \times 1$ vectors of $H$ assets that pay off $d^h\left(s\right)$ in state $s$ @@ -349,7 +349,7 @@ In constructing our model, we'll repeatedly encounter formulas that remind us of ### Multi-Step-Forward Transition Probabilities and Pricing Kernels -The $(i,j)$ component of the $k$-step ahead transition probability $P^\ell$ is +The $(i,j)$ component of the $\ell$-step ahead transition probability $P^\ell$ is $$ Prob(s_{t+\ell} = \bar s_j | s_t = \bar s_i) = P^{\ell}_{i,j} @@ -706,7 +706,6 @@ import matplotlib.pyplot as plt np.set_printoptions(suppress=True) ``` - First, we create a Python class to compute the objects that comprise a competitive equilibrium with sequential trading of one-period Arrow securities. From 131c9d860f6adfc15b41d88b0cd285a737f6735e Mon Sep 17 00:00:00 2001 From: Humphrey Yang Date: Thu, 15 Aug 2024 21:32:49 +1000 Subject: [PATCH 2/5] update notes and typos --- lectures/ge_arrow.md | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/lectures/ge_arrow.md b/lectures/ge_arrow.md index 17ae0863c..4f1d3a7c7 100644 --- a/lectures/ge_arrow.md +++ b/lectures/ge_arrow.md @@ -97,11 +97,11 @@ history $s^t$. The history $s^t$ is publicly observable. -Consumer $i$ +Consumer $k$ purchases a history-dependent consumption plan $c^k = \{c_t^k(s^t)\}_{t=0}^\infty$ -Consumer $i$ orders consumption plans by +Consumer $k$ orders consumption plans by $$ U_k(c^k) = \sum_{t=0}^\infty \sum_{s^t} \beta^t u_k[c_t^k(s^t)] @@ -118,7 +118,7 @@ Here $u_k(c)$ is an increasing, twice continuously differentiable, strictly concave function of consumption $c\geq 0$ of one good. -The utility function pf person $k$ satisfies +The utility function of person $k$ satisfies the Inada condition $$ \lim_{c \downarrow 0} u'_k(c) = +\infty.$$ @@ -159,12 +159,12 @@ These enable us to provide a recursive formulation of a consumer's optimization problem. -Consumer $i$'s state at time $t$ is its financial wealth $a^k_t$ and Markov state $s_t$. +Consumer $k$'s state at time $t$ is its financial wealth $a^k_t$ and Markov state $s_t$. -Let $v^k(a,s)$ be the optimal value of consumer $i$'s problem +Let $v^k(a,s)$ be the optimal value of consumer $k$'s problem starting from state $(a, s)$. - * $v^k(a,s)$ is the maximum expected discounted utility that consumer $i$ with current financial wealth $a$ can attain in Markov state $s$. + * $v^k(a,s)$ is the maximum expected discounted utility that Consumer $k$ with current financial wealth $a$ can attain in Markov state $s$. The optimal value function satisfies the Bellman equation @@ -172,6 +172,8 @@ $$ v^k(a, s) = \max_{c, \hat a(s')} \left\{ u_k(c) + \beta \sum_{s'} v^k[\hat a(s'),s'] \pi (s' | s) \right\} $$ +(NOTE: Define $\hat a$ here?) + where maximization is subject to the budget constraint @@ -210,8 +212,8 @@ and $c_{t+1}^k = c^k(s_{t+1})$. A **recursive competitive equilibrium** is an initial distribution of wealth $\vec a_0$, a set of borrowing limits $\{\bar A^k(s)\}_{k=1}^K$, -a pricing kernel $Q(s' | s)$, sets of value functions $\{v^k(a,s)\}_{i=1}^K$, and -decision rules $\{c^k(s), a^k(s)\}_{i=1}^K$ such +a pricing kernel $Q(s' | s)$, sets of value functions $\{v^k(a,s)\}_{k=1}^K$, and +decision rules $\{c^k(s), a^k(s)\}_{k=1}^K$ such that * The state-by-state borrowing constraints satisfy the recursion @@ -226,11 +228,11 @@ solve the consumers' problems; * For all realizations of $\{s_t\}_{t=0}^\infty$, the consumption and asset portfolios $\{\{c^k_t,$ -$\{\hat a^k_{t+1}(s')\}_{s'}\}_i\}_t$ satisfy $\sum_i c^k_t = \sum_i y^k(s_t)$ and -$\sum_i \hat a_{t+1}^k(s') = 0$ +$\{\hat a^k_{t+1}(s')\}_{s'}\}_k\}_t$ satisfy $\sum_k c^k_t = \sum_k y^k(s_t)$ and +$\sum_k \hat a_{t+1}^k(s') = 0$ for all $t$ and $s'$. -* The initial financial wealth vector $\vec a_0$ satisfies $\sum_{i=1}^K a_0^k = 0 $. +* The initial financial wealth vector $\vec a_0$ satisfies $\sum_{k=1}^K a_0^k = 0 $. The third condition asserts that there are zero net aggregate claims in all Markov states. @@ -562,7 +564,7 @@ y^{k}=\left[\begin{array}{c} y^{k}\left(\bar{s}_{1}\right)\\ \vdots\\ y^{k}\left(\bar{s}_{n}\right) -\end{array}\right] \equiv \begin{bmatrix} y^k_1 \cr \vdots \cr v^k_n \end{bmatrix} +\end{array}\right] \equiv \begin{bmatrix} y^k_1 \cr \vdots \cr y^k_n \end{bmatrix} $$ @@ -578,6 +580,8 @@ even if he consumes zero goods forevermore. **Remark:** If we have an Inada condition at zero consumption or just impose that consumption be nonnegative, then in a **finite horizon** economy with sequential trading of one-period Arrow securities there is no need to impose natural debt limits. See the section below on a Finite Horizon Economy. +(NOTE: check equation (25) in week 4 slides -- Inada condition forces the the natural debt limits non-binding in infinite horizon sequential trading) + ### Continuation Wealth Continuation wealth plays an important role in Bellmanizing a competitive equilibrium with sequential @@ -624,6 +628,8 @@ y\left(\bar{s}_{n}\right) \end{array}\right] $$ +(NOTE: Derived using 9.8.1 and Gorman Aggregation) + Note that $\sum_{k=1}^K \psi^k = {0}_{n \times 1}$. **Remark:** At the initial state $s_0 \in \begin{bmatrix} \bar s_1, \ldots, \bar s_n \end{bmatrix}$, From a923146f5b6625f9e3a7b6b88cb00268de94d8fb Mon Sep 17 00:00:00 2001 From: Humphrey Yang Date: Fri, 16 Aug 2024 11:29:52 +1000 Subject: [PATCH 3/5] update --- lectures/ge_arrow.md | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/lectures/ge_arrow.md b/lectures/ge_arrow.md index 4f1d3a7c7..0780647ad 100644 --- a/lectures/ge_arrow.md +++ b/lectures/ge_arrow.md @@ -164,7 +164,7 @@ Consumer $k$'s state at time $t$ is its financial wealth $a^k_t$ and Markov stat Let $v^k(a,s)$ be the optimal value of consumer $k$'s problem starting from state $(a, s)$. - * $v^k(a,s)$ is the maximum expected discounted utility that Consumer $k$ with current financial wealth $a$ can attain in Markov state $s$. + * $v^k(a,s)$ is the maximum expected discounted utility that consumer $k$ with current financial wealth $a$ can attain in Markov state $s$. The optimal value function satisfies the Bellman equation @@ -172,7 +172,7 @@ $$ v^k(a, s) = \max_{c, \hat a(s')} \left\{ u_k(c) + \beta \sum_{s'} v^k[\hat a(s'),s'] \pi (s' | s) \right\} $$ -(NOTE: Define $\hat a$ here?) +(NOTE: Define $\hat a$ here? I think it is trying to distinguish the choice and the equilibrium $a^k(s)$ below?) where maximization is subject to the budget constraint @@ -792,7 +792,6 @@ class RecurCompetitive: n = self.n Q = np.empty((n, n)) - for i in range(n): for j in range(n): ratio = self.u_prime(c[j]) / self.u_prime(c[i]) @@ -943,6 +942,8 @@ print(f'ψ = \n{ex1.continuation_wealths()}') print(f'J = \n{ex1.value_functionss()}') ``` +(NOTE: Continuation wealth flips because of the initial state is now 2) + ### Example 2 ```{code-cell} ipython3 @@ -982,6 +983,18 @@ print("R = ", ex2.R) ex2.Q ``` +(NOTE: The pricing kernal is different because of the aggregate endowments in state 1 and 2 are different now + +```{code-cell} ipython3 +ex2.β * ex2.u_prime(3.5) / ex2.u_prime(2.5) * ex2.P[0,1] +``` + +```{code-cell} ipython3 +ex2.β * ex2.u_prime(2.5) / ex2.u_prime(3.5) * ex2.P[1,0] +``` + +) + ```{code-cell} ipython3 # Risk free rate R ex2.R @@ -1116,6 +1129,7 @@ s = np.array([1, 2, 3]) μ = .9 δ = .05 +# prosperous, moderate, and recession states P = np.array([[1-λ, λ, 0], [μ/2, μ, μ/2], [(1-δ)/2, (1-δ)/2, δ]]) # endowments @@ -1152,6 +1166,7 @@ for i in range(1, 4): ``` ## Finite Horizon +(NOTE: Consider bring finite horizon section above since the class considers the finite horizon cases) The Python class **RecurCompetitive** provided above also can be used to compute competitive equilibrium allocations and Arrow securities prices for finite horizon economies. From a8a0158f28b949029e2971b482feff1eec8c14cd Mon Sep 17 00:00:00 2001 From: Humphrey Yang Date: Sat, 17 Aug 2024 09:08:51 +1000 Subject: [PATCH 4/5] update fix and notes --- lectures/ge_arrow.md | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/lectures/ge_arrow.md b/lectures/ge_arrow.md index 0780647ad..29096a44a 100644 --- a/lectures/ge_arrow.md +++ b/lectures/ge_arrow.md @@ -172,8 +172,7 @@ $$ v^k(a, s) = \max_{c, \hat a(s')} \left\{ u_k(c) + \beta \sum_{s'} v^k[\hat a(s'),s'] \pi (s' | s) \right\} $$ -(NOTE: Define $\hat a$ here? I think it is trying to distinguish the choice and the equilibrium $a^k(s)$ below?) - +(NOTE: We have $\hat a$ here and $a$ below in the definition of **recursive competitive equilibrium**. Is it a typo below or this is intentional?) where maximization is subject to the budget constraint @@ -498,7 +497,7 @@ This follows from agent $k$'s first-order necessary conditions. But with the CRRA preferences that we have assumed, individual consumptions vary proportionately with aggregate consumption and therefore with the aggregate endowment. - * This is a consequence of our preference specification implying that **Engle curves** affine in wealth and therefore satisfy conditions for **Gorman aggregation** + * This is a consequence of our preference specification implying that **Engle curves** are affine in wealth and therefore satisfy conditions for **Gorman aggregation** Thus, @@ -628,8 +627,6 @@ y\left(\bar{s}_{n}\right) \end{array}\right] $$ -(NOTE: Derived using 9.8.1 and Gorman Aggregation) - Note that $\sum_{k=1}^K \psi^k = {0}_{n \times 1}$. **Remark:** At the initial state $s_0 \in \begin{bmatrix} \bar s_1, \ldots, \bar s_n \end{bmatrix}$, @@ -942,8 +939,6 @@ print(f'ψ = \n{ex1.continuation_wealths()}') print(f'J = \n{ex1.value_functionss()}') ``` -(NOTE: Continuation wealth flips because of the initial state is now 2) - ### Example 2 ```{code-cell} ipython3 @@ -983,7 +978,7 @@ print("R = ", ex2.R) ex2.Q ``` -(NOTE: The pricing kernal is different because of the aggregate endowments in state 1 and 2 are different now +NOTE: The pricing kernal is different because of the aggregate endowments in state 1 and 2 are different now ```{code-cell} ipython3 ex2.β * ex2.u_prime(3.5) / ex2.u_prime(2.5) * ex2.P[0,1] @@ -993,7 +988,7 @@ ex2.β * ex2.u_prime(3.5) / ex2.u_prime(2.5) * ex2.P[0,1] ex2.β * ex2.u_prime(2.5) / ex2.u_prime(3.5) * ex2.P[1,0] ``` -) +END OF NOTE ```{code-cell} ipython3 # Risk free rate R @@ -1083,7 +1078,7 @@ print(f'J = \n{ex3.value_functionss()}') For the specification of the Markov chain in example 3, let's take a look at how the equilibrium allocation changes as a function of transition probability $\lambda$. ```{code-cell} ipython3 -λ_seq = np.linspace(0, 1, 100) +λ_seq = np.linspace(0, 0.99, 100) # prepare containers αs0_seq = np.empty((len(λ_seq), 2)) @@ -1166,7 +1161,7 @@ for i in range(1, 4): ``` ## Finite Horizon -(NOTE: Consider bring finite horizon section above since the class considers the finite horizon cases) +(NOTE: Consider bring finite horizon section above since the Python class considers the finite horizon cases) The Python class **RecurCompetitive** provided above also can be used to compute competitive equilibrium allocations and Arrow securities prices for finite horizon economies. From aa3f2f9f7ef234221a158dd724edd90d57bcd83b Mon Sep 17 00:00:00 2001 From: thomassargent30 Date: Sat, 17 Aug 2024 13:28:32 -0600 Subject: [PATCH 5/5] Tom's edits of ge_arrow lecture in intermediate repo --- lectures/ge_arrow.md | 300 ++++++++++++++++++++++--------------------- 1 file changed, 157 insertions(+), 143 deletions(-) diff --git a/lectures/ge_arrow.md b/lectures/ge_arrow.md index 29096a44a..a20513b4b 100644 --- a/lectures/ge_arrow.md +++ b/lectures/ge_arrow.md @@ -28,11 +28,11 @@ This lecture presents Python code for experimenting with competitive equilibria * Common expected utility preferences across agents -* Common beliefs across agents +* Common beliefs among agents * A constant relative risk aversion (CRRA) one-period utility function that implies the existence of a representative consumer whose consumption process can be plugged into a formula for the pricing kernel for one-step Arrow securities and thereby determine equilibrium prices before determining an equilibrium distribution of wealth -* Diverse endowments across agents provide motivations for individuals to want to reallocate consumption goods across time and Markov states +* Differences in their endowments make individuals want to reallocate consumption goods across time and Markov states We impose restrictions that allow us to **Bellmanize** competitive equilibrium prices and quantities @@ -45,7 +45,7 @@ We use Bellman equations to describe * state-by-state natural debt limits for each person -In the course of presenting the model we shall describe these important ideas +In the course of presenting the model we shall encounter these important ideas * a **resolvent operator** widely used in this class of models @@ -172,8 +172,6 @@ $$ v^k(a, s) = \max_{c, \hat a(s')} \left\{ u_k(c) + \beta \sum_{s'} v^k[\hat a(s'),s'] \pi (s' | s) \right\} $$ -(NOTE: We have $\hat a$ here and $a$ below in the definition of **recursive competitive equilibrium**. Is it a typo below or this is intentional?) - where maximization is subject to the budget constraint $$ @@ -212,7 +210,7 @@ and $c_{t+1}^k = c^k(s_{t+1})$. A **recursive competitive equilibrium** is an initial distribution of wealth $\vec a_0$, a set of borrowing limits $\{\bar A^k(s)\}_{k=1}^K$, a pricing kernel $Q(s' | s)$, sets of value functions $\{v^k(a,s)\}_{k=1}^K$, and -decision rules $\{c^k(s), a^k(s)\}_{k=1}^K$ such +decision rules $\{c^k(s), \hat a^k(s)\}_{k=1}^K$ such that * The state-by-state borrowing constraints satisfy the recursion @@ -221,7 +219,7 @@ $$ \bar A^k(s) = y^k(s) + \sum_{s'} Q(s'|s) \bar A^k(s') $$ -* For all $i$, given +* For all $k$, given $a^k_0$, $\bar A^k(s)$, and the pricing kernel, the value functions and decision rules solve the consumers' problems; @@ -262,7 +260,7 @@ the single budget constraint in arrangement with all trades occurring at tim -Starting the system with $a_0^k =0$ for all $i$ has a striking implication that we can call **state variable degeneracy**. +Starting the system with $a_0^k =0$ for all $i$ has a striking implication that we call **state variable degeneracy**. Here is what we mean by **state variable degeneracy**: @@ -337,12 +335,18 @@ p^h = (I - Q)^{-1} d^h $$ + + * the price in Markov state $s$ at time $t$ of an **ex dividend** stock that entitles the owner at the end of time $t$ to the time $t+1$ dividend and the option to sell the stock at time $t+1$. The price is $$ p^h = (I - Q)^{-1} Q d^h $$ +```{note} +The matrix geometric sum $(I - Q)^{-1} = I + Q + Q^2 + \cdots $ +is an example of a **resolvent operator**. +``` Below, we describe an equilibrium model with trading of one-period Arrow securities in which the pricing kernel is endogenous. @@ -577,9 +581,9 @@ Evidently, they equal the maximum amount that it is feasible for individual $k$ even if he consumes zero goods forevermore. **Remark:** If we have an Inada condition at zero consumption or just impose that consumption -be nonnegative, then in a **finite horizon** economy with sequential trading of one-period Arrow securities there is no need to impose natural debt limits. See the section below on a Finite Horizon Economy. +be nonnegative, then in a **finite horizon** economy with sequential trading of one-period Arrow securities there is no need to impose natural debt limits. See the section on a Finite Horizon Economy below. + -(NOTE: check equation (25) in week 4 slides -- Inada condition forces the the natural debt limits non-binding in infinite horizon sequential trading) ### Continuation Wealth @@ -693,6 +697,134 @@ $$ J^k = (I - \beta P)^{-1} u(\alpha_k y) , \quad u(c) = \frac{c^{1-\gamma}}{1- where it is understood that $ u(\alpha_k y)$ is a vector. + +## Finite Horizon + +We now describe a finite-horizon version of the economy that operates for $T+1$ periods +$t \in {\bf T} = \{ 0, 1, \ldots, T\}$. + +Consequently, we'll want $T+1$ counterparts to objects described above, with one important exception: +we won't need **borrowing limits**. + + * borrowing limits aren't required for a finite horizon economy in which a +one-period utility function $u(c)$ satisfies an Inada condition that sets the marginal utility of consumption at zero consumption to zero. + * Nonnegativity of consumption choices at all $t \in {\bf T}$ automatically +limits borrowing. + + +### Continuation Wealths + + +We denote a $K \times 1$ vector of state-dependent continuation wealths in Markov state $s$ at time $t$ as + +$$ +\psi_t\left(s\right)=\left[\begin{array}{c} +\psi^{1}\left(s\right)\\ +\vdots\\ +\psi^{K}\left(s\right) +\end{array}\right], \quad s \in \left[\bar{s}_1, \ldots, \bar{s}_n\right] +$$ + +and an $n \times 1$ vector of continuation wealths for each individual $k$ as + +$$ +\psi_t^{k}=\left[\begin{array}{c} +\psi_t^{k}\left(\bar{s}_{1}\right)\\ +\vdots\\ +\psi_t^{k}\left(\bar{s}_{n}\right) +\end{array}\right], \quad k \in \left[1, \ldots, K\right] +$$ + + + +Continuation wealths $\psi^k$ of consumer $k$ satisfy + +$$ +\begin{aligned} +\psi_T^k & = \left[\alpha_k y - y^k\right] \cr +\psi_{T-1}^k & = \left[I + Q \right] \left[\alpha_k y - y^k\right] \cr +\vdots \quad & \quad \quad \quad \vdots \cr +\psi_0^k & = \left[I + Q + Q^2 + \cdots + Q^T \right] \left[\alpha_k y - y^k\right] +\end{aligned} +$$ (eq:vv) + +where + +$$ +y^{k}=\left[\begin{array}{c} +y^{k}\left(\bar{s}_{1}\right)\\ +\vdots\\ +y^{k}\left(\bar{s}_{n}\right) +\end{array}\right],\quad y=\left[\begin{array}{c} +y\left(\bar{s}_{1}\right)\\ +\vdots\\ +y\left(\bar{s}_{n}\right) +\end{array}\right] +$$ + +Note that $\sum_{k=1}^K \psi_t^k = {0}_{n \times 1}$ for all $t \in {\bf T}$. + +**Remark:** At the initial state $s_0 \in \begin{bmatrix} \bar s_1, \ldots, \bar s_n \end{bmatrix}$, + for all agents $k = 1, \ldots, K$, continuation wealth $\psi_0^k(s_0) = 0$. This indicates that +the economy begins with all agents being debt-free and financial-asset-free at time $0$, state $s_0$. + + +**Remark:** Note that all agents' continuation wealths return to zero when the Markov state returns to whatever value $s_0$ it had at time $0$. This will recur if the Markov chain makes the initial state $s_0$ recurrent. + + + + +With the initial state being a particular state $s_0 \in \left[\bar{s}_1, \ldots, \bar{s}_n\right]$, we must have + +$$ +\psi_0^k\left(s_0\right) = 0, \quad k=1, \ldots, K +$$ + +which means the equilibrium distribution of wealth satisfies + +$$ +\alpha_k = \frac{V_z y^k}{V_z y} +$$ (eq:w) + + + +where now in our finite-horizon economy + +$$ + V = \left[I + Q + Q^2 + \cdots + Q^T \right] +$$ (eq:ww) + +and $z$ is the row index corresponding to the initial state $s_0$. + +Since $\sum_{k=1}^K V_z y^k = V_z y$, $\sum_{k=1}^K \alpha_k = 1$. + + +In summary, here is the logical flow of an algorithm to compute a competitive equilibrium with Arrow securities +in our finite-horizon Markov economy: + +* compute $Q$ from the aggregate allocation and formula {eq}`eq:Qformula` + +* compute the distribution of wealth $\alpha$ from formulas {eq}`eq:w` and {eq}`eq:ww` + +* using $\alpha$, assign each consumer $k$ the share $\alpha_k$ of the aggregate endowment at each state + +* return to the $\alpha$-dependent formula {eq}`eq:vv` for continuation wealths and compute continuation wealths + +* equate agent $k$'s portfolio to its continuation wealth state by state + + +While for the infinite horizon economy, the formula for value functions is + +$$ J^k = (I - \beta P)^{-1} u(\alpha_k y) , \quad u(c) = \frac{c^{1-\gamma}}{1-\gamma} $$ + +for the finite horizon economy the formula is + +$$ J_0^k = (I + \beta P + \cdots + \beta^T P^T) u(\alpha_k y) , $$ + +where it is understood that $ u(\alpha_k y)$ is a vector. + + + ## Python Code We are ready to dive into some Python code. @@ -712,9 +844,9 @@ np.set_printoptions(suppress=True) First, we create a Python class to compute the objects that comprise a competitive equilibrium with sequential trading of one-period Arrow securities. -In addition to handly infinite-horizon economies, the code is set up to handle finite-horizon economies indexed by horizon $T$. +In addition to infinite-horizon economies, the code is set up to handle finite-horizon economies indexed by horizon $T$. -We'll study some finite horizon economies after we look at some infinite-horizon economies. +We'll study examples of finite horizon economies after we first look at some infinite-horizon economies. ```{code-cell} ipython3 class RecurCompetitive: @@ -879,6 +1011,14 @@ class RecurCompetitive: return J ``` +## Examples + +We'll use our code to construct equilibrium objects in several example economies. + +Our first several examples will be infinite horizon economies. + +Our final example will be a finite horizon economy. + ### Example 1 Please read the preceding class for default parameter values and the following Python code for the fundamentals of the economy. @@ -978,7 +1118,9 @@ print("R = ", ex2.R) ex2.Q ``` -NOTE: The pricing kernal is different because of the aggregate endowments in state 1 and 2 are different now +Note that the pricing kernal in example economies 1 and 2 differ. + +This comes from differences in the aggregate endowments in state 1 and 2 in example 1. ```{code-cell} ipython3 ex2.β * ex2.u_prime(3.5) / ex2.u_prime(2.5) * ex2.P[0,1] @@ -988,7 +1130,7 @@ ex2.β * ex2.u_prime(3.5) / ex2.u_prime(2.5) * ex2.P[0,1] ex2.β * ex2.u_prime(2.5) / ex2.u_prime(3.5) * ex2.P[1,0] ``` -END OF NOTE + ```{code-cell} ipython3 # Risk free rate R @@ -1160,138 +1302,10 @@ for i in range(1, 4): print(f'J = \n{ex4.value_functionss()}\n') ``` -## Finite Horizon -(NOTE: Consider bring finite horizon section above since the Python class considers the finite horizon cases) - -The Python class **RecurCompetitive** provided above also can be used to compute competitive equilibrium -allocations and Arrow securities prices for finite horizon economies. - -The setting is a finite-horizon version of the one above except that time now runs for $T+1$ periods -$t \in {\bf T} = \{ 0, 1, \ldots, T\}$. - -Consequently, we want $T+1$ counterparts to objects described above, with one important exception: -we won't need **borrowing limits**. - - * borrowing limits aren't required for a finite horizon economy in which a -one-period utility function $u(c)$ satisfies an Inada condition that sets the marginal utility of consumption at zero consumption to zero. - * Nonnegativity of consumption choices at all $t \in {\bf T}$ automatically -limits borrowing. - - -### Continuation Wealths - - -We denote a $K \times 1$ vector of state-dependent continuation wealths in Markov state $s$ at time $t$ as - -$$ -\psi_t\left(s\right)=\left[\begin{array}{c} -\psi^{1}\left(s\right)\\ -\vdots\\ -\psi^{K}\left(s\right) -\end{array}\right], \quad s \in \left[\bar{s}_1, \ldots, \bar{s}_n\right] -$$ - -and an $n \times 1$ vector of continuation wealths for each individual $k$ as - -$$ -\psi_t^{k}=\left[\begin{array}{c} -\psi_t^{k}\left(\bar{s}_{1}\right)\\ -\vdots\\ -\psi_t^{k}\left(\bar{s}_{n}\right) -\end{array}\right], \quad k \in \left[1, \ldots, K\right] -$$ - - - -Continuation wealths $\psi^k$ of consumer $k$ satisfy - -$$ -\begin{aligned} -\psi_T^k & = \left[\alpha_k y - y^k\right] \cr -\psi_{T-1}^k & = \left[I + Q \right] \left[\alpha_k y - y^k\right] \cr -\vdots \quad & \quad \quad \quad \vdots \cr -\psi_0^k & = \left[I + Q + Q^2 + \cdots + Q^T \right] \left[\alpha_k y - y^k\right] -\end{aligned} -$$ (eq:vv) - -where - -$$ -y^{k}=\left[\begin{array}{c} -y^{k}\left(\bar{s}_{1}\right)\\ -\vdots\\ -y^{k}\left(\bar{s}_{n}\right) -\end{array}\right],\quad y=\left[\begin{array}{c} -y\left(\bar{s}_{1}\right)\\ -\vdots\\ -y\left(\bar{s}_{n}\right) -\end{array}\right] -$$ - -Note that $\sum_{k=1}^K \psi_t^k = {0}_{n \times 1}$ for all $t \in {\bf T}$. - -**Remark:** At the initial state $s_0 \in \begin{bmatrix} \bar s_1, \ldots, \bar s_n \end{bmatrix}$, - for all agents $k = 1, \ldots, K$, continuation wealth $\psi_0^k(s_0) = 0$. This indicates that -the economy begins with all agents being debt-free and financial-asset-free at time $0$, state $s_0$. - - -**Remark:** Note that all agents' continuation wealths return to zero when the Markov state returns to whatever value $s_0$ it had at time $0$. This will recur if the Markov chain makes the initial state $s_0$ recurrent. - - - - -With the initial state being a particular state $s_0 \in \left[\bar{s}_1, \ldots, \bar{s}_n\right]$, we must have - -$$ -\psi_0^k\left(s_0\right) = 0, \quad k=1, \ldots, K -$$ - -which means the equilibrium distribution of wealth satisfies - -$$ -\alpha_k = \frac{V_z y^k}{V_z y} -$$ (eq:w) - - - -where now in our finite-horizon economy - -$$ - V = \left[I + Q + Q^2 + \cdots + Q^T \right] -$$ (eq:ww) - -and $z$ is the row index corresponding to the initial state $s_0$. - -Since $\sum_{k=1}^K V_z y^k = V_z y$, $\sum_{k=1}^K \alpha_k = 1$. - - -In summary, here is the logical flow of an algorithm to compute a competitive equilibrium with Arrow securities -in our finite-horizon Markov economy: - -* compute $Q$ from the aggregate allocation and formula {eq}`eq:Qformula` - -* compute the distribution of wealth $\alpha$ from formulas {eq}`eq:w` and {eq}`eq:ww` - -* using $\alpha$, assign each consumer $k$ the share $\alpha_k$ of the aggregate endowment at each state - -* return to the $\alpha$-dependent formula {eq}`eq:vv` for continuation wealths and compute continuation wealths - -* equate agent $k$'s portfolio to its continuation wealth state by state - - -While for the infinite horizon economy, the formula for value functions is - -$$ J^k = (I - \beta P)^{-1} u(\alpha_k y) , \quad u(c) = \frac{c^{1-\gamma}}{1-\gamma} $$ - -for the finite horizon economy the formula is - -$$ J_0^k = (I + \beta P + \cdots + \beta^T P^T) u(\alpha_k y) , $$ - -where it is understood that $ u(\alpha_k y)$ is a vector. ### Finite Horizon Example -Below we revisit the economy defined in example 1, but set the time horizon to be $T=10$. +We now revisit the economy defined in example 1, but set the time horizon to be $T=10$. ```{code-cell} ipython3 # dimensions