Linear Regression Guide

What's the key thing to understand about Least-Squares Regression?

The least-squares regression line minimises the sum of squared vertical distances from each data point to the line (residuals). Gradient m = Σ(xᵢ−x̄)(yᵢ−ȳ) / Σ(xᵢ−x̄)². Y-intercept c = ȳ − m×x̄. The line always passes through the point (x̄, ȳ) — the mean of both variables. This is the LSRL or line of best fit. It minimises Σ(yᵢ − ŷᵢ)² where ŷᵢ = predicted values. There is only one least-squares line for a given dataset (unlike other fitting methods).

What should I know about R-squared Interpretation?

R² = square of the correlation coefficient r. It represents the proportion of variance in Y explained by X. R² = 0.85 means 85% of the variation in Y is explained by the linear relationship with X. The remaining 15% is due to other factors (lurking variables, random variation). R² = 1: perfect fit. R² = 0: no linear relationship. Important: a high R² does not mean causation, and does not mean the linear model is appropriate — always plot the data. R² can be high even when the relationship is clearly non-linear, which is exactly why plotting the raw data alongside any regression statistic is essential rather than trusting the number alone.

What's the difference between Interpolation and Extrapolation?

Interpolation: using the regression line to predict Y for X values within the range of the data — generally reliable. Extrapolation: predicting outside the data range — unreliable and potentially very wrong. The linear relationship that holds between x=10 and x=100 may not hold at x=500. Example: a linear model relating height and weight in children aged 5-10 is reasonable for predicting weight at age 7. Predicting weight at age 40 from the same model would be nonsense. Always state when predictions move beyond the range of the original data, since the linear relationship observed within that range is not guaranteed to hold outside it.

What's the key thing to understand about Assumptions of Linear Regression?

Linearity: the relationship between X and Y is actually linear — check with a scatterplot. Independence: each observation is independent (no repeated measurements). Homoscedasticity: variance of residuals is constant across all X values — if residuals are larger at high X, this assumption is violated. Normality of residuals: for hypothesis testing, residuals should be approximately normally distributed (less critical with large samples). Residual plot: plot residuals against fitted values. Random scatter around zero in a residual plot supports the model's validity; clear patterns instead suggest the linear model isn't the right fit for the data.

Linear Regression & Line of Best Fit Calculator

Results update automatically as you type

Enter values above to calculate