-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathstep6.py
More file actions
58 lines (40 loc) · 1.24 KB
/
step6.py
File metadata and controls
58 lines (40 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# (c) 2022 - 2026 Open Risk (https://www.openriskmanagement.com)
import numpy as np
import pandas as pd
import pymrio
io = pymrio.IOSystem()
"""
Closed Models
Step 6 of the Academy Course [SFI32064](https://www.openriskacademy.com/course/view.php?id=64)
"""
sectors = ['S1', 'S2']
regions = ['R1']
Z_multiindex = pd.MultiIndex.from_product(
[regions, sectors], names=[u'region', u'sector'])
Z = pd.DataFrame(
data=np.array([
[150, 500],
[200, 100]]),
index=Z_multiindex,
columns=Z_multiindex
)
categories = ['final demand']
fd_multiindex = pd.MultiIndex.from_product(
[regions, categories], names=[u'region', u'category'])
Y = pd.DataFrame(
data=np.array([[0], [0]]),
index=Z_multiindex,
columns=fd_multiindex)
io.Z = Z
io.Y = Y
io.calc_all()
# Report
print("Z Table (Industry Transactions):\n", io.Z, "\n") # input
print("Y Table (Demand): \n", io.Y, "\n") # input
print("x Vector (Total Output): \n", io.x, "\n") # x = Z + Y
print("A Table (Normalized Transactions): \n", io.A, "\n") # A = Z / x
print("L Table (Leontief Inverse): \n", io.L, "\n") # L = 1 / (I - A)
# Calculate the determinant det(I - A)
I = np.eye(2)
determinant = np.linalg.det(I - io.A)
print("The determinant is ", determinant)