Regional Input -Output Models

Regional Input -Output Models

Input-output models are used for analyzing the propagation of demand throughout the economy. Find a snapshot of just a section of the python script below. A set of multipliers (GDP, Income, Employment, etc.) are created in a spreadsheet when executed.

#MATRIX CONSTRUCTION
#Identity and zero matrices
O=np.zeros((240,492))
OO=np.zeros((492,240))
I=np.identity(240)
II=np.identity(492)

#D matrices
a=np.transpose(np.array(supplytablealberta.iloc[5:497,2:242], dtype=float))
b=np.array(supplytablealberta.iloc[5:497,242], dtype=float)
D1=np.divide(a,b, out=np.zeros_like(a), where=b!=0)
a=np.transpose(np.array(supplytablecanada.iloc[5:497,2:242]-supplytablealberta.iloc[5:497,2:242], dtype=float))
b = np.array(supplytablecanada.iloc[5:497,242]-supplytablealberta.iloc[5:497,242], dtype=float)
D2=np.divide(a, b, out=np.zeros_like(a), where=b!=0)
D=np.vstack((np.hstack((D1,O)),np.hstack((O,D2))))

#B matrices
a=np.array(usetablealberta.iloc[5:497,2:242], dtype=float)
b=np.array(supplytablealberta.iloc[506,2:242], dtype=float)
B1=np.divide(a,b, out=np.zeros_like(a), where=b!=0)
a=np.array(usetablecanada.iloc[5:497,2:242]-usetablealberta.iloc[5:497,2:242], dtype=float)
b = np.array(supplytablecanada.iloc[506,2:242]-supplytablealberta.iloc[506,2:242], dtype=float)
B2=np.divide(a, b, out=np.zeros_like(a), where=b!=0)
B=np.vstack((np.hstack((B1,OO)),np.hstack((OO,B2))))
#MATRIX CONSTRUCTION
#Identity and zero matrices
O=np.zeros((240,492))
OO=np.zeros((492,240))
I=np.identity(240)
II=np.identity(492)

#D matrices
a=np.transpose(np.array(supplytablealberta.iloc[5:497,2:242], dtype=float))
b=np.array(supplytablealberta.iloc[5:497,242], dtype=float)
D1=np.divide(a,b, out=np.zeros_like(a), where=b!=0)
a=np.transpose(np.array(supplytablecanada.iloc[5:497,2:242]-supplytablealberta.iloc[5:497,2:242], dtype=float))
b = np.array(supplytablecanada.iloc[5:497,242]-supplytablealberta.iloc[5:497,242], dtype=float)
D2=np.divide(a, b, out=np.zeros_like(a), where=b!=0)
D=np.vstack((np.hstack((D1,O)),np.hstack((O,D2))))

#B matrices
a=np.array(usetablealberta.iloc[5:497,2:242], dtype=float)
b=np.array(supplytablealberta.iloc[506,2:242], dtype=float)
B1=np.divide(a,b, out=np.zeros_like(a), where=b!=0)
a=np.array(usetablecanada.iloc[5:497,2:242]-usetablealberta.iloc[5:497,2:242], dtype=float)
b = np.array(supplytablecanada.iloc[506,2:242]-supplytablealberta.iloc[506,2:242], dtype=float)
B2=np.divide(a, b, out=np.zeros_like(a), where=b!=0)
B=np.vstack((np.hstack((B1,OO)),np.hstack((OO,B2))))
#MATRIX CONSTRUCTION
#Identity and zero matrices
O=np.zeros((240,492))
OO=np.zeros((492,240))
I=np.identity(240)
II=np.identity(492)

#D matrices
a=np.transpose(np.array(supplytablealberta.iloc[5:497,2:242], dtype=float))
b=np.array(supplytablealberta.iloc[5:497,242], dtype=float)
D1=np.divide(a,b, out=np.zeros_like(a), where=b!=0)
a=np.transpose(np.array(supplytablecanada.iloc[5:497,2:242]-supplytablealberta.iloc[5:497,2:242], dtype=float))
b = np.array(supplytablecanada.iloc[5:497,242]-supplytablealberta.iloc[5:497,242], dtype=float)
D2=np.divide(a, b, out=np.zeros_like(a), where=b!=0)
D=np.vstack((np.hstack((D1,O)),np.hstack((O,D2))))

#B matrices
a=np.array(usetablealberta.iloc[5:497,2:242], dtype=float)
b=np.array(supplytablealberta.iloc[506,2:242], dtype=float)
B1=np.divide(a,b, out=np.zeros_like(a), where=b!=0)
a=np.array(usetablecanada.iloc[5:497,2:242]-usetablealberta.iloc[5:497,2:242], dtype=float)
b = np.array(supplytablecanada.iloc[506,2:242]-supplytablealberta.iloc[506,2:242], dtype=float)
B2=np.divide(a, b, out=np.zeros_like(a), where=b!=0)
B=np.vstack((np.hstack((B1,OO)),np.hstack((OO,B2))))

Interested in the full script?

Get access to the complete python scripts, excel data, pdfs and more

Interested in the full script?

Get access to the complete python scripts, excel data, pdfs and more

Interested in the full script?

Get access to the complete python scripts, excel data, pdfs and more