Skip to content

Commit 8707670

Browse files
committed
Merge branch 'main' into olg
2 parents a994b90 + af31025 commit 8707670

File tree

9 files changed

+1353
-937
lines changed

9 files changed

+1353
-937
lines changed

environment.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ dependencies:
66
- anaconda=2022.10
77
- pip
88
- pip:
9-
- jupyter-book
10-
- quantecon-book-theme
9+
- jupyter-book==0.13.2
10+
- quantecon-book-theme==0.3.2
1111
- sphinx-tojupyter==0.2.1
1212
- sphinxext-rediraffe==0.2.7
1313
- sphinx-exercise==0.4.1

in-work/quantecon_undergrad_notes_tom_3.md renamed to in-work/supply_demand_foundations_v2.md

Lines changed: 204 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,7 @@ $$
435435
436436
<!-- #endregion -->
437437
438+
<!-- #region -->
438439
$$
439440
b = \begin{bmatrix} \sqrt{\lambda}b_1 \cr \sqrt{1-\lambda}b_2 \end{bmatrix}
440441
$$
@@ -475,17 +476,24 @@ It would be easy to build another example with two consumers who have different
475476
476477
# Economies with Endogenous Supplies of Goods
477478
478-
## Supply
479+
## Supply Curve of a Competitive Firm
479480
480-
Start from a cost function
481+
A competitive firm takes a price vector $p$ as given and chooses a quantity $q$
482+
to maximize
483+
484+
$$
485+
p^\top q - C(q)
486+
$$ (eq:compprofits)
487+
488+
where $C(q)$ is a total cost function
481489
482490
$$
483491
C(q) = h ^\top q + .5 q^\top J q
484492
$$
485493
486-
where $J$ is a positive definite matrix.
494+
and $J$ is a positive definite matrix.
487495
488-
The $n\times 1$ vector of marginal costs is
496+
The $n\times 1$ vector of **marginal costs** is
489497
490498
$$
491499
\frac{\partial C(q)}{\partial q} = h + H q
@@ -497,12 +505,26 @@ $$
497505
H = .5 (J + J')
498506
$$
499507
500-
The inverse supply curve implied by marginal cost pricing is
508+
The $n \times 1$ vector of marginal revenues for the price-taking firm is
509+
510+
$$
511+
p
512+
$$
513+
514+
so **price equals marginal revenue** for our price-taking competitive firm.
515+
516+
The firm maximizes total profits by setting **marginal revenue to marginal costs**.
517+
518+
This leads to the following **inverse supply curve** for the competitive firm:
519+
501520
502521
$$
503522
p = h + H q
504523
$$
505524
525+
526+
527+
506528
## Competitive equilibrium
507529
508530
### $\mu=1$ warmup
@@ -532,7 +554,7 @@ Then the inverse demand curve is
532554
533555
$$
534556
p = \mu^{-1} [\Pi^\top b - \Pi^\top \Pi c]
535-
$$
557+
$$ (eq:old5pa)
536558
537559
Equating this to the inverse supply curve and solving
538560
for $c$ gives
@@ -541,6 +563,38 @@ $$
541563
c = [\Pi^\top \Pi + \mu H]^{-1} [ \Pi^\top b - \mu h]
542564
$$ (eq:old5p)
543565
566+
567+
## Digression: A Monopolist Supplier
568+
569+
Instead of being a price-taker, a monopolist sets prices to maximize profits subject to the inverse demand curve
570+
{eq}`eq:old5pa`.
571+
572+
So the monopolist's total profits as a function of its output $q$ is
573+
574+
$$
575+
[\mu^{-1} \Pi^\top (b - \Pi q)]^\top q - h^\top q - .5 q^\top J q
576+
$$ (eq:monopprof)
577+
578+
After finding the
579+
first-order necessary conditions for maximizing the above formula for monopoly profits with respect to $q$
580+
and solving them for $q$, we find that the monopolist sets
581+
582+
$$
583+
q = (H + 2 \mu^{-1} \Pi^T \Pi)^{-1} (\mu^{-1} \Pi^\top b - h)
584+
$$ (eq:qmonop)
585+
586+
We'll see that the monopolist sets a **lower output** $q$ than does either a
587+
588+
* planner who chooses $q$ to maximize social welfare
589+
590+
* a competitive equilibrium
591+
592+
593+
**Remark:** We can make exercises asking readers to verify the monopolist's supply curve {eq}`eq:qmonop` and the
594+
595+
596+
597+
544598
## Multi-good social welfare maximization problem
545599
546600
Our welfare or social planning problem is to choose $c$ to maximize
@@ -577,7 +631,7 @@ Thus, as for the single-good case, with multiple goods a competitive equilib
577631
578632
We can read the competitive equilbrium price vector off the inverse demand curve or the inverse supply curve.
579633
580-
634+
<!-- #endregion -->
581635
582636
## Initial notes to Jiacheng for coding
583637
@@ -927,6 +981,7 @@ Then we compute the equilibrium price vector using the inverse demand or supply
927981

928982

929983
```python
984+
930985
class Production_economy:
931986
def __init__(self, Pi, b, h, J, mu):
932987
"""
@@ -961,6 +1016,24 @@ class Production_economy:
9611016

9621017
return c, p
9631018

1019+
def equilibrium_with_monopoly(self):
1020+
"""
1021+
Compute the equilibrium price and allocation when there is a monopolist supplier
1022+
"""
1023+
Pi, b, h, mu, J = self.Pi, self.b, self.h, self.mu, self.J
1024+
H = .5*(J+J.T)
1025+
1026+
# allocation
1027+
q = inv(mu*H + 2*Pi.T@Pi)@(Pi.T@b - mu*h)
1028+
1029+
# price
1030+
p = 1/mu * (Pi.T@b - Pi.T@Pi@q)
1031+
1032+
if any(Pi @ q - b >= 0):
1033+
raise Exception('invalid result: set bliss points further away')
1034+
1035+
return q, p
1036+
9641037
def compute_surplus(self):
9651038
"""
9661039
Compute consumer and producer surplus for single good case
@@ -984,7 +1057,7 @@ class Production_economy:
9841057
return c_surplus, p_surplus
9851058

9861059

987-
def plot_PE_single_good(PE):
1060+
def plot_competitive_equilibrium(PE):
9881061
"""
9891062
Plot demand and supply curves, producer/consumer surpluses, and equilibrium for
9901063
a single good production economy
@@ -1013,11 +1086,14 @@ def plot_PE_single_good(PE):
10131086
plt.figure(figsize=[7,5])
10141087
plt.plot(xs, supply_curve, label='Supply', color='#020060')
10151088
plt.plot(xs, demand_curve, label='Demand', color='#600001')
1016-
plt.fill_between(xs[xs<=c], supply_curve[xs<=c], ps[xs<=c], label='Producer surplus', color='#E6E6F5')
1089+
10171090
plt.fill_between(xs[xs<=c], demand_curve[xs<=c], ps[xs<=c], label='Consumer surplus', color='#EED1CF')
1091+
plt.fill_between(xs[xs<=c], supply_curve[xs<=c], ps[xs<=c], label='Producer surplus', color='#E6E6F5')
1092+
10181093
plt.vlines(c, 0, p, linestyle="dashed", color='black', alpha=0.7)
10191094
plt.hlines(p, 0, c, linestyle="dashed", color='black', alpha=0.7)
10201095
plt.scatter(c, p, zorder=10, label='Competitive equilibrium', color='#600001')
1096+
10211097
plt.legend(loc='upper right')
10221098
plt.margins(x=0, y=0)
10231099
plt.ylim(0)
@@ -1051,7 +1127,7 @@ print('Competitive equilibrium price:', p.item())
10511127
print('Competitive equilibrium allocation:', c.item())
10521128

10531129
# plot
1054-
plot_PE_single_good(PE)
1130+
plot_competitive_equilibrium(PE)
10551131
```
10561132

10571133
```python
@@ -1071,7 +1147,7 @@ print('Competitive equilibrium price:', p.item())
10711147
print('Competitive equilibrium allocation:', c.item())
10721148

10731149
# plot
1074-
plot_PE_single_good(PE)
1150+
plot_competitive_equilibrium(PE)
10751151
```
10761152

10771153
```python
@@ -1092,7 +1168,7 @@ print('Competitive equilibrium price:', p.item())
10921168
print('Competitive equilibrium allocation:', c.item())
10931169

10941170
# plot
1095-
plot_PE_single_good(PE)
1171+
plot_competitive_equilibrium(PE)
10961172
```
10971173

10981174
This raises both the equilibrium price and quantity.
@@ -1155,3 +1231,119 @@ c, p = PE.competitive_equilibrium()
11551231
print('Competitive equilibrium price:', p)
11561232
print('Competitive equilibrium allocation:', c)
11571233
```
1234+
1235+
### A Monopolist Supplier
1236+
1237+
Let us follow the above digression and consider a monopolist supplier in this economy. We add a method to the `production_economy` class we built above to compute the equilibrium price and allocation when there is a monopolist supplier. Since the supplier now has the price-setting power,
1238+
- we first compute the optimal quantity that solves the monopolist's profit maximization problem.
1239+
- Then we derive the required price level from the consumer's inverse supply curve.
1240+
1241+
Next, we use a graph for the single good case to illustrate the difference between a competitive equilibrium and an equilibrium with a monopolist supplier. Recall that in a competitive equilibrium of the economy, the price-taking supplier equalizes the marginal revenue $p$ with the marginal cost $h + Hq$. This yields the inverse supply curve. In a monopolist economy, the marginal revenue of the firm is a function of the quantity it chooses:
1242+
$$
1243+
MR(q) = -2\mu^{-1}\Pi^{\top}\Pi q+\mu^{-1}\Pi^{\top}b,
1244+
$$
1245+
which the monopolist supplier equalizes with the marginal cost.
1246+
1247+
Our plot illustrates the fact that the monopolist supplier's equilibrium output is lower than either the competitive equilibrium or the social optimal level. In a single good case, this equilibrium is associated with a higher price of the good.
1248+
1249+
```python
1250+
def plot_monopoly(PE):
1251+
"""
1252+
Plot demand curve, marginal production cost and revenue, surpluses and the
1253+
equilibrium in a monopolist supplier economy with a single good
1254+
1255+
Args:
1256+
PE (class): A initialized production economy class
1257+
"""
1258+
# get singleton value
1259+
J, h, Pi, b, mu = PE.J.item(), PE.h.item(), PE.Pi.item(), PE.b.item(), PE.mu
1260+
H = J
1261+
1262+
# compute competitive equilibrium
1263+
c, p = PE.competitive_equilibrium()
1264+
q, pm = PE.equilibrium_with_monopoly()
1265+
c, p, q, pm = c.item(), p.item(), q.item(), pm.item()
1266+
1267+
# compute
1268+
1269+
# inverse supply/demand curve
1270+
marg_cost = lambda x: h + H*x
1271+
marg_rev = lambda x: -2*1/mu*Pi*Pi*x + 1/mu*Pi*b
1272+
demand_inv = lambda x: 1/mu*(Pi*b - Pi*Pi*x)
1273+
1274+
xs = np.linspace(0, 2*c, 100)
1275+
pms = np.ones(100) * pm
1276+
marg_cost_curve = marg_cost(xs)
1277+
marg_rev_curve = marg_rev(xs)
1278+
demand_curve = demand_inv(xs)
1279+
1280+
# plot
1281+
plt.figure(figsize=[7,5])
1282+
plt.plot(xs, marg_cost_curve, label='Marginal cost', color='#020060')
1283+
plt.plot(xs, marg_rev_curve, label='Marginal revenue', color='#E55B13')
1284+
plt.plot(xs, demand_curve, label='Demand', color='#600001')
1285+
1286+
plt.fill_between(xs[xs<=q], demand_curve[xs<=q], pms[xs<=q], label='Consumer surplus', color='#EED1CF')
1287+
plt.fill_between(xs[xs<=q], marg_cost_curve[xs<=q], pms[xs<=q], label='Producer surplus', color='#E6E6F5')
1288+
1289+
plt.vlines(c, 0, p, linestyle="dashed", color='black', alpha=0.7)
1290+
plt.hlines(p, 0, c, linestyle="dashed", color='black', alpha=0.7)
1291+
plt.scatter(c, p, zorder=10, label='Competitive equilibrium', color='#600001')
1292+
1293+
plt.vlines(q, 0, pm, linestyle="dashed", color='black', alpha=0.7)
1294+
plt.hlines(pm, 0, q, linestyle="dashed", color='black', alpha=0.7)
1295+
plt.scatter(q, pm, zorder=10, label='Equilibrium with monopoly', color='#E55B13')
1296+
1297+
plt.legend(loc='upper right')
1298+
plt.margins(x=0, y=0)
1299+
plt.ylim(0)
1300+
plt.xlabel('Quantity')
1301+
plt.ylabel('Price')
1302+
plt.show()
1303+
```
1304+
1305+
#### A multiple good example
1306+
1307+
```python
1308+
Pi = np.array([[1, 0],
1309+
[0, 1.2]])
1310+
b = np.array([10, 10])
1311+
1312+
h = np.array([0.5, 0.5])
1313+
J = np.array([[1, 0.5],
1314+
[0.5, 1]])
1315+
mu = 1
1316+
1317+
PE = Production_economy(Pi, b, h, J, mu)
1318+
c, p = PE.competitive_equilibrium()
1319+
q, pm = PE.equilibrium_with_monopoly()
1320+
1321+
print('Competitive equilibrium price:', p)
1322+
print('Competitive equilibrium allocation:', c)
1323+
1324+
print('Equilibrium with monopolist supplier price:', pm)
1325+
print('Equilibrium with monopolist supplier allocation:', q)
1326+
```
1327+
1328+
#### A single-good example
1329+
1330+
```python
1331+
Pi = np.array([[1]]) # the matrix now is a singleton
1332+
b = np.array([10])
1333+
h = np.array([0.5])
1334+
J = np.array([[1]])
1335+
mu = 1
1336+
1337+
PE = Production_economy(Pi, b, h, J, mu)
1338+
c, p = PE.competitive_equilibrium()
1339+
q, pm = PE.equilibrium_with_monopoly()
1340+
1341+
print('Competitive equilibrium price:', p.item())
1342+
print('Competitive equilibrium allocation:', c.item())
1343+
1344+
print('Equilibrium with monopolist supplier price:', pm.item())
1345+
print('Equilibrium with monopolist supplier allocation:', q.item())
1346+
1347+
# plot
1348+
plot_monopoly(PE)
1349+
```

lectures/_static/quant-econ.bib

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@
33
Note: Extended Information (like abstracts, doi, url's etc.) can be found in quant-econ-extendedinfo.bib file in _static/
44
###
55
6+
@article{sargent2023economic,
7+
title={Economic Networks: Theory and Computation},
8+
author={Sargent, Thomas J and Stachurski, John},
9+
journal={arXiv preprint arXiv:2203.11972},
10+
year={2023}
11+
}
12+
613

714
@article{Orcutt_Winokur_69,
8-
issn = {00129682, 14680262},
9-
abstract = {Monte Carlo techniques are used to study the first order autoregressive time series model with unknown level, slope, and error variance. The effect of lagged variables on inference, estimation, and prediction is described, using results from the classical normal linear regression model as a standard. In particular, use of the t and x^2 distributions as approximate sampling distributions is verified for inference concerning the level and residual error variance. Bias in the least squares estimate of the slope is measured, and two bias corrections are evaluated. Least squares chained prediction is studied, and attempts to measure the success of prediction and to improve on the least squares technique are discussed.},
1015
author = {Guy H. Orcutt and Herbert S. Winokur},
1116
journal = {Econometrica},
1217
number = {1},

lectures/_toc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ parts:
1717
- file: lp_intro
1818
- file: lln_clt
1919
- file: markov_chains
20+
- file: eigen
2021
- caption: Models
2122
numbered: true
2223
chapters:

0 commit comments

Comments
 (0)