[SciPy-user] Standard error on linear regression coefficients
Thu May 15 12:25:48 CDT 2008
On Thu, May 15, 2008 at 9:52 AM, Lorenzo Isella
> Dear All,
> I happen to use a lot the module for linear regression included in scipy.
> I need to get the standard errors on the slope and the intercept and
> by looking at the help:
> Help on function linregress in module scipy.stats.stats:
> Calculates a regression line on two arrays, x and y, corresponding to
> x,y pairs. If a single 2D array is passed, linregress finds dim with 2
> levels and splits data into x,y pairs along that dim.
> Returns: slope, intercept, r, two-tailed prob, stderr-of-the-estimate
> I am a bit puzzled. I have only one entry for the standard error of
> the estimate. Should I not have two, namely one standard error for the
> slope and one for the intercept?
> I presume the one provided here is the one for the slope, but I fear I
> have misunderstood something.
Yes. The "Standard Error of the Estimate" is the root-mean-square of
the residuals. C.f.
> Or to re-phrase my question: how do I get the errors on the estimated
> slope and intercept with SciPy linregress?
According to WikiPedia: http://en.wikipedia.org/wiki/Regression_analysis
slope, intercept, r, prob2, see = linregress(x, y)
mx = x.mean()
sx2 = ((x-mx)**2).sum()
sd_intercept = see * sqrt(1./len(x) + mx*mx/sx2)
sd_slope = see * sqrt(1./sx2)
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
More information about the SciPy-user