/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numpy/core/records.py:507: FutureWarning: Numpy has detected that you may be viewing or writing to an array returned by selecting multiple fields in a structured array.
This code may break in numpy 1.13 because this will return a view instead of a copy -- see release notes for details.
return obj.view(dtype=(self.dtype.type, obj.dtype))
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/statsmodels/tsa/tsatools.py:121: FutureWarning: Assignment between structured arrays with different field names will change in numpy 1.13.
Previously fields in the dst would be set to the value of the identically-named field in the src. In numpy 1.13 fields will instead be assigned 'by position': The Nth field of the dst will be set to the Nth field of the src array.
See the release notes for details
x = x.astype(np.dtype(descr))
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numpy/linalg/linalg.py:1587: FutureWarning: elementwise == comparison failed and returning scalar instead; this will raise an error or perform elementwise comparison in the future.
return int(not all(M==0))
Traceback (most recent call last):
File "delete.py", line 68, in <module>
grun_mod = SUR(grun_sys)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/statsmodels/sandbox/sysreg.py", line 129, in __init__
self._cols[i]:self._cols[i+1]] = sys[1::2][i]
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/scipy/sparse/lil.py", line 363, in __setitem__
i, j = self._index_to_arrays(i, j)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/scipy/sparse/sputils.py", line 356, in _index_to_arrays
i = self._slicetoarange(i, self.shape[0])[:, None]
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/scipy/sparse/sputils.py", line 262, in _slicetoarange
start, stop, step = j.indices(shape)
TypeError: slice indices must be integers or None or have an __index__ method
from statsmodels.compat.python import lmap, asbytes | |
import numpy as np | |
import statsmodels.api as sm | |
from statsmodels.sandbox.sysreg import * | |
#for Python 3 compatibility | |
# Seemingly Unrelated Regressions (SUR) Model | |
# This example uses the subset of the Grunfeld data in Greene's Econometric | |
# Analysis Chapter 14 (5th Edition) | |
grun_data = sm.datasets.grunfeld.load() | |
firms = ['General Motors', 'Chrysler', 'General Electric', 'Westinghouse', | |
'US Steel'] | |
#for Python 3 compatibility | |
firms = lmap(asbytes, firms) | |
grun_exog = grun_data.exog | |
grun_endog = grun_data.endog | |
# Right now takes SUR takes a list of arrays | |
# The array alternates between the LHS of an equation and RHS side of an | |
# equation | |
# This is very likely to change | |
grun_sys = [] | |
for i in firms: | |
index = grun_exog['firm'] == i | |
grun_sys.append(grun_endog[index]) | |
exog = grun_exog[index][['value','capital']].view(float).reshape(-1,2) | |
exog = sm.add_constant(exog, prepend=True) | |
grun_sys.append(exog) | |
grun_mod = SUR(grun_sys) | |
grun_res = grun_mod.fit() | |
print("Results for the 2-step GLS") | |
print("Compare to Greene Table 14.1, 5th edition") | |
print(grun_res.params) |