Skip to content
CoursesLog in
← Statistics glossary

coefficient of determination (R²)

The share of the outcome's variance explained by the model, from 0 to 1.

R², the coefficient of determination, is the share of the variation in an outcome that a model explains, compared with the laziest possible model: always predicting the average.

R2=1−SSresSStot=1−∑(yi−y^i)2∑(yi−yˉ)2R^2 = 1 - \frac{SS_{\text{res}}}{SS_{\text{tot}}} = 1 - \frac{\sum (y_i - \hat y_i)^2}{\sum (y_i - \bar y)^2}

SStotSS_{\text{tot}} measures how much the outcome varies around its mean; SSresSS_{\text{res}} is what's left over in the residuals after the model's predictions. R² = 0 means the model does no better than the mean; R² = 1 means it fits every point exactly. In simple linear regression, R² is the square of Pearson's correlation rr.

What R² tells you: how tightly the data cluster around the fitted line or surface, in this dataset. What it doesn't: whether the model is correct, causal, or any good at forecasting. A high R² is not the same thing as a good model:

  • two metrics that both grow over time (ad spend and orders during a growth year) can give a high R² with no causal link;
  • adding predictors never lowers R² on the data the model was fitted on, even if they're pure noise, so a stuffed multiple regression looks great and forecasts badly. Use adjusted R² and a holdout sample;
  • a line can have a high R² and still be the wrong shape, which you only spot in a residual plot.

A low R² isn't automatically bad either. Individual customer behaviour is noisy, so a model of single orders might have R² = 0.15 and still reveal a reliable, valuable effect. For decisions, look at residual plots, out-of-sample error and the confidence intervals of the coefficients, not R² alone.

Example

Ten weeks of CatChow data: weekly ad spend from $200 to $700 and orders from ads between 20 and 48 (mean 34.2).

  1. Total variation: SStot=∑(yi−34.2)2=749.6SS_{\text{tot}} = \sum (y_i - 34.2)^2 = 749.6.
  2. The least-squares line is orders^≈8.85+0.0539×spend\widehat{\text{orders}} \approx 8.85 + 0.0539 \times \text{spend}. Its residuals add up to SSres≈77.5SS_{\text{res}} \approx 77.5.
  3. R2=1−77.5749.6≈1−0.103=0.897≈0.90R^2 = 1 - \frac{77.5}{749.6} \approx 1 - 0.103 = 0.897 \approx 0.90.

What this supports: the line accounts for about 90% of the week-to-week swings in orders, and each extra $100 of spend goes with about 5.4 more orders.

What it doesn't support:

  • "A $900 week will bring 57 orders" (8.85+0.0539×900≈57.48.85 + 0.0539 \times 900 \approx 57.4). $900 lies outside the $200–$700 range the line was fitted on, and a high R² inside the range says nothing about the shape beyond it.
  • "Ads cause 90% of our orders." R² describes how well the line fits, not how many orders ads cause. If CatChow tended to spend more during holiday weeks, the season could be doing part of the work.

Common mistakes

  • "High R² = good model." A high R² can come from a shared trend, from overfitting or from a fit that's only good inside the data range. Check residuals and out-of-sample error.
  • Stuffing the model to push R² up. Every extra predictor raises R² on the training data. Compare models by adjusted R² or by error on a holdout sample.
  • Comparing R² across different outcomes or datasets. An R² of 0.6 for daily orders and 0.3 for individual basket size aren't comparable; the outcomes have different amounts of natural noise.
  • Throwing out a model because R² is low. For noisy individual-level behaviour, a modest R² can sit alongside a precise, valuable coefficient.
  • Reading R² as causation or as "share of results caused by X". It measures fit, not cause.

Learn it in the course

  • Linear regression · Predicting one metric from another with a straight line, and checking the fit.