Canadian flagMath101 · Independent Ontario learning libraryCreated and edited by Kamran
Probability and StatisticsGrades 9–123 min read

Linear Regression

Linear regression fits a least-squares line to paired quantitative data and uses residuals to assess predictions.

Cheat sheet
A regression line summarizes an average linear pattern; residuals show what the line misses.

Model form

A fitted linear model is written

$$ \hat y=a+bx, $$

where $\hat y$ is the predicted response, $b$ is slope, and $a$ is intercept. The hat distinguishes a prediction from an observed value $y$.

The explanatory variable is $x$ and the response variable is $y$.

Least-squares criterion

For each observation, the residual is

$$ e=y-\hat y. $$

Least-squares regression chooses $a$ and $b$ to minimize

$$ \sum e_i^2. $$

Squaring prevents positive and negative residuals from cancelling and penalizes large errors.

Interpreting slope

The slope describes predicted response change for one additional unit of the explanatory variable.

Always include both variable units.

Interpreting the intercept

The intercept predicts $y$ when $x=0$. It is meaningful only if zero is realistic and reasonably near the observed range.

An intercept can be mathematically necessary for the line while lacking a sensible contextual interpretation.

Worked residual

Using $\hat y=4.2x+58$, a student with $x=5$ study hours has predicted score

$$ \hat y=4.2(5)+58=79. $$

If the observed score is $82$, then

$$ e=82-79=3. $$

A positive residual means the observation lies above the fitted line.

Residual plots

Plot residuals against fitted values or $x$. A good linear model has residuals scattered around zero without a clear curve, funnel shape, or time pattern.

Curvature suggests nonlinearity; changing spread suggests nonconstant variability; isolated large residuals suggest outliers.

Coefficient of determination

$R^2$ is the proportion of response variation explained by the fitted model in the dataset. In simple linear regression with an intercept,

$$ R^2=r^2. $$

An $R^2$ of $0.64$ means $64\%$ of observed response variation is accounted for by the linear model—not that predictions are $64\%$ accurate or that causation is $64\%$ proven.

Interpolation and extrapolation

Interpolation predicts within the observed explanatory range. Extrapolation predicts beyond it and is riskier because the relationship may change.

Even interpolation inherits uncertainty and any bias in the data.

Influential observations

Points with unusual $x$-values can strongly affect slope and intercept. Examine leverage, residual size, and data quality. Report analyses with and without a point only when justified.

Do not remove valid data because they weaken a desired model.

Association versus causation

Regression estimates a conditional association. Causal interpretation requires appropriate design and assumptions, often including random assignment, controlled conditions, and attention to confounding.

A precise fitted line cannot repair biased sampling or poor measurement.

Making a prediction

Substitute an allowed $x$ into the model, report $\hat y$ with units and sensible precision, and state whether the prediction is within the data range.

When available, prediction intervals communicate uncertainty more honestly than a single point estimate.

Common mistakes

Interpreting slope without units or context. Name both variables.

Forcing meaning onto an unrealistic intercept. Check whether $x=0$ makes sense.

Calculating residual as predicted minus observed. Use observed minus predicted.

Calling $R^2$ prediction accuracy or causal strength. It summarizes variation explained in the sample.

Extrapolating far beyond the data without warning. Model form may not persist.

Quick self-check

  • Are explanatory and response variables identified correctly?
  • Does the scatter plot support a linear model?
  • Is slope interpreted as predicted change with units?
  • Are residuals patternless around zero?
  • Is $R^2$ described accurately?
  • Are outliers, extrapolation, uncertainty, bias, and causal limits addressed?
Check your understanding

Try it yourself

Hints are part of learning. Open one whenever it makes the next step feel possible.

1 practice question
Question 1Calculate and interpret a residual · Gentle

For ŷ = 4.2x + 58, x = 5 gives an observed y = 82. Find the residual y − ŷ.

End of lesson

Nice work making it this far.

Understanding grows through return visits. Save this lesson, try the practice, or continue when you are ready.

Lesson complete

That one is yours now.

Linear Regression is saved to My Learning. Take the win—you earned it.

1Your Math101 collectionlesson completed
Search 464 published lessons, 123 answer guides, courses, and learning tools.
Your experience

Settings

Ontario math tutoringWork with KamranBook ↗