By Thomas Bourdin Updated Aug 30, 2022
Tevarak/iStock/GettyImages
Linear regression is a cornerstone of statistical analysis, allowing us to estimate the relationship between a predictor variable x and a response variable y using the equation y = mx + b. While the fitted line often captures the underlying trend, it rarely passes through every data point perfectly. The resulting discrepancies—called residuals—introduce uncertainty into our parameter estimates, especially the slope m. The standard error of the slope quantifies this uncertainty, enabling confidence intervals and hypothesis tests.
SSR is the sum of the squared differences between observed y values and the values predicted by the fitted line. For instance, if the observed values are 2.7, 5.9, and 9.4 and the model predicts 3, 6, and 9, the squared residuals are 0.09, 0.01, and 0.16, respectively. Adding them yields an SSR of 0.26.
Divide the SSR by the degrees of freedom, which is the number of observations minus two (for the slope and intercept). In the example, with three observations, the divisor is 1, giving a variance estimate of 0.26. Call this value A.
The square root of A (√0.26) equals 0.51. This value represents the standard deviation of the residuals and will be used in the final calculation.
xESS measures the variability of the predictor variable around its mean. For x values of 1, 2, and 3, the mean is 2. Subtracting the mean and squaring each difference gives 1, 0, and 1, which sum to 2. Thus, ESS = 2.
The square root of ESS (√2) is 1.41. Denote this as B.
Divide the square root of the variance estimate (step 3) by the square root of ESS (step 5): 0.51 ÷ 1.41 = 0.36. This value—0.36—is the standard error of the slope.
For large data sets, automate the calculation to avoid manual errors and save time.