Examen

Geografia Turismului

V1

Exchange of Goods and Services in the U.S. for 1947 (in billions of 1947 dollars)


In [58]:
import numpy as np
import pandas as pd

In [2]:
ls


Exam v 0_1.ipynb  leontief.csv  QE_P2L01.ipynb  Untitled0.ipynb

In [16]:
f = open('leontief.csv')

In [17]:
Names = (f.next().strip()).split(',')
data =[]

In [18]:
for row in f:
    #np.vstack(data,(row.strip().split(',')))
    data.append(row.strip().split(','))

In [35]:
data = np.array(data)

# Extracting External Demand
Ex_Demand= data[:-1][:,-1]
Ex_Demand=Ex_Demand.astype(float)
# Extracting Gross Product
Gross_Product = data[-1][:-1]
Gross_Product=Gross_Product.astype(float)
# Extracting Expenditures Matrix
A = data[:-1][:,:-1]
A=A.astype(float)

print Ex_Demand
print Gross_Product
print A


[  39.24   60.02  130.65]
[  84.56  163.43  219.03]
[[ 34.69   4.92   5.62]
 [  5.28  61.28  22.99]
 [ 10.45  25.95  42.03]]

In [43]:
Demand = []
for i in xrange(len(A[0])):
    Demand.append (sum(A[i])+Ex_Demand[i])
Demand= np.array(Demand)
Income = Gross_Product - Demand
Income


Out[43]:
array([  0.09,  13.86,   9.95])

In [68]:
A_tc = A / Gross_Product
print A_tc


[[ 0.41024125  0.03010463  0.02565859]
 [ 0.06244087  0.37496176  0.10496279]
 [ 0.12358089  0.15878358  0.19189152]]

In [74]:
L = (np.identity(len(A[0])) - A_tc)
L


Out[74]:
array([[ 0.58975875, -0.03010463, -0.02565859],
       [-0.06244087,  0.62503824, -0.10496279],
       [-0.12358089, -0.15878358,  0.80810848]])

In [73]:
linalg.inv(L)


Out[73]:
array([[ 1.72036911,  0.10003816,  0.06761781],
       [ 0.22341618,  1.66748571,  0.2236785 ],
       [ 0.30698795,  0.34293929,  1.29174829]])

In [77]:
P = np.dot(linalg.inv(L), Ex_Demand)

In [78]:
P


Out[78]:
array([  82.3458407 ,  138.07293955,  201.39633704])

$ Turisti_{t} = \alpha * Turisti_{t-1} + \beta_{0} +\beta_{1}GDP_{cap} + \beta_{2}\frac{Prices_{foreign}}{Prices_{home}} + \beta_{3}*ExRate_{\frac{Foreign}{MDL}}+\beta_{4}CO_{2}$


In [ ]:


In [ ]:


In [ ]: