asanyarray coercion in Model class breaks sparse matrices

Bug #521229 reported by Skipper Seabold
6
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).

Revision history for this message
joep (josef-pktd) wrote :

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.

Revision history for this message
Skipper Seabold (jsseabold) wrote :

I meant asarray. Oops. It's a moot point I think anyway. I could have sworn I took a pseudoinverse of a sparse matrix last night and had the betas for VAR, but I can't repllicate. I am looking into rewriting it all in "companion matrix" form to see if this will be more efficient.

Changed in statsmodels:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.