Back

Regression

12 minmedium Load
Requires an internet connection to play

Fitting a line to data

Khan Academy

Open

Regression analysis examines the relationship between two or more variables. The first step is creating a scatter plot, where each point represents one data pair (x, y). The pattern of points reveals whether a relationship exists and what form it takes — linear, exponential, or something else.

Correlation measures the strength and direction of a linear relationship between two variables. The correlation coefficient, r, ranges from -1 to +1. An r-value near +1 indicates a strong positive linear relationship (as x increases, y increases). An r-value near -1 indicates a strong negative relationship (as x increases, y decreases). An r-value near 0 suggests no linear relationship. Crucially, correlation does not imply causation — two variables can be correlated because of a third lurking variable, pure coincidence, or a reversed causal direction.

The line of best fit (least squares regression line) minimizes the sum of squared vertical distances from each data point to the line. Its equation is ŷ = a + bx, where b is the slope (the predicted change in y for each unit increase in x) and a is the y-intercept. The coefficient of determination, r², tells you what proportion of the variation in y is explained by the regression on x. If r = 0.9, then r² = 0.81, meaning 81% of the variability in y is explained by the linear model.

Regression lines are used for prediction, but predictions should only be made within the range of the original data (interpolation). Extrapolating far beyond the observed data is unreliable because the linear trend may not continue. Always check for outliers, which can dramatically shift the regression line, and verify that a linear model is actually appropriate for the data pattern.