BUG..?: linear_regression_raw doesn't warn for rank deficiency
Passing predictors that will lead to a rank deficient matrix to linear_regression_raw should throw an error or at least a big fat warning. Currently, it silently computes a stupid solution. This is in my experience a very common scenario.
An extremely easy way may be checking the rank of the resulting predictor matrix.
(It would also be nice to estimate the degree of multicollinearity in the model.)
how would you do this?
I'm not sure - the problem is, how to do it on the cheap? np.matrix_rank uses an SVD which I assume takes about as long as the actual regression.
Another option I could explore might be doing it with the much smaller input matrices, but that would only approximate it.
you can solve the system with an SVD so you know before solving the system if you have a conditioning pb.
I'll start trying things out once I've brought a few of my other PRs home ... I'd also extend the docstring a bit.
As discussed with @Eric89GXL , I will catch the linalg error the Cholesky solver gives for a perfectly collinear pair of predictors and replace it with a more helpful warning telling people to fix their model.
@jona-sassenhagen did you fix this in some recent PR?
Nope. We discussed it at the sprint a bit, but for now I'd wait for https://github.com/mne-tools/mne-python/pull/3563
Hi! I’m Aditya, a student preparing for GSoC 2025 and exploring open-source contributions. This issue looks interesting, and I’d love to work on it as my first contribution. Could you please assign it to me or let me know if it’s available? Thanks!
It's still available!