asanyarray coercion in Model class breaks sparse matrices
Bug #521229 reported by
Skipper Seabold
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
statsmodels |
Invalid
|
Undecided
|
Unassigned |
Bug Description
When we coerce with asanyarray in Model, it doesn't work with sparse matrices. It's a simple fix to check for sparse, but no time now. Otherwise, we can pass in block diagonal sparse matrices to GLS etc., if we want to and there's no other option for stacking (not convinced of this yet).
To post a comment you must log in.
We cannot replace asarray with asanyarray in any conversion!
statsmodels calculations are written to work with arrays, using matrices including sparse matrices would change multiplication and axis reduction (eg. in mean()). I expect that this would break things all over the place.
Enabling sparse matrix calculations would require a lot of changes to the internal code.
For the specific case of a sparse full sized covariance matrix, or it's cholesky (or other) decomposition, it might be worthwhile to specialcase this. As an alternative for GLS, we could use a callback function for whiten, that could then handle sparse calculations. But I'm not sure, and we have to check if changing only whiten is enough (I think it might work, since all GLS calculations go through whiten).
However, this would not be enough if we want to have exog sparse as for example for system of equations regression.