You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Singular design matrix produce very extreme p-values #8670
I found when the design matrix is singular, statsmodels can give me very extreme and wrong p values. In this case, I have x2 + x3 = 1, and statsmodels produced wrong results.
In R, when x2 + x3 = 1, it will drop x3, fit the model with x2 only, and give NA to x3. I would imagine R implementation is less misleading for most of the users.
Is there a way that I can get similar singularity handling as R using statsmodels?
Also, when x1 = x2, statsmodels calculated the right p values for both x1 and x2, but it splits the effect size and standard errors by half. This is, of course, not a bug, but I prefer the R implementation.
It's a design decision that we use pinv in linear regression.
This is a regularized solution if relative condition number is larger than around 5e15 (default by np.linalg.pinv)
Currently, statsmodels does NOT have an option to drop semi-arbitrary columns from exog. #6935 is a PR that would add pivoting QR #3824 has a long discussion on our default
several issues to figure out how to handle this with more options, for example #2062
Activity
JasonTan-code commentedon Feb 13, 2023
Also, when x1 = x2, statsmodels calculated the right p values for both x1 and x2, but it splits the effect size and standard errors by half. This is, of course, not a bug, but I prefer the R implementation.
josef-pkt commentedon Feb 14, 2023
It's a design decision that we use
pinvin linear regression.This is a regularized solution if relative condition number is larger than around 5e15 (default by np.linalg.pinv)
Currently, statsmodels does NOT have an option to drop semi-arbitrary columns from exog.
#6935 is a PR that would add pivoting QR
#3824 has a long discussion on our default
several issues to figure out how to handle this with more options, for example #2062