Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
further_edits
  • Loading branch information
shlff committed Jun 4, 2023
commit df80367a2c2f39e22af6b96eb67cd391e11be28b
266 changes: 140 additions & 126 deletions lectures/supply_demand_heterogeneity.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,40 @@ kernelspec:
name: python3
---

(supply_demand_heterogeneity)=
# Market Equilibrium with Heterogeneity

```{contents} Contents
:depth: 2
```

## Overview

In the {doc}`previous lecture
<supply_demand_multiple_goods>`, we studied competitive equilibria in an economy with many goods.

While the results of the study were informative, we used a strong simplifying assumption: all of the agents in the economy are identical.

In the real world, households, firms and other economic agents differ from one another along many dimensions.

In this lecture, we introduce heterogeneity across consumers by allowing their preferences and endownments to differ.

We will examine competitive equilibrium in this setting.

## An Endowment Economy
We will also show how a "representative consumer" can be constructed.

Let's study a **pure exchange** economy without production.
Here are some imports:

```{code-cell} ipython3
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from scipy.linalg import inv
```

## An simple example

Let's study a simple example of **pure exchange** economy without production.

There are two consumers who differ in their endowment vectors $e_i$ and their bliss-point vectors $b_i$ for $i=1,2$.

Expand Down Expand Up @@ -80,66 +108,11 @@ $$
```{exercise-end}
```

## Designing some Python Code


Below we shall construct a Python class with the following attributes:

* **Preferences** in the form of

* an $n \times n$ positive definite matrix $\Pi$
* an $n \times 1$ vector of bliss points $b$

* **Endowments** in the form of

* an $n \times 1$ vector $e$
* a scalar "wealth" $W$ with default value $0$

* **Production Costs** pinned down by

* an $n \times 1$ nonnegative vector $h$
* an $n \times n$ positive definite matrix $J$

The class will include a test to make sure that $b > > \Pi e $ and raise an exception if it is violated
(at some threshold level we'd have to specify).

* **A Person** in the form of a pair that consists of

* **Preferences** and **Endowments**

* **A Pure Exchange Economy** will consist of

* a collection of $m$ **persons**

* $m=1$ for our single-agent economy
* $m=2$ for our illustrations of a pure exchange economy

* an equilibrium price vector $p$ (normalized somehow)
* an equilibrium allocation $c^1, c^2, \ldots, c^m$ -- a collection of $m$ vectors of dimension $n \times 1$

* **A Production Economy** will consist of

* a single **person** that we'll interpret as a representative consumer
* a single set of **production costs**
* a multiplier $\mu$ that weights "consumers" versus "producers" in a planner's welfare function, as described above in the main text
* an $n \times 1$ vector $p$ of competitive equilibrium prices
* an $n \times 1$ vector $c$ of competitive equilibrium quantities
* **consumer surplus**
* **producer surplus**

Now let's proceed to code.

```{code-cell} ipython3
# import some packages
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from scipy.linalg import inv
```
## Pure exchange economy

### Pure Exchange Economy
Let's further explore a pure exchange economy with $n$ goods and $m$ people.

Let's first explore a pure exchange economy with $n$ goods and $m$ people.
### Competitive equilibrium

We'll compute a competitive equilibrium.

Expand All @@ -163,79 +136,40 @@ c_{i}=\Pi^{-1}b_{i}-(\Pi^{\top}\Pi)^{-1}\mu_{i}p
$$


### Designing some Python code

## Deducing a Representative Consumer

In the class of multiple consumer economies that we are studying here, it turns out that there
exists a single **representative consumer** whose preferences and endowments can be deduced from lists of preferences and endowments for the separate individual consumers.

Consider a multiple consumer economy with initial distribution of wealth $W_i$ satisfying $\sum_i W_{i}=0$

We allow an initial redistribution of wealth.

We have the following objects


- The demand curve:

$$
c_{i}=\Pi^{-1}b_{i}-(\Pi^{\top}\Pi)^{-1}\mu_{i}p
$$

- The marginal utility of wealth:

$$
\mu_{i}=\frac{-W_{i}+p^{\top}\left(\Pi^{-1}b_{i}-e_{i}\right)}{p^{\top}(\Pi^{\top}\Pi)^{-1}p}
$$

- Market clearing:

$$
\sum c_{i}=\sum e_{i}
$$

Denote aggregate consumption $\sum_i c_{i}=c$ and $\sum_i \mu_i = \mu$.

Market clearing requires
Below we shall construct a Python class with the following attributes:

$$
\Pi^{-1}\left(\sum_{i}b_{i}\right)-(\Pi^{\top}\Pi)^{-1}p\left(\sum_{i}\mu_{i}\right)=\sum_{i}e_{i}
$$
which, after a few steps, leads to
* **Preferences** in the form of

$$
p=\mu^{-1}\left(\Pi^{\top}b-\Pi^{\top}\Pi e\right)
$$
* an $n \times n$ positive definite matrix $\Pi$
* an $n \times 1$ vector of bliss points $b$

where
* **Endowments** in the form of

$$
\mu = \sum_i\mu_{i}=\frac{0 + p^{\top}\left(\Pi^{-1}b-e\right)}{p^{\top}(\Pi^{\top}\Pi)^{-1}p}.
$$
* an $n \times 1$ vector $e$
* a scalar "wealth" $W$ with default value $0$

Now consider the representative consumer economy specified above.

Denote the marginal utility of wealth of the representative consumer by $\tilde{\mu}$.
The class will include a test to make sure that $b > > \Pi e $ and raise an exception if it is violated
(at some threshold level we'd have to specify).

The demand function is
* **A Person** in the form of a pair that consists of

$$
c=\Pi^{-1}b-(\Pi^{\top}\Pi)^{-1}\tilde{\mu} p
$$
* **Preferences** and **Endowments**

Substituting this into the budget constraint gives
* **A Pure Exchange Economy** will consist of

$$
\tilde{\mu}=\frac{p^{\top}\left(\Pi^{-1}b-e\right)}{p^{\top}(\Pi^{\top}\Pi)^{-1}p}
$$
* a collection of $m$ **persons**

In an equilibrium $c=e$, so
* $m=1$ for our single-agent economy
* $m=2$ for our illustrations of a pure exchange economy

$$
p=\tilde{\mu}^{-1}(\Pi^{\top}b-\Pi^{\top}\Pi e)
$$
* an equilibrium price vector $p$ (normalized somehow)
* an equilibrium allocation $c^1, c^2, \ldots, c^m$ -- a collection of $m$ vectors of dimension $n \times 1$

Thus, we have verified that, up to choice of a numeraire in which to express absolute prices, the price vector in our representative consumer economy is the same as that in an underlying economy with multiple consumers.
Now let's proceed to code.

```{code-cell} ipython3
class ExchangeEconomy:
Expand All @@ -244,7 +178,7 @@ class ExchangeEconomy:
bs,
es,
Ws=None,
thres=4):
thres=1.5):
"""
Set up the environment for an exchange economy

Expand All @@ -253,12 +187,13 @@ class ExchangeEconomy:
bs (list): all consumers' bliss points
es (list): all consumers' endowments
Ws (list): all consumers' wealth
thres (float): a threshold set to test b >> Pi e violated
"""
n, m = Pi.shape[0], len(bs)

# check non-satiation
for b, e in zip(bs, es):
if np.min(b / np.max(Pi @ e)) <= 1.5:
if np.min(b / np.max(Pi @ e)) <= thres:
raise Exception('set bliss points further away')

if Ws == None:
Expand Down Expand Up @@ -305,11 +240,17 @@ class ExchangeEconomy:
return p, c_s, mu_s
```

### Example: Two-Person Economy **without** Production
* Study how competitive equilibrium $p, c^1, c^2$ respond to different
## Implementation

Next we use the class ``ExchangeEconomy`` defined above to study

* a two-person economy without production,
* a dynamic economy, and
* an economy with risk and arrow securities.

* $b^i$'s
* $e^i$'s
### Two-person economy without production

Here we tudy how competitive equilibrium $p, c^1, c^2$ respond to different $b^i$ and $e^i$, $i \in \{1, 2\}.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we study

$i \in {1, 2}$

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(The final dollar sign is missing.)


```{code-cell} ipython3
Pi = np.array([[1, 0],
Expand Down Expand Up @@ -384,7 +325,7 @@ print('Competitive equilibrium price vector:', p)
print('Competitive equilibrium allocation:', c_s)
```

### A **Dynamic Economy**
### A dynamic economy

Now let's use the tricks described above to study a dynamic economy, one with two periods.

Expand All @@ -405,7 +346,7 @@ print('Competitive equilibrium price vector:', p)
print('Competitive equilibrium allocation:', c_s)
```

### Example: **Arrow Securities**
### Risk economy with Arrow securities

We use the tricks described above to interpret $c_1, c_2$ as "Arrow securities" that are state-contingent claims to consumption goods.

Expand All @@ -427,3 +368,76 @@ p, c_s, mu_s = EE_AS.competitive_equilibrium()
print('Competitive equilibrium price vector:', p)
print('Competitive equilibrium allocation:', c_s)
```

## Deducing a Representative Consumer

In the class of multiple consumer economies that we are studying here, it turns out that there
exists a single **representative consumer** whose preferences and endowments can be deduced from lists of preferences and endowments for the separate individual consumers.

Consider a multiple consumer economy with initial distribution of wealth $W_i$ satisfying $\sum_i W_{i}=0$

We allow an initial redistribution of wealth.

We have the following objects


- The demand curve:

$$
c_{i}=\Pi^{-1}b_{i}-(\Pi^{\top}\Pi)^{-1}\mu_{i}p
$$

- The marginal utility of wealth:

$$
\mu_{i}=\frac{-W_{i}+p^{\top}\left(\Pi^{-1}b_{i}-e_{i}\right)}{p^{\top}(\Pi^{\top}\Pi)^{-1}p}
$$

- Market clearing:

$$
\sum c_{i}=\sum e_{i}
$$

Denote aggregate consumption $\sum_i c_{i}=c$ and $\sum_i \mu_i = \mu$.

Market clearing requires

$$
\Pi^{-1}\left(\sum_{i}b_{i}\right)-(\Pi^{\top}\Pi)^{-1}p\left(\sum_{i}\mu_{i}\right)=\sum_{i}e_{i}
$$
which, after a few steps, leads to

$$
p=\mu^{-1}\left(\Pi^{\top}b-\Pi^{\top}\Pi e\right)
$$

where

$$
\mu = \sum_i\mu_{i}=\frac{0 + p^{\top}\left(\Pi^{-1}b-e\right)}{p^{\top}(\Pi^{\top}\Pi)^{-1}p}.
$$

Now consider the representative consumer economy specified above.

Denote the marginal utility of wealth of the representative consumer by $\tilde{\mu}$.

The demand function is

$$
c=\Pi^{-1}b-(\Pi^{\top}\Pi)^{-1}\tilde{\mu} p
$$

Substituting this into the budget constraint gives

$$
\tilde{\mu}=\frac{p^{\top}\left(\Pi^{-1}b-e\right)}{p^{\top}(\Pi^{\top}\Pi)^{-1}p}
$$

In an equilibrium $c=e$, so

$$
p=\tilde{\mu}^{-1}(\Pi^{\top}b-\Pi^{\top}\Pi e)
$$

Thus, we have verified that, up to choice of a numeraire in which to express absolute prices, the price vector in our representative consumer economy is the same as that in an underlying economy with multiple consumers.