Statistics for Finance
R-squared and residuals
A fitted line never passes through every dot. R-squared says how much of the movement the line explains. The residuals, what's left over, tell you whether a straight line was the right choice at all.
How much of a stock's movement is just the market?
Example, with made-up numbers. In the last lesson, the stock's line was stock = −0.4 + 1.4 × market. The market clearly matters. But in some months the stock did its own thing. How much of its ups and downs does the market explain, and how much is the company itself?
The idea
Measure how much the stock moves in total: the sum of its squared gaps from its average. Part of that the line explains. The rest is in the residuals, each month's actual return minus the line's prediction. R-squared, written R², is the share the line explains:
Top: what the line missed each month. Bottom: the stock's total movement, split into what the line explains and what's left.
R² runs from 0 (the line explains nothing) to 1 (every dot sits on the line). With a single x, it's simply the correlation squared.
Quick check
Regressing a stock on the market gives R² = 0.30. What does that say?
Worked example: same five months
Example, with made-up numbers. Market: 2, −1, 3, 0, 1. Stock: 3, −2, 4, 1, −1. Line: stock = −0.4 + 1.4 × market.
| 1. The line's prediction each month | 2.4, −1.8, 3.8, −0.4, 1.0 |
| 2. Residuals: actual − predicted | 0.6, −0.2, 0.2, 1.4, −2.0 |
| 3. Sum of squared residuals | 0.36 + 0.04 + 0.04 + 1.96 + 4 = 6.4 |
| 4. Total sum of squared gaps (from the correlation lesson) | 26 |
| 5. R² | 1 − 6.4 ÷ 26 = 0.754 |
Check: the correlation was 0.87, and 0.87² ≈ 0.75. The residuals add up to zero, as they always do for a least-squares line. In Excel: =RSQ(stock range, market range).
Why finance cares
For a stock regressed on the market, R² splits its risk in two. The explained part is market risk: you can't diversify it away. The residual part is company-specific risk, which shrinks as you hold more stocks. Here that's 75% market and 25% company. For funds, R² against a benchmark shows how closely the fund follows it. A fund with R² near 1 and high fees is charging active fees for something close to an index fund.
Reading the residuals
Good residuals look like random noise around zero. Three patterns mean the line is the wrong tool:
| A curve (U or arch shape) | The relationship isn't straight |
| A fan that widens | The spread grows with x, so predictions are less reliable at the high end |
| One huge residual | An outlier may be pulling the whole line |
Try it yourself
Paste two lists, see R² and plot the residuals.
| Fitted line | |
| R² | |
| Residuals |
Common mistakes
Three slips beginners make.
- Using prices instead of returns. Two prices that both drift upward over time can show a high R² with no real link. Regress returns.
- Reading a high R² as proof. It says the line fits, not that x causes y, and not that it will keep fitting.
- Dismissing a low R². A stock's beta can be useful even when the market explains only 30% of its moves.
Remember
- Residual = actual − predicted. A good line leaves residuals with no pattern.
- R² = 1 − squared residuals ÷ total squared gaps: the share of movement the line explains. With one x, it's the correlation squared.
- For a stock against the market, R² is the share of market risk. The rest is company-specific.
Check yourself
Three questions. Try them without scrolling up.
1. A simple regression has R² = 0.81. What could the correlation be?
2. The sum of squared residuals is 30 and the total sum of squared gaps is 120. What's R²?
3. The residuals form a clear U-shape against x. What does that suggest?
Section practice · optional
Relationships
9 mixed problems from lessons 16 to 18 · about 12 minutes
The problems aren't labeled with a lesson, so part of the work is choosing the right tool. Work each one on paper, then open the answer.
x: 1, 2, 3, 4. y: 2, 3, 5, 6. What's the correlation?
Show answer
CorrelationMeans 2.5 and 4. Gaps: x −1.5, −0.5, 0.5, 1.5; y −2, −1, 1, 2. Products add to 7. Squared gaps: 5 and 10. 7 ÷ √50 = 0.99.Two funds, each with a 10% standard deviation and a correlation of +0.5. What's the risk of a 50/50 split?
Show answer
Correlation10% × √((1 + 0.5) ÷ 2) = 10% × √0.75 = 8.7%. Less than either fund alone.Across cities, the number of police officers is strongly correlated with the number of crimes. Do police cause crime?
Show answer
CorrelationNo evidence of that. Bigger cities have more of both. Population drives the two together.Using the data in problem 1, find the fitted line and predict y when x = 5.
Show answer
Linear regressionSlope 7 ÷ 5 = 1.4. Intercept 4 − 1.4 × 2.5 = 0.5. y = 0.5 + 1.4x, so at x = 5, 7.5. Careful: 5 is just outside the data.A stock's correlation with the market is 0.8. Its standard deviation is 25%, the market's 20%. What's its beta?
Show answer
Linear regression0.8 × (25 ÷ 20) = 1.0. It moves one-for-one with the market on average, though it swings more overall.You hold $50,000 of a stock with beta 0.8. How much of the market index would you sell to hedge its market risk?
Show answer
Linear regression0.8 × $50,000 = $40,000.What's R² for the data in problem 1?
Show answer
R-squared and residualsThe correlation squared: 0.99² = 49 ÷ 50 = 0.98. The line explains 98% of y's movement.A stock has beta 1.2 and R² 0.36 against the market. The market falls 5%. What's the expected move, and how much of the stock's risk is market risk?
Show answer
Linear regression · R-squared1.2 × −5% = −6%. Market risk is 36%. The other 64% is company-specific, which diversification can reduce.Residuals from a regression of spending on income get wider and wider as income rises. What's going on?
Show answer
R-squared and residualsA fan shape: high earners vary more in what they spend. The line's predictions are less reliable at high incomes.
Samples and standard error
Why an average from data is only an estimate, and how far off it might be.