2
$\begingroup$

How to compute the overall standard error of a linear regression model using Python? Which library should I use? I am looking for something like this, however, I can't see how to get the overall standard error. Any ideas?

$\endgroup$
7
  • $\begingroup$ docs.scipy.org/doc/scipy-0.14.0/reference/generated/… $\endgroup$
    – John
    Commented Aug 13, 2014 at 14:03
  • $\begingroup$ Have tried this already but doesn't support multivariate... correct? $\endgroup$ Commented Aug 13, 2014 at 14:06
  • $\begingroup$ Ah, I see. How about datarobot.com/blog/multiple-regression-using-statsmodels $\endgroup$
    – John
    Commented Aug 13, 2014 at 14:35
  • $\begingroup$ Seems on the right path, however, I am not sure how to get the overall standard error... I can see on the std error of the individual variables. Any ideas? $\endgroup$ Commented Aug 13, 2014 at 14:39
  • $\begingroup$ Take the square root of result.mse_resid. $\endgroup$
    – Steve S
    Commented Aug 13, 2014 at 15:07

1 Answer 1

1
$\begingroup$

Let's say you have linear model Y = XB + e, for Y: n*q, X: n*p, B: p*q. Then:

def standard_error(X,Y):
    beta = inv(X.T.dot(X)).dot(X.T).dot(Y)
    return mean((Y-X.dot(beta))**2)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.