@@ -3,10 +3,12 @@ jupytext:
33text_representation:
44extension: .md
55format_name: myst
6+format_version: 0.13
7+jupytext_version: 1.17.1
68kernelspec:
7-display_name: Python 3
8-language: python
99name: python3
10+display_name: Python 3 (ipykernel)
11+language: python
1012---
11131214(harrison_kreps)=
@@ -29,10 +31,9 @@ kernelspec:
29313032In addition to what's in Anaconda, this lecture uses following libraries:
313332-```{code-cell} ipython
33----
34-tags: [hide-output]
35----
34+```{code-cell} ipython3
35+:tags: [hide-output]
36+3637!pip install quantecon
3738```
3839@@ -51,7 +52,7 @@ The model features
51525253Let's start with some standard imports:
535454-```{code-cell} ipython
55+```{code-cell} ipython3
5556import numpy as np
5657import quantecon as qe
5758import scipy.linalg as la
@@ -131,15 +132,15 @@ But in state $1$, a type $a$ investor is more pessimistic about next period's
131132132133The stationary (i.e., invariant) distributions of these two matrices can be calculated as follows:
133134134-```{code-cell} python3
135+```{code-cell} ipython3
135136qa = np.array([[1/2, 1/2], [2/3, 1/3]])
136137qb = np.array([[2/3, 1/3], [1/4, 3/4]])
137138mca = qe.MarkovChain(qa)
138139mcb = qe.MarkovChain(qb)
139140mca.stationary_distributions
140141```
141142142-```{code-cell} python3
143+```{code-cell} ipython3
143144mcb.stationary_distributions
144145```
145146@@ -270,7 +271,7 @@ The first two rows of the table report $p_a(s)$ and $p_b(s)$.
270271271272Here's a function that can be used to compute these values
272273273-```{code-cell} python3
274+```{code-cell} ipython3
274275def price_single_beliefs(transition, dividend_payoff, β=.75):
275276 """
276277 Function to Solve Single Beliefs
@@ -399,7 +400,7 @@ Investors of type $a$ want to sell the asset in state $1$ while investors of typ
399400400401Here's code to solve for $\bar p$, $\hat p_a$ and $\hat p_b$ using the iterative method described above
401402402-```{code-cell} python3
403+```{code-cell} ipython3
403404def price_optimistic_beliefs(transitions, dividend_payoff, β=.75,
404405 max_iter=50000, tol=1e-16):
405406 """
@@ -444,8 +445,8 @@ Instead of equation {eq}`hakr2`, the equilibrium price satisfies
444445\check p(s)
445446= \beta \min
446447\left\{
447- P_a(s,1) \check p(0) + P_a(s,1) ( 1 + \check p(1)) ,\;
448- P_b(s,1) \check p(0) + P_b(s,1) ( 1 + \check p(1))
448+ P_a(s,0) \check p(0) + P_a(s,1) ( 1 + \check p(1)) ,\;
449+ P_b(s,0) \check p(0) + P_b(s,1) ( 1 + \check p(1))
449450\right\}
450451```
451452@@ -467,7 +468,7 @@ Constraints on short sales prevent that.
467468468469Here's code to solve for $\check p$ using iteration
469470470-```{code-cell} python3
471+```{code-cell} ipython3
471472def price_pessimistic_beliefs(transitions, dividend_payoff, β=.75,
472473 max_iter=50000, tol=1e-16):
473474 """
@@ -512,8 +513,6 @@ Scheinkman extracts insights about the effects of financial regulations on bubbl
512513513514He emphasizes how limiting short sales and limiting leverage have opposite effects.
514515515-## Exercises
516-517516```{exercise-start}
518517:label: hk_ex1
519518```
@@ -570,7 +569,7 @@ We'll use these transition matrices when we present our solution of exercise 1 b
570569First, we will obtain equilibrium price vectors with homogeneous beliefs, including when all
571570investors are optimistic or pessimistic.
572571573-```{code-cell} python3
572+```{code-cell} ipython3
574573qa = np.array([[1/2, 1/2], [2/3, 1/3]]) # Type a transition matrix
575574qb = np.array([[2/3, 1/3], [1/4, 3/4]]) # Type b transition matrix
576575# Optimistic investor transition matrix
@@ -595,7 +594,7 @@ for transition, label in zip(transitions, labels):
595594We will use the price_optimistic_beliefs function to find the price under
596595heterogeneous beliefs.
597596598-```{code-cell} python3
597+```{code-cell} ipython3
599598opt_beliefs = price_optimistic_beliefs([qa, qb], dividendreturn)
600599labels = ['p_optimistic', 'p_hat_a', 'p_hat_b']
601600