Skip to content

Commit c622acf

Browse files
committed
input output lecture edits
1 parent 42031d9 commit c622acf

File tree

1 file changed

+121
-14
lines changed

1 file changed

+121
-14
lines changed

lectures/input_output.md

Lines changed: 121 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,103 @@ jupytext:
44
extension: .md
55
format_name: myst
66
format_version: 0.13
7-
jupytext_version: 1.14.4
7+
jupytext_version: 1.14.5
88
kernelspec:
99
display_name: Python 3 (ipykernel)
1010
language: python
1111
name: python3
1212
---
1313

14+
+++ {"user_expressions": []}
15+
1416
(input_output)=
1517

1618
In this lecture, we will need the following library.
1719

18-
+++
20+
+++ {"user_expressions": []}
1921

2022
# Input-Output Models
2123

2224
## Overview
2325

24-
We adopt notation in chapters 8 and 9 of the classic book {cite}`DoSSo`.
26+
The following figure illustrates a network of linkages between 71 sectors obtained from the US Bureau of Economic Analysis’s
27+
2019 Input-Output Accounts Data.
28+
29+
```{code-cell} ipython3
30+
---
31+
jupyter:
32+
outputs_hidden: true
33+
source_hidden: true
34+
---
35+
pip install --upgrade quantecon_book_networks
36+
pip install quantecon
37+
```
38+
39+
```{code-cell} ipython3
40+
import numpy as np
41+
import pandas as pd
42+
import networkx as nx
43+
```
44+
45+
```{code-cell} ipython3
46+
#hide
47+
48+
import quantecon as qe
49+
import quantecon_book_networks
50+
import quantecon_book_networks.input_output as qbn_io
51+
import quantecon_book_networks.plotting as qbn_plt
52+
import quantecon_book_networks.data as qbn_data
53+
ch2_data = qbn_data.production()
54+
import matplotlib.pyplot as plt
55+
import matplotlib.cm as cm
56+
import matplotlib.colors as plc
57+
from matplotlib import cm
58+
quantecon_book_networks.config("matplotlib")
59+
import matplotlib as mpl
60+
mpl.rcParams.update(mpl.rcParamsDefault)
61+
62+
codes_71 = ch2_data['us_sectors_71']['codes']
63+
A_71 = ch2_data['us_sectors_71']['adjacency_matrix']
64+
X_71 = ch2_data['us_sectors_71']['total_industry_sales']
65+
66+
centrality_71 = qbn_io.eigenvector_centrality(A_71)
67+
color_list_71 = qbn_io.colorise_weights(centrality_71,beta=False)
68+
69+
fig, ax = plt.subplots(figsize=(10, 12))
70+
plt.axis("off")
71+
72+
qbn_plt.plot_graph(A_71, X_71, ax, codes_71,
73+
node_size_multiple=0.0005,
74+
edge_size_multiple=4.0,
75+
layout_type='spring',
76+
layout_seed=5432167,
77+
tol=0.01,
78+
node_color_list=color_list_71)
79+
80+
plt.show()
81+
```
82+
83+
+++ {"user_expressions": []}
84+
85+
An arrow from $i$ to $j$ implies that sector $i$ supplies some of its output as raw material to sector $j$.
86+
87+
Economies are characterised by many such complex and interdependent multisector production networks.
88+
89+
A basic framework for their analysis is [Leontief's](https://en.wikipedia.org/wiki/Wassily_Leontief) input-output model.
90+
91+
This model's key aspect is its simplicity.
92+
93+
In this lecture, we introduce the standard input-ouput model and approach it as a [linear programming](link to lpp lecture) problem.
94+
95+
+++ {"user_expressions": []}
2596

26-
We let
97+
## Input Output Analysis
2798

28-
* $X_0$ be the amount of a single exogenous input to production. We'll call this input labor
99+
We adopt notation from chapters 9 and 10 of the classic book {cite}`DoSSo`.
100+
101+
Let
102+
103+
* $X_0$ be the amount of a single exogenous input to production, say labor
29104
* $X_j, j = 1,\ldots n$ be the gross output of final good $j$
30105
* $C_j, j = 1,\ldots n$ be the net output of final good $j$ that is available for final consumption
31106
* $x_{ij} $ be the quantity of good $i$ allocated to be an input to producing good $j$ for $i=1, \ldots n$, $j = 1, \ldots n$
@@ -43,9 +118,45 @@ X_j = \min_{i \in \{0, \ldots , n \}} \left( \frac{x_{ij}}{a_{ij}}\right)
43118
$$
44119

45120

46-
To illustrate ideas, we'll begin by setting $n =2$.
121+
To illustrate ideas, we begin by setting $n =2$.
122+
123+
The following is a simple illustration of this network.
124+
125+
```{code-cell} ipython3
126+
---
127+
jupyter:
128+
source_hidden: true
129+
---
130+
G = nx.DiGraph()
131+
132+
nodes= (1,2)
133+
edges = ((1,1),(1,2),(2,1),(2,2))
134+
G.add_nodes_from(nodes)
135+
G.add_edges_from(edges)
136+
137+
pos_list = ([0,0],[2,0])
138+
pos = dict(zip(G.nodes(), pos_list))
139+
labels = (f'a_{11}',f'a_{12}',r'$a_{21}$',f'a_{22}')
140+
edge_labels = dict(zip(G.edges(), labels))
141+
142+
plt.axis("off")
143+
144+
nx.draw_networkx_nodes(G, pos=pos,node_size=800,node_color = 'white', edgecolors='black')
145+
nx.draw_networkx_labels(G, pos=pos)
146+
nx.draw_networkx_edges(G,pos = pos,node_size=300,connectionstyle='arc3,rad=0.2',arrowsize=10,min_target_margin=15)
147+
#nx.draw_networkx_edge_labels(G, pos=pos, edge_labels = edge_labels)
148+
plt.text(0.055,0.125, r'$x_{11}$')
149+
plt.text(1.825,0.125, r'$x_{22}$')
150+
plt.text(0.955,0.075, r'$x_{21}$')
151+
plt.text(0.955,-0.05, r'$x_{12}$')
152+
153+
154+
plt.show()
155+
```
156+
157+
+++ {"user_expressions": []}
47158

48-
Feasible allocations must satisfy
159+
#### Feasible allocations must satisfy
49160

50161
$$
51162
\begin{aligned}
@@ -182,7 +293,9 @@ $$
182293
183294
where $^*$'s denote optimal choices for the primal and dual problems.
184295
185-
+++
296+
```{code-cell} ipython3
297+
298+
```
186299
187300
## Exercise
188301
@@ -231,12 +344,6 @@ $$
231344
232345
where $L$ is a vector of labor services used in each industry.
233346
234-
235-
236-
237-
238-
239-
240347
```{code-cell} ipython3
241348
242349
```

0 commit comments

Comments
 (0)