A topic in the Open Knowledge Graph — a free, open map of 15,290 topics and the order to learn them in.

Residuals and Goodness of Fit (R²)

College Depth 106 in the knowledge graph ☐ I know this ☆ Set as goal
191topics build on this
552prerequisites beneath it
See this on the map →
Linear Regression BasicsLinear Regression and Least Squares Estimation+1 more→→Graphical Diagnostics: Residual Plots and QQ PlotsHeteroskedasticity+2 more
residuals R-squared goodness-of-fit residual-plots model-diagnostics

Core Idea

A residual is the difference between an observed y value and the predicted value ŷ from the regression line: eᵢ = yᵢ − ŷᵢ. Residual plots (residuals vs. fitted values or vs. predictor) reveal whether the linear model is appropriate — random scatter around zero indicates a good fit, while patterns suggest the model is misspecified. The coefficient of determination R² = r² gives the proportion of variability in y explained by the linear model, ranging from 0 (no explanatory power) to 1 (perfect linear fit).

How It's Best Learned

Generate residual plots from regression output in software and practice recognizing patterns: funnel shapes indicate non-constant variance, curved patterns indicate nonlinearity. Connect R² to correlation: if r = 0.8, then R² = 0.64 — 64% of variation in y is explained by x.

Common Misconceptions

Explainer

Once you have fit a linear regression line to data, the natural question is: how well does it fit? The residual for each observation is the answer to that question at a single point — it is the gap between what the model predicted and what actually happened: eᵢ = yᵢ − ŷᵢ. A positive residual means the true value was above the line; negative means it was below. Crucially, residuals are signed — they don't cancel each other out by accident, but they do cancel on average: in ordinary least squares regression, the residuals always sum to zero. This is not a coincidence; the regression line was chosen precisely to minimize the sum of squared residuals, and that optimization forces the sum to be zero.

The most informative diagnostic tool is the residual plot — a scatterplot of residuals on the vertical axis against fitted values (or against the predictor x) on the horizontal axis. If the linear model is appropriate, this plot should look like random scatter around the horizontal line at zero. No trend, no fan shape, no curves. Any pattern in the residual plot is evidence of a model problem. A curved pattern (like a smile or frown) indicates the relationship is not linear — you fit a line to something curved. A funnel shape (residuals spread out more as fitted values increase) indicates heteroscedasticity — the variance of the errors is not constant. Both problems violate the assumptions that make regression inference valid. Reading a residual plot is more important than memorizing any formula.

The coefficient of determination, R², answers the question: what fraction of the total variation in y does the model account for? To build the intuition, think about two extremes. If you ignored x entirely and just predicted ȳ for every observation, your total prediction error would be the total variability in y — called the total sum of squares (SST). Now imagine the regression model reduces that error by explaining some of the variation. The residual sum of squares (SSR) is the variation the model could not explain. R² = 1 − SSR/SST: the proportion of variability the model did explain. An R² of 0.64 means 64% of the variation in y is accounted for by the linear relationship with x; the other 36% is noise the model cannot see.

For simple linear regression with one predictor, R² equals r² — the square of the correlation coefficient you already know. This means R² inherits a clean geometric meaning: if r = 0.8, there is a strong linear relationship, and R² = 0.64. If r = 0.5, the relationship is moderate, and only R² = 0.25 of the variation is explained. The squaring is important — it strips the sign from r (direction doesn't matter for explanatory power) and always gives a value between 0 and 1. However, a high R² is not sufficient evidence that a model is good. A curved relationship can still have high R² while being fundamentally misspecified. Always pair R² with a residual plot inspection: R² measures how much variation is explained; the residual plot tells you whether the explanation is valid.

Practice Questions 5 questions

Prerequisite Chain

Understanding Zero → The Number Zero → Counting to Five → Counting to 10 → Counting to 20 → Counting a Set of Objects Up to 20 → Cardinality: The Last Number Counted → Matching Numerals to Quantities → Subitizing Small Quantities → Addition Within 10 → Number Bonds to 10 → Addition Within 20 → Doubles and Near Doubles → Doubles Facts Within 10 → Near Doubles Facts Within 20 → Mental Math Strategies for Addition → Mental Math: Adding and Subtracting Tens → Addition Within 100 → Repeated Addition as Multiplication → Multiplication as Equal Groups → Multiplication: Arrays → Basic Multiplication Facts (0s, 1s, 2s, 5s, 10s) → Multiplication Facts Within 100 → Division as Equal Sharing → Division as Grouping (Measurement Division) → Division: Grouping (Repeated Subtraction) Model → Division: Fair Sharing Model → Division as Equal Sharing → Division as Grouping → Basic Division Facts → Division Facts Within 100 → Multiplication and Division Fact Families → Relationship Between Multiplication and Division → Division Facts as Inverse of Multiplication → Remainders and Quotients in Division → Division Word Problems → Multi-Step Word Problems → Solving Multi-Step Word Problems → Multiplication Word Problems → Division Word Problems → Introduction to Long Division → Factors and Multiples → Prime and Composite Numbers → Equivalent Fractions → Relating Fractions and Decimals → Decimal Place Value → Integers and the Number Line → Comparing and Ordering Integers → Absolute Value → Adding Integers → Subtracting Integers → Multiplying Integers → Dividing Integers → Unit Rates → Proportions → Percent Concept → Converting Between Fractions, Decimals, and Percents → Operations with Rational Numbers → Two-Step Equations → Solving Multi-Step Equations → Equations with Variables on Both Sides → Angle Pairs: Complementary, Supplementary, and Vertical → Parallel Lines and Transversals → Corresponding Angles → Alternate Interior Angles → Triangle Angle Sum Theorem → Exterior Angle Theorem → Triangle Inequality Theorem → Similar Triangles: AA Similarity → Similar Triangles: SSS and SAS Similarity → Proportions in Similar Triangles → Right Triangle Trigonometry Introduction → Sine, Cosine, and Tangent Ratios → Trigonometric Ratios Review → Radian Measure → Converting Between Degrees and Radians → The Unit Circle → Graphing Sine and Cosine → Graphing Tangent and Reciprocal Trigonometric Functions → Derivatives of Trigonometric Functions → Antiderivatives → Indefinite Integrals → Basic Integration Rules → Riemann Sums → Definite Integral Definition → Probability Density Functions and Continuous Distributions → Cumulative Distribution Functions → Continuous Random Variables → Probability Density Functions → Expected Value → Weak Law of Large Numbers → Probability Axioms and Rules → Conditional Probability → Independence of Events → Sampling Distributions → Standard Error of Estimators → Hypothesis Testing: Framework and Logic → P-values and Statistical Significance → Effect Size and Practical Significance → Hypothesis Testing: Framework and Logic → Z-Tests and T-Tests for Means → One-Sample Z-Test for Means → One-Sample and Two-Sample T-Tests → Inference in Linear Regression → Prediction Intervals in Regression → Linear Regression Basics → Residuals and Goodness of Fit (R²)

Longest path: 107 steps · 552 total prerequisite topics

Prerequisites (3)

Leads To (4)