The Handy Calculators logoTheHandyCalculators.com

    Linear Regression Calculator

    Least-squares slope, intercept, R², and predictions for any paired (x, y) data.

    Autosave on
    Slope (b)
    0.9758
    Intercept (a)
    1.1333
    92.96%
    Residual std error (s)
    0.8625
    SE(slope)
    0.09496
    t (slope = 0)
    10.2754
    p-value
    0.00001
    95% CI on slope
    (0.7568, 1.1947)
    Prediction at x = 11
    11.8667

    ŷ = 1.1333 + 0.9758 · x (n = 10)

    Scatter with OLS line

    Ordinary least-squares regression finds the line ŷ = a + b·x that minimises the sum of squared vertical residuals. This calculator returns the slope, intercept, R², residual standard error, a t-test on the slope, a 95% CI on the slope, and a prediction for any new x.

    What the regression line is

    Choose a and b to minimise Σ(yᵢ − a − bxᵢ)². Closed-form solutions: b = Σ(xᵢ − x̄)(yᵢ − ȳ) / Σ(xᵢ − x̄)², a = ȳ − b·x̄.

    Interpretation: a 1-unit increase in x is associated with a b-unit change in the average of y. The intercept a is the predicted y when x = 0 — meaningful only if x = 0 is inside or near your data.

    R² = 1 − SS_res / SS_tot is the proportion of y's variance explained by x. Equals r² for simple regression.

    What the standard error and t-test tell you

    Residual standard error s = √(SS_res / (n − 2)). The typical vertical distance from the line — y is predicted with roughly ±2s accuracy for new observations.

    SE of the slope: s / √Σ(xᵢ − x̄)². Determines how precisely we know b.

    t = b / SE(b), df = n − 2. Tests H₀: true slope = 0 (i.e. x has no linear effect on y).

    95% CI on slope: b ± t* · SE(b). If this interval excludes 0, the slope is significant at α = 0.05.

    Assumptions (LINE mnemonic)

    Linearity — the true relationship between mean y and x is a straight line.

    Independence — residuals don't form patterns over time or grouping.

    Normality — residuals are approximately normal (matters for small-sample p-values; the CLT helps for large n).

    Equal variance (homoscedasticity) — residual spread is roughly constant across x.

    Diagnostic: residual-vs-fitted and QQ plots reveal violations far better than R² alone.

    Worked example

    Same data as the correlation calculator: x = 1..10, y = (2,4,5,4,5,7,8,8,10,12).

    b = 73.5 / 82.5 ≈ 0.891. a = 6.5 − 0.891·5.5 ≈ 1.6.

    Residuals: yᵢ − (1.6 + 0.891·xᵢ). SS_res ≈ 9.45. s ≈ √(9.45/8) ≈ 1.087.

    SE(slope) ≈ 1.087/√82.5 ≈ 0.120. t = 0.891/0.120 ≈ 7.44, df = 8, p < 0.001. Slope is highly significant.

    Prediction at x = 11: ŷ = 1.6 + 0.891·11 ≈ 11.4 (with a wider prediction interval than confidence interval because individual variability adds on top).

    Common pitfalls

    Extrapolation: predicting at x far outside the observed range, where the assumed linear shape may break.

    Influential points: a single high-leverage outlier can pull the slope dramatically. Inspect leverage and Cook's distance, not just R².

    Omitted variable bias: a strong relationship between x and y might really be driven by a third variable z. Simple regression can't detect this.

    Reporting R² without checking residual patterns. A curved relationship can give R² = 0.95 and yet the line is the wrong model.

    Confusing prediction interval (for one new y) with confidence interval (for the mean y at that x). Prediction intervals are always wider.

    Frequently asked questions

    How does this differ from the correlation calculator?

    Same math underneath, but regression gives slope, intercept, residual SE, slope SE, and predictions — useful when y depends on x asymmetrically.

    What if my relationship is curved?

    Try log/sqrt transformations, polynomial terms, or a non-linear model. Don't force a line on visibly curved data.

    Can I do multiple regression here?

    This page handles simple (one x) regression. Multiple regression needs a dedicated multivariate tool — coming later in this suite.

    Is R² the same as r²?

    For simple linear regression with an intercept, yes. Multiple regression R² generalises differently.

    By Larius software engineer, NC real estate broker & CRE/business appraiserReviewed by the Handy Calculators editorial teamHow we build calculators

    More in Statistics & Probability

    From z-scores and confidence intervals to t-tests, chi-square, correlation, regression, and the binomial/Poisson distributions — textbook-grade tools with worked examples.

    See hub →
    Browse all Education →