Skip to content

Commit 9565240

Browse files
Tom's afternoon edit of supply-demand* lecture with code advice for Jiacheng
1 parent 6014a4b commit 9565240

File tree

1 file changed

+119
-9
lines changed

1 file changed

+119
-9
lines changed

in-work/quantecon_undergrad_notes_tom_3.md

Lines changed: 119 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<!-- #region -->
12

23
## Elements of Supply and Demand
34

@@ -123,6 +124,7 @@ We study a setting with $n$ goods and $n$ corresponding prices.
123124
We apply formulas from linear algebra for
124125
125126
* differentiating an inner product
127+
* differentiating a product of a matrix and a vector
126128
* differentiating a quadratic form
127129
128130
Where $a$ is an $n \times 1$ vector, $A$ is an $n \times n$ matrix, and $x$ is an $n \times 1$ vector:
@@ -131,6 +133,10 @@ $$
131133
\frac{\partial a^\top x }{\partial x} = a
132134
$$
133135
136+
$$
137+
\frac{\partial A x} {\partial x} = A
138+
$$
139+
134140
$$
135141
\frac{\partial x^\top A x}{\partial x} = (A + A^\top)x
136142
$$
@@ -147,9 +153,18 @@ Let
147153
148154
We assume that $\Pi$ has an inverse $\Pi^{-1}$ and that $\Pi^\top \Pi$ is a positive definite matrix.
149155
156+
It follows that $\Pi^\top \Pi$ has an inverse.
157+
158+
150159
The matrix $\Pi$ describes a consumer's willingness to substitute one good for another, for each pair of
151160
good in the $n \times 1$ vector $c$.
152161
162+
In particular, we shall see below that $(\Pi^T \Pi)^{-1}$ is a matrix of slopes of (compensated) demand curves for $c$ with respect to a vector of prices:
163+
164+
$$
165+
{\partial c } {\partial p} = (\Pi^T \Pi)^{-1}
166+
$$
167+
153168
A consumer faces $p$ as a price taker and chooses $c$ to maximize the utility function
154169
155170
$$
@@ -165,12 +180,12 @@ $$ (eq:old2)
165180
We shall specify examples in which $\Pi$ and $b$ are such that it typically happens that
166181
167182
$$
168-
\Pi b > > c
183+
\Pi c < < b
169184
$$ (eq:bversusc)
170185
171-
so that utility function {eq}`eq:old2` tells us that the consumer has consumes of each good that he wants.
186+
so that utility function {eq}`eq:old2` tells us that the consumer has much less of each good than he wants.
172187
173-
Condition {eq}`eq:bversusc` will ultimately assure us that competitive equilibrium prices are all positive.
188+
Condition {eq}`eq:bversusc` will ultimately assure us that competitive equilibrium prices are all positive.
174189
175190
## Digression: Marshallian and Hicksian Demand Curves
176191
@@ -548,20 +563,115 @@ $$
548563
549564
which implies {eq}`eq:old5p`.
550565
551-
Thus, in the multiple case as for the single-good case, a competitive equilibrium quantity solves a planning problem.
566+
Thus, as for the single-good case, with multiple goods a competitive equilibrium quantity vector solves a planning problem.
552567
553568
(This is another version of the first welfare theorem.)
554569
555570
We can read the competitive equilbrium price vector off the inverse demand curve or the inverse supply curve.
556571
572+
<!-- #endregion -->
573+
574+
<!-- #region -->
575+
## Notes to Jiacheng for coding
576+
577+
Hi Jiacheng.
557578
579+
These are just some suggestions about how to begin writing code.
558580
559-
## To do
581+
I sketch some things that are "not even pseudo code". Here goes.
560582
561-
Tom has multi consumer version of pure exchange economy
583+
I recommend that we start "general" and write a Python class that will do "everything".
562584
563-
Two types of represenative agent
585+
Once we get that working with a bunch of fun examples, we can then "work backwards" and make some very simple "baby code" that starts with simple cases (e.g., a scalar case) and graduallly builds up to the class.
564586
565-
* Gorman (everyone has some $\Pi$)
587+
The fun thing will be to make some revealing examples.
588+
589+
I recommend making a Python class with the following attributes:
590+
591+
* **Preferences** in the form of
592+
593+
* an $n \times n$ positive definite matrix $\Pi$
594+
* an $n \times 1$ vector of bliss points $b$
595+
596+
* **Endowments** in the form of
597+
598+
* an $n \times 1$ vector $e$
599+
* a scalar "wealth" $W$ with default value $0$
566600
567-
* mongrel (heterogeneous $\Pi$)
601+
* **Production Costs** $C(q) = h^\top q + .5 q^\top J q $ indexed by
602+
603+
* an $n \times 1$ nonnegative vector $h$
604+
* an $n \times n$ positive definite matrix $J$
605+
606+
Along the lines of your great suggestion (now incorporated in the main text in the previous cell)
607+
the class would do a test to make sure that $b > > \Pi e $ and raise an exception if it is violated
608+
(at some threshold level we'd have to specify).
609+
610+
* **A Person** in the form of a pair that consists of
611+
612+
* **Preferences** and **Endowments**
613+
614+
* **A Pure Exchange Economy** consists of
615+
616+
* a collection of $m$ **persons**
617+
618+
* $m=1$ for our single-agent economy
619+
* $m=2$ for our illustrations of a pure exchange economy
620+
621+
* an equilibrium price vector $p$ (normalized somehow)
622+
* an equilibrium allocation $c^1, c^2, \ldots, c^m$ -- a collection of $m$ vectors of dimension $n \times 1$
623+
624+
* **A Production Economy** consists of
625+
626+
* a single **person** that we'll interpret as a representative consumer
627+
* a single set of **production costs**
628+
* a multiplier $\mu$ that weights "consumers" versus "producers" in a planner's welfare function, as described above in the main text
629+
* an $n \times 1$ vector $p$ of competitive equilibrium prices
630+
* an $n \times 1$ vector $c$ of competitive equilibrium quantities
631+
* **consumer surplus**
632+
* **producer surplus**
633+
634+
635+
636+
**Remark:** I don't know whether we want to be simple or fancy in terms of using class inheritance in creating a person or an economy.
637+
638+
639+
## Some experiments
640+
641+
642+
* Single agent with one good and with production
643+
644+
* specify a single **person** and a **cost curve** in a way that let's us replicate the simple
645+
single-good supply demand example with which we started
646+
* compute equilibrium $p$ and $c$ and consumer and producer surpluses
647+
648+
*if possible draw graphs of both surpluses
649+
650+
* do some experiments in which we shift $b$ and watch what happens to $p, c$.
651+
652+
* Single agent two-good economy **with** production
653+
654+
* do the counterparts of the above
655+
* do some experiments with **diagonal** $\Pi$ and also with **non-diagonal** $\Pi$ matrices to study
656+
how cross-slopes affect responses of $p$ and $c$ to various shifts in $b$
657+
658+
* Two-person economy **without** production
659+
660+
* study how competive equilibrium $p, c^1, c^2$ responds to various combinations of different
661+
662+
* $b^i$'s
663+
* $e^i$'s
664+
665+
* The simple example in the text of a **dynamic economy**
666+
667+
* The simple example in the text of an exchange economy with two **Arrow securities**
668+
669+
670+
671+
672+
673+
<!-- #endregion -->
674+
675+
```python
676+
677+
```

0 commit comments

Comments
 (0)