Quant Memo
Core

R-squared and Goodness of Fit

What R-squared really measures, the share of the wiggle in your outcome that a model explains, how to compute it from residuals, why it always creeps up when you add predictors, and why a low R-squared is normal and often fine in finance.

Prerequisites: Ordinary Least Squares (OLS)

R-squared answers one question: of all the up-and-down variation in the thing you're trying to predict, how much does your model actually account for? If your outcome bounces around a lot and your fitted line follows most of that bouncing, R-squared is high. If your line is nearly flat while the data scatter wildly around it, R-squared is low. It's the most quoted number in regression, and also the most misread.

Start with two piles of "leftover wiggle." First, how far each point sits from the flat line at the average yˉ\bar y, this is the total variation you could explain. Second, how far each point sits from your fitted line, the part you failed to explain. R-squared is one minus the ratio of the second to the first:

R2=1SSresSStot,SSres=i(yiy^i)2,SStot=i(yiyˉ)2.R^2 = 1 - \frac{\text{SS}_{\text{res}}}{\text{SS}_{\text{tot}}}, \qquad \text{SS}_{\text{res}} = \sum_i (y_i - \hat y_i)^2, \quad \text{SS}_{\text{tot}} = \sum_i (y_i - \bar y)^2 .

Here yiy_i is the actual value, y^i\hat y_i is the model's prediction, and yˉ\bar y is the plain average of the yy's. If the model's misses (SSres\text{SS}_{\text{res}}) are tiny compared to the raw spread (SStot\text{SS}_{\text{tot}}), the ratio is near 0 and R2R^2 is near 1. If the model does no better than guessing the average, SSres=SStot\text{SS}_{\text{res}} = \text{SS}_{\text{tot}} and R2=0R^2 = 0. Those leftover misses are the residuals, the vertical gaps below.

residual x y
The green line is the fitted model. Each amber segment is a residual, the vertical gap between a real point and the line's prediction. $R^2$ compares the total size of those gaps to how far the points spread from their own average.

A useful shortcut: it's just correlation, squared

In simple regression with one predictor, R-squared is literally the correlation coefficient squared, hence the name. A Correlation of 0.90.9 means R2=0.81R^2 = 0.81; a correlation of 0.30.3 (respectable in finance) means R2=0.09R^2 = 0.09, the model explains only 9% of the variation. That single fact deflates a lot of hype: a "strong-looking" correlation of 0.50.5 still leaves three quarters of the movement unexplained.

Read R2R^2 as the share of the outcome's variation your model explains: R2=1SSres/SStotR^2 = 1 - \text{SS}_{\text{res}}/\text{SS}_{\text{tot}}. In simple regression it is just the correlation squared, so a respectable-looking ρ=0.3\rho = 0.3 explains a mere 9% of the movement.

Drag ρ\rho below and read the two numbers together. Notice how much faster r2r^2 falls than ρ\rho: at ρ=0.5\rho = 0.5 the cloud still looks tilted, yet r2r^2 is only 0.250.25 — the line explains just a quarter of the scatter.

Correlation explorer
X →Y ↑
ρ = 0.70r² = 0.49relationship: strong positive

Worked example: computing it by hand

Fit a line to five points: x=(1,2,3,4,5)x = (1,2,3,4,5), y=(1,3,2,3,5)y = (1,3,2,3,5). Ordinary least squares (see Ordinary Least Squares (OLS)) gives the line y^=0.4+0.8x\hat y = 0.4 + 0.8x. The predictions are (1.2, 2.0, 2.8, 3.6, 4.4)(1.2,\ 2.0,\ 2.8,\ 3.6,\ 4.4), so the residuals are (0.2, 1.0, 0.8, 0.6, 0.6)(-0.2,\ 1.0,\ -0.8,\ -0.6,\ 0.6) and

SSres=0.04+1.00+0.64+0.36+0.36=2.40.\text{SS}_{\text{res}} = 0.04 + 1.00 + 0.64 + 0.36 + 0.36 = 2.40 .

The mean of yy is yˉ=2.8\bar y = 2.8, so the total variation is

SStot=(12.8)2+(32.8)2+(22.8)2+(32.8)2+(52.8)2=8.80.\text{SS}_{\text{tot}} = (1-2.8)^2 + (3-2.8)^2 + (2-2.8)^2 + (3-2.8)^2 + (5-2.8)^2 = 8.80 .

Therefore

R2=12.408.80=0.727.R^2 = 1 - \frac{2.40}{8.80} = 0.727 .

The line explains about 73% of the spread in yy. (And indeed 0.7270.85\sqrt{0.727} \approx 0.85, the correlation between xx and yy.)

Common pitfalls

  • It never goes down when you add predictors. Throw in a useless variable and R2R^2 stays flat or nudges up, purely from fitting noise. That's why people report adjusted R2R^2, which docks you for every extra parameter you spend. See Degrees of Freedom for the bookkeeping, and Overfitting for the danger.
  • High R2R^2 does not mean a good, or causal, model. Two trending series (both drifting up over time) can post an R2R^2 near 1 while being completely unrelated, a spurious regression. A high fit can also come from look-ahead leakage.
  • Low R2R^2 is normal in finance and not a failure. Predicting daily returns, an R2R^2 of 0.010.01 can be a genuine, tradable edge. Judge return models by out-of-sample profit and risk, not by R2R^2.
  • It says nothing about bias or the size of errors. A model can have a decent R2R^2 yet be systematically off in the tails. Always eyeball the residual plot, not just the single number.

R2R^2 never falls when you add predictors — it creeps up even on pure noise, which is why you report adjusted R2R^2. And a low R2R^2 is normal in finance: an R2R^2 of 0.010.01 on daily returns can be a genuinely tradable edge.

The habit to build: read R2R^2 as "share of variation explained," sanity-check it against the correlation, and never let a big number lull you into skipping the residual plot or the out-of-sample test.

Related concepts

Practice in interviews

Further reading

  • Greene, Econometric Analysis (Ch. 3)
  • Wooldridge, Introductory Econometrics (Ch. 2–3)
ShareTwitterLinkedIn