Hello,
I am trying to use statsmodels package to develop a seemingly unrelated regression model.
A simple overview of the model - There are 14 equations with 1 endogenous and 2 exogenous variables ( A ~ B + C).
endogenous and exogenous variables. Below is the code.
There are 14 zones which represent the 14 equations. data is the dataframe with data for all 14 equations/zones. y_vars, x1_vars and x2_vars are lists of the column names which represent the endog and exog variables.
sur_list=[]
sur_array=np.empty(shape=(len(data),3))
for z,zone in enumerate(zones):
sur_array[:,0]=data[y_vars[z]]
sur_array[:,1]=data[x2_vars[z]]
sur_array[:,2]=data[x1_vars[z]]
sur_list+=[sur_array[:,0].astype(int)]
sur_list+=[sur_array[:,1:3].astype(int)]
sur_mod = SUR(sur_list)
sur_res = sur_mod.fit()
I'm getting the following error.
File "<ipython-input-22-ae788a9d656c>", line 31, in <module>
sur_mod = SUR(sur_list)
File "C:\Users\Anand Govindarajan\Anaconda3\lib\site-packages\statsmodels\sandbox\sysreg.py", line 129, in __init__
self._cols[i]:self._cols[i+1]] = sys[1::2][i]
File "C:\Users\Anand Govindarajan\Anaconda3\lib\site-packages\scipy\sparse\lil.py", line 363, in __setitem__
i, j = self._index_to_arrays(i, j)
File "C:\Users\Anand Govindarajan\Anaconda3\lib\site-packages\scipy\sparse\sputils.py", line 356, in _index_to_arrays
i = self._slicetoarange(i, self.shape[0])[:, None]
File "C:\Users\Anand Govindarajan\Anaconda3\lib\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
Any help will be appreciated. There is not much documentation on SUR estimation in Python. Please let me know if you need more information. Thanks