Skip to content

Commit ec86ca0

Browse files
authored
Merge pull request #64 from QuantEcon/cobweb_2
LECT: Cobweb-Fix citation
2 parents a693d37 + a87d92d commit ec86ca0

File tree

2 files changed

+93
-18
lines changed

2 files changed

+93
-18
lines changed

lectures/_static/quant-econ.bib

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2530,4 +2530,34 @@ @article{benhabib_wealth_2019
25302530
year = {2019},
25312531
keywords = {Personal Income, Wealth, and Their Distributions, General Aggregative Models: Neoclassical, Macroeconomics: Consumption, Saving, Wealth, Aggregate Factor Income Distribution},
25322532
pages = {1623--1647},
2533-
}
2533+
}
2534+
2535+
2536+
@article{cobweb_model,
2537+
ISSN = {10711031},
2538+
URL = {http://www.jstor.org/stable/1236509},
2539+
abstract = {In recent years, economists have become much interested in recursive models. This interest stems from a growing need for long-term economic projections and for forecasting the probable effects of economic programs and policies. In a dynamic world, past and present conditions help shape future conditions. Perhaps the simplest recursive model is the two-dimensional "cobweb diagram," discussed by Ezekiel in 1938. The present paper attempts to generalize the simple cobweb model somewhat. It considers some effects of price supports. It discusses multidimensional cobwebs to describe simultaneous adjustments in prices and outputs of a number of commodities. And it allows for time trends in the variables.},
2540+
author = {Frederick V. Waugh},
2541+
journal = {Journal of Farm Economics},
2542+
number = {4},
2543+
pages = {732--750},
2544+
publisher = {[Oxford University Press, Agricultural & Applied Economics Association]},
2545+
title = {Cobweb Models},
2546+
urldate = {2023-02-06},
2547+
volume = {46},
2548+
year = {1964}
2549+
}
2550+
2551+
@article{hog_cycle,
2552+
author = {Harlow, Arthur A.},
2553+
title = {The Hog Cycle and the Cobweb Theorem},
2554+
journal = {American Journal of Agricultural Economics},
2555+
volume = {42},
2556+
number = {4},
2557+
pages = {842-853},
2558+
doi = {https://doi.org/10.2307/1235116},
2559+
url = {https://onlinelibrary.wiley.com/doi/abs/10.2307/1235116},
2560+
eprint = {https://onlinelibrary.wiley.com/doi/pdf/10.2307/1235116},
2561+
abstract = {Abstract A surprisingly regular four year cycle in hogs has become apparent in the past ten years. This regularity presents an unusual opportunity to study the mechanism of the cycle because it suggests the cycle may be inherent within the industry rather than the result of lagged responses to outside influences. The cobweb theorem is often mentioned as a theoretical tool for explaining the hog cycle, although a two year cycle is usually predicted. When the nature of the hog industry is examined, certain factors become apparent which enable the cobweb theorem to serve as a theoretical basis for the present four year cycle.},
2562+
year = {1960}
2563+
}

lectures/cobweb.md

Lines changed: 62 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ jupytext:
33
text_representation:
44
extension: .md
55
format_name: myst
6+
format_version: 0.13
7+
jupytext_version: 1.14.1
68
kernelspec:
79
display_name: Python 3 (ipykernel)
810
language: python
@@ -13,9 +15,11 @@ kernelspec:
1315
# The Cobweb Model
1416

1517

16-
The cobweb model {cite}:`10.2307/1236509` is a model of prices and quantities in a given market, and how they evolve over time.
18+
The cobweb model is a model of prices and quantities in a given market, and how they evolve over time.
1719

18-
The model dates back to the 1930s and, while simple, it remains significant
20+
## Overview
21+
22+
The cobweb model dates back to the 1930s and, while simple, it remains significant
1923
because it shows the fundamental importance of *expectations*.
2024

2125
To give some idea of how the model operates, and why expectations matter, imagine the following scenario.
@@ -52,15 +56,46 @@ assumptions regarding the way that produces form expectations.
5256

5357
Our discussion and simulations draw on [high quality lectures](https://comp-econ.org/CEF_2013/downloads/Complex%20Econ%20Systems%20Lecture%20II.pdf) by [Cars Hommes](https://www.uva.nl/en/profile/h/o/c.h.hommes/c.h.hommes.html).
5458

55-
We will use the following imports:
59+
60+
+++
61+
62+
We will use the following imports.
5663

5764
```{code-cell} ipython3
5865
import numpy as np
5966
import matplotlib.pyplot as plt
6067
```
6168

69+
## History
70+
71+
Early papers on the cobweb cycle include {cite}`cobweb_model` and {cite}`hog_cycle`.
72+
73+
The paper {cite}`hog_cycle` uses the cobweb theorem to explain the prices of hog in the US over 1920--1950
74+
75+
The next plot replicates part of Figure 2 from that paper, which plots the price of hogs at yearly frequency.
76+
77+
Notice the cyclical price dynamics, which match the kind of cyclical soybean price dynamics discussed above.
78+
79+
```{code-cell} ipython3
80+
hog_prices = [55, 57, 80, 70, 60, 65, 72, 65, 51, 49, 45, 80, 85,
81+
78, 80, 68, 52, 65, 83, 78, 60, 62, 80, 87, 81, 70,
82+
69, 65, 62, 85, 87, 65, 63, 75, 80, 62]
83+
years = np.arange(1924, 1960)
84+
fig, ax = plt.subplots()
85+
ax.plot(years, hog_prices, '-o', ms=4, label='hog price')
86+
ax.set_xlabel('year')
87+
ax.set_ylabel('dollars')
88+
ax.legend()
89+
ax.grid()
90+
plt.show()
91+
```
92+
93+
94+
6295
## The Model
6396

97+
Let's return to our discussion of a hypothetical soy bean market, where price is determined by supply and demand.
98+
6499
We suppose that demand for soy beans is given by
65100

66101
$$
@@ -71,7 +106,7 @@ where $a, b$ are nonnegative constants and $p_t$ is the spot (i.e, current marke
71106

72107
($D(p_t)$ is the quantity demanded in some fixed unit, such as thousands of tons.)
73108

74-
Supply of soy beans depends on *expected* prices at time $t$, which we denote $p^e_t$.
109+
Because the crop of soy beans for time $t$ is planted at $t-1$, supply of soy beans at time $t$ depends on *expected* prices at time $t$, which we denote $p^e_t$.
75110

76111
We suppose that supply is nonlinear in expected prices, and takes the form
77112

@@ -210,6 +245,7 @@ The function `plot45` defined below helps us draw the 45 degree diagram.
210245

211246
```{code-cell} ipython3
212247
:tags: [hide-input]
248+
213249
def plot45(model, pmin, pmax, p0, num_arrows=5):
214250
"""
215251
Function to plot a 45 degree plot
@@ -352,7 +388,7 @@ The cycle is "stable", in the sense that prices converge to it from most startin
352388

353389
For example,
354390

355-
```{code-cell} ipython3 tags=[]
391+
```{code-cell} ipython3
356392
ts_plot_price(m, 10, ts_length=15)
357393
```
358394

@@ -430,7 +466,6 @@ Let's call the function with prices starting at $p_0 = 5$.
430466

431467
TODO does this fit well in the page, even in the pdf? If not should it be stacked vertically?
432468

433-
434469
```{code-cell} ipython3
435470
ts_price_plot_adaptive(m, 5, ts_length=30)
436471
```
@@ -450,7 +485,7 @@ TODO check / fix exercises
450485
```{exercise-start}
451486
:label: cobweb_ex1
452487
```
453-
Using the default Market model and naive expectations, plot a time series simulation of supply (rather than the price).
488+
Using the default `Market` class and naive expectations, plot a time series simulation of supply (rather than the price).
454489

455490
Show, in particular, that supply also cycles.
456491

@@ -482,10 +517,12 @@ def ts_plot_supply(model, p0, ts_length=10):
482517
'bo-',
483518
alpha=0.6,
484519
lw=2,
485-
label=r'$S_t$')
520+
label=r'supply')
486521
487522
ax.legend(loc='best', fontsize=10)
488523
ax.set_xticks(np.arange(ts_length))
524+
ax.set_xlabel("time")
525+
ax.set_ylabel("quantity")
489526
plt.show()
490527
```
491528

@@ -538,30 +575,38 @@ def ts_plot_price_blae(model, p0, p1, alphas, ts_length=15):
538575
Function to simulate and plot the time series of price
539576
using backward looking average expectations.
540577
"""
541-
fig, ax = plt.subplots()
542-
ax.set_xlabel(r'$t$', fontsize=12)
543-
ax.set_ylabel(r'$p_t$', fontsize=12)
544-
for a in alphas:
578+
fig, axes = plt.subplots(len(alphas), 1, figsize=(8, 16))
579+
580+
for ax, a in zip(axes.flatten(), alphas):
545581
p = np.empty(ts_length)
546-
p[0] = p[0]
547-
p[1] = p[1]
582+
p[0] = p0
583+
p[1] = p1
548584
for t in range(2, ts_length):
549585
pe = a*p[t-1] + (1 - a)*p[t-2]
550586
p[t] = -(model.supply(pe) - model.a) / model.b
551587
ax.plot(np.arange(ts_length),
552588
p,
553589
'o-',
554590
alpha=0.6,
555-
label=r'$\alpha={}$'.format(a),
556-
c=np.random.rand(3))
591+
label=r'$\alpha={}$'.format(a))
557592
ax.legend(loc='best', fontsize=10)
593+
ax.set_xlabel(r'$t$', fontsize=12)
594+
ax.set_ylabel(r'$p_t$', fontsize=12)
558595
plt.show()
559596
```
560597

561598
```{code-cell} ipython3
562599
m = Market()
563-
ts_plot_price_blae(m, 1, 2.5, [0.1, 0.3, 0.5, 0.8], 20)
600+
ts_plot_price_blae(m,
601+
p0=5,
602+
p1=6,
603+
alphas=[0.1, 0.3, 0.5, 0.8],
604+
ts_length=20)
564605
```
565606

566607
```{solution-end}
567608
```
609+
610+
```{code-cell} ipython3
611+
612+
```

0 commit comments

Comments
 (0)