Unhelpful error from bad exog matrix in model.py
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
statsmodels |
New
|
Undecided
|
Unassigned |
Bug Description
These lines in model.py could be improved:
if np.any(exog.var(0) == 0):
# assumes one constant in first or last position
example traceback
File "/home/
reference = sm.OLS(endog, sm.add_
File "/usr/lib/
super(OLS, self)._
File "/usr/lib/
super(WLS, self)._
File "/usr/lib/
super(GLS, self)._
File "/usr/lib/
super(
File "/usr/lib/
const_idx = np.where(
ValueError: can only convert an array of size 1 to a Python scalar
example exog matrix that causes blowup:
array([[ 24. , 2. , 4. , 0. , 1. ],
[ 21. , 1.7 , 2.89 , 0. , 1. ],
[ 24. , 2.8 , 7.84 , 0. , 1. ],
[ 26. , 2.4 , 5.76 , 0. , 1. ],
[ 33. , 3. , 9. , 0. , 1. ],
[ 34. , 4.8 , 23.04 , 0. , 1. ],
[ 33. , 3.18 , 10.1124, 0. , 1. ],
[ 21. , 1.5 , 2.25 , 0. , 1. ],
[ 25. , 3. , 9. , 0. , 1. ],
[ 27. , 2.28 , 5.1984, 0. , 1. ]])
I fixed this in my branch earlier this week. I think, to
const_idx = np.where( exog.var( 0) == 0)[0][0].item()
I haven't merged my branch into devel yet this week.