Course contentsShow
← Data Science
Lesson 516 of 2,14514. Simple Linear RegressionFree lesson

Residuals: The Distance from Prediction

Define residuals as the vertical distance between observed values and the regression line, and understand their role in fitting.

Residuals: The Distance from Prediction

You'll learn: What residuals are in linear regression and why they're essential for evaluating how well your line fits the data.

What Are Residuals?

When you draw a regression line through your data points, most observations won't fall exactly on the line. Residuals are the vertical distances between each actual observed value and the value your regression line predicts at that same x-position.

Think of it like this: if you're predicting house prices based on square footage, and your line predicts 300,000fora2,000sqfthouse,buttheactualsalepricewas300,000 for a 2,000 sq ft house, but the actual sale price was 320,000, the residual for that observation is $20,000 (the actual value minus the predicted value).

Why Vertical Distance?

Residuals measure the vertical gap because in regression, you're predicting the y-variable (the dependent variable) from the x-variable. You want to know how far off your y-predictions are, not the shortest geometric distance to the line.

The Role of Residuals in Fitting

Residuals are fundamental to finding the "best fit" line. A good regression line minimizes these distances across all data points. Large residuals mean poor predictions; small residuals mean your line captures the pattern well.

The residual for observation i can be written as:

residual = observed value - predicted value

Or in shorthand: eᵢ = yᵢ - ŷᵢ

Where yᵢ is the actual value and ŷᵢ is the predicted value from your regression line.

Key Takeaway: Residuals are the vertical distances between observed data points and the regression line's predictions—they quantify prediction errors and are the foundation for determining the best-fitting line.