Panel SUR - error

25 kali dilihat
Langsung ke pesan pertama yang belum dibaca

Andres R

belum dibaca,
28 Mar 2017, 11.54.3128/03/17
kepadapystatsmodels
Hi,

I am trying to run the below code in Python 3.6.0 and Python 2.7.13 and I obtain the following error:

/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)

josef...@gmail.com

belum dibaca,
28 Mar 2017, 12.01.4228/03/17
kepadapystatsmodels
Is this with statsmodels 0.8, 0.6.1 or a branch?


All changes in numpy including deprecation warnings should have been properly taken account of in 0.8. 
However, we might have missed some changes. One issue in a plot function was reported yesterday

Josef 

Andres R

belum dibaca,
29 Mar 2017, 02.48.1229/03/17
kepadapystat...@googlegroups.com
Thanks for your answer: 

I am running the following Python version:

Python 3.6.0 (v3.6.0:41df79263a11, Dec 22 2016, 17:23:13) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

statsmodel package:

>>> import statsmodels
>>> print(statsmodels.__version__)
0.8.0

numpy package:

>>> print(numpy.__version__)
1.12.1

scipy package:

>>> import scipy
>>> print(scipy.__version__)
0.19.0

pandas package:

>>> import pandas
>>> print(pandas.__version__)
0.19.2

patsy package:

>>> import patsy
>>> print(patsy.__version__)
0.4.1

python package:

Cython version 0.25.2

I ran update commands for all dependencies - everything seems up to date.

Andres R

belum dibaca,
29 Mar 2017, 03.41.0829/03/17
kepadapystat...@googlegroups.com
Balas ke semua
Balas ke penulis
Teruskan
0 pesan baru