Skip to content

Remove unused imports #142

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions lectures/BCG_complete_mkts.md
Original file line number Diff line number Diff line change
Expand Up @@ -802,44 +802,44 @@ It consists of 4 functions that do the following things:
- First, create a grid for capital.
- Then for each value of capital stock in the grid, compute the left side of the planner's
first-order necessary condition for $k$, that is,

$$
\beta \alpha A K^{\alpha -1} \int \left( \frac{w_1(\epsilon) + A K^\alpha e^\epsilon}{w_0 - K } \right)^{-\gamma} e^\epsilon g(\epsilon) d \epsilon - 1 =0
$$

- Find $k$ that solves this equation.
* `q` computes Arrow security prices as a function of the productivity shock $\epsilon$ and capital $K$:

$$
q(\epsilon;K) = \beta \left( \frac{u'\left( w_1(\epsilon) + A K^\alpha e^\epsilon\right)} {u'(w_0 - K )} \right)
$$

* `V` solves for the firm value given capital $k$:

$$
V = - k + \int A k^\alpha e^\epsilon q(\epsilon; K) d \epsilon
$$

* `opt_c` computes optimal consumptions $c^i_0$, and $c^i(\epsilon)$:
- The function first computes weight $\eta$ using the
budget constraint for agent 1:

$$
w_0^1 + \theta_0^1 V + \int w_1^1(\epsilon) q(\epsilon) d \epsilon
= c_0^1 + \int c_1^1(\epsilon) q(\epsilon) d \epsilon
= \eta \left( C_0 + \int C_1(\epsilon) q(\epsilon) d \epsilon \right)
$$
where

$$
\begin{aligned}
C_0 & = w_0 - K \cr
C_1(\epsilon) & = w_1(\epsilon) + A K^\alpha e^\epsilon \cr
\end{aligned}
$$

- It computes consumption for each agent as

$$
\begin{aligned}
c_0^1 & = \eta C_0 \cr
Expand All @@ -848,7 +848,7 @@ It consists of 4 functions that do the following things:
c_1^2 (\epsilon) & = (1 - \eta) C_1(\epsilon)
\end{aligned}
$$


The list of parameters includes:

Expand All @@ -868,7 +868,6 @@ The list of parameters includes:
Gauss-Hermite quadrature: default value is 10

```{code-cell} ipython
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import norm
Expand Down Expand Up @@ -1205,4 +1204,3 @@ Image(fig.to_image(format="png"))
# fig.show() will provide interactive plot when running
# notebook locally
```

44 changes: 20 additions & 24 deletions lectures/BCG_incomplete_mkts.md
Original file line number Diff line number Diff line change
Expand Up @@ -580,47 +580,47 @@ Here goes:
$|\theta^1_h - \theta^1_l|$ is large:
* Compute agent 1’s valuation of the equity claim with a
fixed-point iteration:

$q_1 = \beta \int \frac{u^\prime(c^1_1(\epsilon))}{u^\prime(c^1_0)} d^e(k,b;\epsilon) g(\epsilon) \ d\epsilon$

where

$c^1_1(\epsilon) = w^1_1(\epsilon) + \theta^1 d^e(k,b;\epsilon)$

and

$c^1_0 = w^1_0 + \theta^1_0V - q_1\theta^1$
* Compute agent 2’s valuation of the bond claim with a
fixed-point iteration:

$p = \beta \int \frac{u^\prime(c^2_1(\epsilon))}{u^\prime(c^2_0)} d^b(k,b;\epsilon) g(\epsilon) \ d\epsilon$

where

$c^2_1(\epsilon) = w^2_1(\epsilon) + \theta^2 d^e(k,b;\epsilon) + b$

and

$c^2_0 = w^2_0 + \theta^2_0 V - q_1 \theta^2 - pb$
* Compute agent 2’s valuation of the equity claim with a
fixed-point iteration:

$q_2 = \beta \int \frac{u^\prime(c^2_1(\epsilon))}{u^\prime(c^2_0)} d^e(k,b;\epsilon) g(\epsilon) \ d\epsilon$

where

$c^2_1(\epsilon) = w^2_1(\epsilon) + \theta^2 d^e(k,b;\epsilon) + b$

and

$c^2_0 = w^2_0 + \theta^2_0 V - q_2 \theta^2 - pb$
* If $q_1 > q_2$, Set $\theta_l = \theta^1$;
otherwise, set $\theta_h = \theta^1$.
* Repeat steps 6Aa through 6Ad until
$|\theta^1_h - \theta^1_l|$ is small.
1. Set bond price as $p$ and equity price as $q = \max(q_1,q_2)$.
1. Compute optimal choices of consumption:

$$
\begin{aligned}
c^1_0 &= w^1_0 + \theta^1_0V - q\theta^1 \\
Expand All @@ -629,29 +629,29 @@ Here goes:
c^2_1(\epsilon) &= w^2_1(\epsilon) + \theta^2 d^e(k,b;\epsilon) + b
\end{aligned}
$$

1. (Here we confess to abusing notation again, but now in a different
way. In step 7, we interpret frozen $c^i$s as Big
$C^i$. We do this to solve the firm’s problem.) Fixing the
values of $c^i_0$ and $c^i_1(\epsilon)$, compute optimal
choices of capital $k$ and debt level $b$ using the
firm’s first order necessary conditions.
1. Compute deviations from the firm’s FONC for capital $k$ as:

$kfoc = \beta \alpha A k^{\alpha - 1} \left( \int \frac{u^\prime(c^2_1(\epsilon))}{u^\prime(c^2_0)} e^\epsilon g(\epsilon) \ d\epsilon \right) - 1$
- If $kfoc > 0$, Set $k_l = k$; otherwise, set
$k_h = k$.
- Repeat steps 4 through 7A until $|k_h-k_l|$ is small.
1. Compute deviations from the firm’s FONC for debt level $b$ as:

$bfoc = \beta \left[ \int_{\epsilon^*}^\infty \left( \frac{u^\prime(c^1_1(\epsilon))}{u^\prime(c^1_0)} \right) g(\epsilon) \ d\epsilon - \int_{\epsilon^*}^\infty \left( \frac{u^\prime(c^2_1(\epsilon))}{u^\prime(c^2_0)} \right) g(\epsilon) \ d\epsilon \right]$
- If $bfoc > 0$, Set $b_h = b$; otherwise, set
$b_l = b$.
- Repeat steps 3 through 7B until $|b_h-b_l|$ is small.
1. Given prices $q$ and $p$ from step 6, and the firm
choices of $k$ and $b$ from step 7, compute the synthetic
firm value:

$V_x = -k + q + pb$
- If $V_x > V$, then set $V_l = V$; otherwise, set
$V_h = V$.
Expand Down Expand Up @@ -704,12 +704,9 @@ Parameters include:
- bound: Bound for truncated normal distribution. Default value is 3.

```{code-cell} ipython
import pandas as pd
import numpy as np
from scipy.stats import norm
from scipy.stats import truncnorm
from scipy.integrate import quad
from scipy.optimize import bisect
from numba import njit
from interpolation import interp
```
Expand Down Expand Up @@ -1946,4 +1943,3 @@ Agents of type 2 value bonds more highly (they want more hedging).

Taken together with our earlier plot of equity holdings, these graphs confirm our earlier conjecture that while both type
of agents hold equities, only agents of type 2 holds bonds.

1 change: 0 additions & 1 deletion lectures/additive_functionals.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ Let's start with some imports:

```{code-cell} ipython3
import numpy as np
import scipy as sp
import scipy.linalg as la
import quantecon as qe
import matplotlib.pyplot as plt
Expand Down
3 changes: 0 additions & 3 deletions lectures/amss.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ from interpolation.splines import eval_linear, UCGrid, nodes
from quantecon import optimize, MarkovChain
from numba import njit, prange, float64
from numba.experimental import jitclass

%matplotlib inline
```

In {doc}`an earlier lecture <opt_tax_recur>`, we described a model of
Expand Down Expand Up @@ -1033,4 +1031,3 @@ problem, there exists another realization $\tilde s^t$ with
the same history up until the previous period, i.e., $\tilde s^{t-1}=
s^{t-1}$, but where the multiplier on constraint {eq}`AMSS_46` takes a positive value, so
$\gamma_t(\tilde s^t)>0$.

4 changes: 1 addition & 3 deletions lectures/arellano.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,8 @@ Let's start with some imports:
import matplotlib.pyplot as plt
import numpy as np
import quantecon as qe
import random

from numba import njit, int64, float64, prange
from numba.experimental import jitclass
from numba import njit, prange
%matplotlib inline
```

Expand Down
Loading