GitHub

@@ -24,7 +24,7 @@ because it shows the fundamental importance of *expectations*.

24242525

To give some idea of how the model operates, and why expectations matter, imagine the following scenario.

262627-

There is a market for soy beans, say, where prices and traded quantities

27+

There is a market for soybeans, say, where prices and traded quantities

2828

depend on the choices of buyers and sellers.

29293030

The buyers are represented by a demand curve --- they buy more at low prices

@@ -38,11 +38,11 @@ However, the sellers (who are farmers) need time to grow their crops.

3838

Suppose now that the price is currently high.

39394040

Seeing this high price, and perhaps expecting that the high price will remain

41-

for some time, the farmers plant many fields with soy beans.

41+

for some time, the farmers plant many fields with soybeans.

42424343

Next period the resulting high supply floods the market, causing the price to drop.

444445-

Seeing this low price, the farmers now shift out of soy beans, restricting

45+

Seeing this low price, the farmers now shift out of soybeans, restricting

4646

supply and causing the price to climb again.

47474848

You can imagine how these dynamics could cause cycles in prices and quantities

@@ -52,7 +52,7 @@ The cobweb model puts these ideas into equations so we can try to quantify

5252

them, and to study conditions under which cycles persist (or disappear).

53535454

In this lecture, we investigate and simulate the basic model under different

55-

assumptions regarding the way that produces form expectations.

55+

assumptions regarding the way that producers form expectations.

56565757

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).

5858

@@ -70,7 +70,7 @@ import matplotlib.pyplot as plt

70707171

Early papers on the cobweb cycle include {cite}`cobweb_model` and {cite}`hog_cycle`.

727273-

The paper {cite}`hog_cycle` uses the cobweb theorem to explain the prices of hog in the US over 1920--1950

73+

The paper {cite}`hog_cycle` uses the cobweb theorem to explain the prices of hog in the US over 1920--1950.

74747575

The next plot replicates part of Figure 2 from that paper, which plots the price of hogs at yearly frequency.

7676

@@ -94,9 +94,9 @@ plt.show()

94949595

## The model

969697-

Let's return to our discussion of a hypothetical soy bean market, where price is determined by supply and demand.

97+

Let's return to our discussion of a hypothetical soybean market, where price is determined by supply and demand.

989899-

We suppose that demand for soy beans is given by

99+

We suppose that demand for soybeans is given by

100100101101

$$

102102

D(p_t) = a - b p_t

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

106106107107

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

108108109-

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-1}$.

109+

Because the crop of soybeans for time $t$ is planted at $t-1$, supply of soybeans at time $t$ depends on *expected* prices at time $t$, which we denote $p^t_{t-1}$.

110110111111

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

112112113113

$$

114-

S(p^e_{t-1}) = \tanh(\lambda(p^e_{t-1} - c)) + d

114+

S(p^t_{t-1}) = \tanh(\lambda(p^t_{t-1} - c)) + d

115115

$$

116116117-

where $\lambda$ is a positive constant and $c, d \geq 0$.

117+

where $\lambda$ is a positive constant, $c, d$ are nonnegative constants and $\tanh$ is a type of [hyperbolic function](https://en.wikipedia.org/wiki/Hyperbolic_functions).

118118119119

Let's make a plot of supply and demand for particular choices of the parameter values.

120120

@@ -149,7 +149,7 @@ m = Market()

149149

fig, ax = plt.subplots()

150150151151

ax.plot(p_grid, m.demand(p_grid), label="$D$")

152-

ax.plot(p_grid, m.supply(p_grid), label="S")

152+

ax.plot(p_grid, m.supply(p_grid), label="$S$")

153153

ax.set_xlabel("price")

154154

ax.set_ylabel("quantity")

155155

ax.legend()

@@ -160,13 +160,13 @@ plt.show()

160160

Market equilibrium requires that supply equals demand, or

161161162162

$$

163-

a - b p_t = S(p^e_{t-1})

163+

a - b p_t = S(p^t_{t-1})

164164

$$

165165166166

Rewriting in terms of $p_t$ gives

167167168168

$$

169-

p_t = - \frac{1}{b} [S(p^e_{t-1}) - a]

169+

p_t = - \frac{1}{b} [S(p^t_{t-1}) - a]

170170

$$

171171172172

Finally, to complete the model, we need to describe how price expectations are formed.

@@ -177,7 +177,7 @@ In particular, we suppose that

177177178178

```{math}

179179

:label: p_et

180-

p^e_{t-1} = f(p_{t-1}, p_{t-2})

180+

p^t_{t-1} = f(p_{t-1}, p_{t-2})

181181

```

182182183183

where $f$ is some function.

@@ -204,7 +204,7 @@ Let's start with naive expectations, which refers to the case where producers ex

204204205205

In other words,

206206207-

$$ p_{t-1}^e = p_{t-1} $$

207+

$$ p_{t-1}^t = p_{t-1} $$

208208209209

Using {eq}`price_t`, we then have

210210

@@ -239,9 +239,9 @@ def g(model, current_price):

239239

return next_price

240240

```

241241242-

Let's try to understand how prices will evolve using a 45 degree diagram, which is a tool for studying one-dimensional dynamics.

242+

Let's try to understand how prices will evolve using a 45-degree diagram, which is a tool for studying one-dimensional dynamics.

243243244-

The function `plot45` defined below helps us draw the 45 degree diagram.

244+

The function `plot45` defined below helps us draw the 45-degree diagram.

245245246246

```{code-cell} ipython3

247247

:tags: [hide-input]

@@ -277,7 +277,7 @@ def plot45(model, pmin, pmax, p0, num_arrows=5):

277277278278

ax.plot(pgrid, g(model, pgrid), 'b-',

279279

lw=2, alpha=0.6, label='g')

280-

ax.plot(pgrid, pgrid, lw=1, alpha=0.7, label='45')

280+

ax.plot(pgrid, pgrid, lw=1, alpha=0.7, label='$45\degree$')

281281282282

x = p0

283283

xticks = [pmin]

@@ -316,7 +316,7 @@ def plot45(model, pmin, pmax, p0, num_arrows=5):

316316

plt.show()

317317

```

318318319-

Now we can set up a market and plot the 45 degree diagram.

319+

Now we can set up a market and plot the 45-degree diagram.

320320321321

```{code-cell} ipython3

322322

m = Market()

@@ -326,21 +326,21 @@ m = Market()

326326

plot45(m, 0, 9, 2, num_arrows=3)

327327

```

328328329-

The plot shows the function $g$ defined in {eq}`def_g` and the $45$ degree line.

329+

The plot shows the function $g$ defined in {eq}`def_g` and the $45\degree$ line.

330330331331

Think of $ p_t $ as a value on the horizontal axis.

332332333333

Since $p_{t+1} = g(p_t)$, we use the graph of $g$ to see $p_{t+1}$ on the vertical axis.

334334335335

Clearly,

336336337-

- If $ g $ lies above the 45 degree line at $p_t$, then we have $ p_{t+1} > p_t $.

338-

- If $ g $ lies below the 45 degree line at $p_t$, then we have $ p_{t+1} < p_t $.

339-

- If $ g $ hits the 45 degree line at $p_t$, then we have $ p_{t+1} = p_t $, so $ p_t $ is a steady state.

337+

- If $ g $ lies above the 45-degree line at $p_t$, then we have $ p_{t+1} > p_t $.

338+

- If $ g $ lies below the 45-degree line at $p_t$, then we have $ p_{t+1} < p_t $.

339+

- If $ g $ hits the 45-degree line at $p_t$, then we have $ p_{t+1} = p_t $, so $ p_t $ is a {ref}` steady state <scalar-dynam:steady-state>`.

340340341341

Consider the sequence of prices starting at $p_0$, as shown in the figure.

342342343-

We find $p_1$ on the vertical axis and then shift it to the horizontal axis using the 45 degree line (where values on the two axes are equal).

343+

We find $p_1$ on the vertical axis and then shift it to the horizontal axis using the 45-degree line (where values on the two axes are equal).

344344345345

Then from $p_1$ we obtain $p_2$ and continue.

346346

@@ -408,15 +408,15 @@ That is,

408408409409

```{math}

410410

:label: pe_adaptive

411-

p_{t-1}^e = \alpha p_{t-1} + (1-\alpha) p^e_{t-2}

411+

p_{t-1}^t = \alpha p_{t-1} + (1-\alpha) p^t_{t-2}

412412

\qquad (0 \leq \alpha \leq 1)

413413

```

414414415415

Another way to write this is

416416417417

```{math}

418418

:label: pe_adaptive_2

419-

p_{t-1}^e = p^e_{t-2} + \alpha (p_{t-1} - p_{t-2}^e)

419+

p_{t-1}^t = p^t_{t-2} + \alpha (p_{t-1} - p_{t-2}^t)

420420

```

421421422422

This equation helps to show that expectations shift

@@ -427,7 +427,7 @@ This equation helps to show that expectations shift

427427

Using {eq}`pe_adaptive`, we obtain the dynamics

428428429429

$$

430-

p_t = - \frac{1}{b} [ S(\alpha p_{t-1} + (1-\alpha) p^e_{t-2}) - a]

430+

p_t = - \frac{1}{b} [ S(\alpha p_{t-1} + (1-\alpha) p^t_{t-2}) - a]

431431

$$

432432433433

@@ -464,7 +464,6 @@ def ts_price_plot_adaptive(model, p0, ts_length=10, α=[1.0, 0.9, 0.75]):

464464465465

Let's call the function with prices starting at $p_0 = 5$.

466466467-

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

468467469468

```{code-cell} ipython3

470469

ts_price_plot_adaptive(m, 5, ts_length=30)

@@ -478,7 +477,6 @@ expectations, which stabilizes expected prices.

478477

This increased stability can be seen in the figures.

479478480479481-

TODO check / fix exercises

482480483481

## Exercises

484482

@@ -547,7 +545,7 @@ That is,

547545548546

```{math}

549547

:label: pe_blae

550-

p_{t-1}^e = \alpha p_{t-1} + (1-\alpha) p_{t-2}

548+

p_{t-1}^t = \alpha p_{t-1} + (1-\alpha) p_{t-2}

551549

```

552550553551

Read the original on github.com ↗