@@ -3,10 +3,12 @@ jupytext:
33 text_representation :
44 extension : .md
55 format_name : myst
6+ format_version : 0.13
7+ jupytext_version : 1.17.1
68kernelspec :
7- display_name : Python 3
8- language : python
99 name : python3
10+ display_name : Python 3 (ipykernel)
11+ language : python
1012---
1113
1214(harrison_kreps)=
@@ -29,10 +31,9 @@ kernelspec:
2931
3032In addition to what's in Anaconda, this lecture uses following libraries:
3133
32- ``` {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
5152
5253Let's start with some standard imports:
5354
54- ``` {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
131132
132133The stationary (i.e., invariant) distributions of these two matrices can be calculated as follows:
133134
134- ``` {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```
141142
142- ``` {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)$.
270271
271272Here's a function that can be used to compute these values
272273
273- ```{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
399400
400401Here's code to solve for $\bar p$, $\hat p_a$ and $\hat p_b$ using the iterative method described above
401402
402- ```{code-cell} python3
403+ ```{code-cell} ipython3
403404def price_optimistic_beliefs(transitions, dividend_payoff, β=.75,
404405 max_iter=50000, tol=1e-16):
405406 """
@@ -414,15 +415,15 @@ def price_optimistic_beliefs(transitions, dividend_payoff, β=.75,
414415 p_old = p_new
415416 p_new = β * np.max([q @ p_old
416417 + q @ dividend_payoff for q in transitions],
417- 1 )
418+ axis=0 )
418419
419420 # If we succeed in converging, break out of for loop
420421 if np.max(np.sqrt((p_new - p_old)**2)) < tol:
421422 break
422423
423424 ptwiddle = β * np.min([q @ p_old
424425 + q @ dividend_payoff for q in transitions],
425- 1 )
426+ axis=0 )
426427
427428 phat_a = np.array([p_new[0], ptwiddle[1]])
428429 phat_b = np.array([ptwiddle[0], p_new[1]])
@@ -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.
467468
468469Here's code to solve for $\check p$ using iteration
469470
470- ```{code-cell} python3
471+ ```{code-cell} ipython3
471472def price_pessimistic_beliefs(transitions, dividend_payoff, β=.75,
472473 max_iter=50000, tol=1e-16):
473474 """
@@ -482,7 +483,7 @@ def price_pessimistic_beliefs(transitions, dividend_payoff, β=.75,
482483 p_old = p_new
483484 p_new = β * np.min([q @ p_old
484485 + q @ dividend_payoff for q in transitions],
485- 1 )
486+ axis=0 )
486487
487488 # If we succeed in converging, break out of for loop
488489 if np.max(np.sqrt((p_new - p_old)**2)) < tol:
@@ -512,8 +513,6 @@ Scheinkman extracts insights about the effects of financial regulations on bubbl
512513
513514He emphasizes how limiting short sales and limiting leverage have opposite effects.
514515
515- ## 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.
572571
573- ```{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.
597596
598- ```{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
@@ -614,4 +613,4 @@ with **permanently optimistic** investors - this is due to the marginal investor
614613```{solution-end}
615614```
616615
617- [^f1]: By assuming that both types of agents always have "deep enough pockets" to purchase all of the asset, the model takes wealth dynamics off the table. The Harrison-Kreps model generates high trading volume when the state changes either from 0 to 1 or from 1 to 0.
616+ [^f1]: By assuming that both types of agents always have "deep enough pockets" to purchase all of the asset, the model takes wealth dynamics off the table. The Harrison-Kreps model generates high trading volume when the state changes either from 0 to 1 or from 1 to 0.
0 commit comments