Search
local_SI
import numpy as np
import pandas as pd
import os
os.chdir('../')
from gravity import Gravity, Production, Attraction, Doubly, BaseGravity
import statsmodels.formula.api as smf
from statsmodels.api import families
import matplotlib.pyplot as plt
%pylab inline
Populating the interactive namespace from numpy and matplotlib
austria = pd.read_csv('http://dl.dropbox.com/u/8649795/AT_Austria.csv')
austria = austria[austria['Origin'] != austria['Destination']]
f = austria['Data'].values
o = austria['Origin'].values
d = austria['Destination'].values
dij = austria['Dij'].values
o_vars = austria['Oi2007'].values
d_vars = austria['Dj2007'].values
model = Gravity(f, o_vars, d_vars, dij, 'exp')
print model.params[-1]
-0.00976746026969
local = model.local(loc_index=o, locs=np.unique(o))
local['param2']
[-0.01699776161094757,
 -0.0053210259160796358,
 -0.0028594272276957211,
 -0.006533037784217155,
 -0.0024666647861060209,
 -0.0058258251130860472,
 -0.010739622617965516,
 -0.0046867791898773659,
 -0.0065940756391066335]
model = Production(f, o, d_vars, dij, 'exp')
print model.params[-1]
-0.00727113391179
local = model.local()
local['param2']
[-0.016997761610949791,
 -0.005321025916080413,
 -0.0028594272276953325,
 -0.0065330377842177101,
 -0.0024666647861060209,
 -0.0058258251130863803,
 -0.010739622617965183,
 -0.0046867791898770328,
 -0.0065940756391070776]
model = Attraction(f, d, o_vars, dij, 'exp')
print model.params[-1]
-0.00693754909526
local = model.local()
local['param2']
[-0.010872636479707154,
 -0.0054690202130680543,
 -0.0025567421332022833,
 -0.0051439340488994012,
 -0.0036020461535491433,
 -0.010088935906795271,
 -0.012926843651020203,
 -0.0075750287063747201,
 -0.0081576735088411123]