Regression basics: beta and R squared
Regression in finance explained: fit a stock's returns against an index by hand, read beta as the slope and R squared as the fit, and avoid overfitting.
Part of the Statistics for Investors and Traders track on Agenticks. About 12 minutes, written for a intermediate reader.
Read first: Correlation and diversification.
Last reviewed .
Key takeaways
- Simple regression fits a straight line. The slope of a stock's returns against an index's returns is the stock's beta.
- Beta = sum of (index deviation x stock deviation) / sum of squared index deviations.
- R squared is the share of the stock's variation the index explains, from 0 to 1.
- Beta describes a past relationship with the market only, and its value for predicting returns is disputed.
- A model with enough parameters can fit past data perfectly and still predict nothing.
Regression finds the straight line that best describes how one variable changes with another. In finance the classic use is to line up a stock's returns against a market index's returns and ask: when the index moves 1%, how much does the stock tend to move? The slope of that line is the stock's beta. Beta comes from the capital asset pricing model, developed in the 1960s by William Sharpe and others, which links an asset's expected return to how much it moves with the market. You do not need the model to use the measurement. A beta of 1 means the stock has tended to move one for one with the index, above 1 means bigger moves, below 1 means smaller ones, and a negative beta means it has tended to move the other way.
The line and its slope
Simple linear regression fits: stock return = alpha + beta x index return + leftover. Beta = sum of (index deviation x stock deviation) / sum of squared index deviations. Alpha is where the line crosses zero, the stock's average return in a period when the index was flat. The leftovers, called residuals, are everything the index does not explain.
Worked example: beta from five months
Illustrative monthly returns, sorted by the index. Index: -2%, -1%, 0%, +1%, +2%. Stock: 0%, -3%, +3%, +1%, +4%.
| Means (0 / 5 and 5 / 5) | index 0%, stock 1% |
|---|---|
| Index deviations | -2, -1, 0, +1, +2 |
| Stock deviations (each stock return minus 1) | -1, -4, +2, 0, +3 |
| Products (index deviation x stock deviation) | 2, 4, 0, 0, 6 |
| Sum of products | 12 |
| Sum of squared index deviations (4 + 1 + 0 + 1 + 4) | 10 |
| Beta (slope) (12 / 10) | 1.2 |
| Alpha (intercept) (stock mean - 1.2 x index mean = 1 - 0) | 1% |
| Fitted line | stock return = 1% + 1.2 x index return |
Five points are far too few for a real estimate. They keep every step checkable by hand.
Beta gives the slope. R squared says how well the line fits: the share of the stock's ups and downs that the index accounts for, from 0 (none) to 1 (all). To get it, compare how badly the line misses with how much the stock varied in total.
Worked example: R squared for the same five months
Using the fitted line stock return = 1% + 1.2 x index return.
| Line's predictions (1 + 1.2 x each index return) | -1.4, -0.2, 1.0, 2.2, 3.4 |
|---|---|
| Residuals (actual - predicted) | +1.4, -2.8, +2.0, -1.2, +0.6 |
| Sum of squared residuals (1.96 + 7.84 + 4 + 1.44 + 0.36) | 15.6 |
| Total variation of the stock (squared stock deviations: 1 + 16 + 4 + 0 + 9) | 30 |
| R squared (1 - 15.6 / 30) | 0.48 |
| Share explained by the index | 48%, the other 52% is the stock's own movement |
In a simple regression, R squared equals the correlation squared: here r is about 0.693, and 0.693 squared is 0.48.
A beta of 1.2 says that across these months the stock moved on average about 1.2% for every 1% move in the index. An R squared of 0.48 says the index explains about half of the stock's variation; the rest came from company news and noise. Read the two together. A high beta with a low R squared means the relationship is loose, so the beta is a weak guide. A beta near 1 with an R squared near 1 means the holding mostly behaves like the index itself. Beta also describes only one kind of risk, the part tied to the market. A stock can have a low beta and still collapse on its own bad news, which is why the correlation lesson matters even for low-beta portfolios. Its record as a predictor of returns is mixed: Eugene Fama and Kenneth French concluded that the empirical record of the capital asset pricing model is poor enough to undermine the way it is commonly applied. Treat beta as a description of a past relationship, not a law.
- Beta
- How much the stock moved per 1% move in the index
- Alpha
- The stock's average return when the index was flat
- R squared
- The share of the stock's variation the index explains
- Residual
- The gap between an actual return and the line's prediction
Two practical points about beta. First, a portfolio's beta is the weighted average of its holdings' betas. Hold 60% in a stock with a beta of 1.2 and 40% in one with a beta of 0.5, and the mix has a beta of 0.6 x 1.2 + 0.4 x 0.5 = 0.72 + 0.20 = 0.92. Second, beta is not a fixed property of a stock. It depends on the index you compare against, whether you use daily, weekly or monthly returns, and which years you include, so two published betas for the same stock can differ and both be computed correctly. Before comparing betas, check that they were measured the same way.
Regression is also where overfitting starts. A straight line through five points has two numbers to choose, alpha and beta, and it misses some of the points. Allow a curve with five numbers to choose and it can pass through all five points exactly, with an R squared of 1. That perfect fit predicts nothing; it has memorized five months of noise. The same thing happens when a trading rule gains parameter after parameter until it matches past data perfectly. Adding inputs to a regression never lowers its R squared on the data used to fit it, so a high in-sample fit is cheap. The honest test is data the model has not seen, which is the theme of the overfitting lesson and the walk forward lesson.
A perfect fit is a warning, not a win
With as many parameters as data points, any model fits perfectly. Fit quality only means something when the model is simple relative to the data, and when it holds up on data it was not fitted to.
A stock has a beta of 0.5 against an index, with a high R squared. The index rises 4% in a month. What does the regression suggest? The stock has tended to rise about 2% in months like that, give or take its own noise 0.5 x 4% = 2%, plus alpha and a residual. A high R squared means the line has fitted fairly closely.
You can read beta and R squared
You can now fit a regression line by hand, read beta as the slope and R squared as the fit, and explain why a perfect fit can be a sign of overfitting.
Check your understanding
- Index deviations are -1, 0 and +1. Stock deviations are -3, 0 and +3. What is the stock's beta?
- 3. Sum of products: 3 + 0 + 3 = 6. Sum of squared index deviations: 1 + 0 + 1 = 2. Beta = 6 / 2 = 3.
- A stock's regression on an index has an R squared of 0.2. What does that mean?
- The index explains about 20% of the stock's variation, so most of its movement is its own. R squared is the share of variation explained by the line. The other 80% came from company news and noise.
- A curve with five adjustable numbers passes exactly through five data points, giving an R squared of 1. What does that show?
- Very little: with as many parameters as points, a perfect fit is automatic. The curve has memorized the noise in those five points. Only new data can test whether it predicts anything.
- What did Fama and French conclude about the capital asset pricing model?
- Its empirical record is poor enough to undermine how it is commonly applied. Their 2004 review found the model's evidence weak, which is a reason to treat beta as a description rather than a law.
Common questions
- What is beta in simple terms?
- Beta is how much a stock has tended to move for each 1% move in a market index. A beta of 1.2 means about 1.2% on average; below 1 means smaller moves; a negative beta means it tended to move the other way. It is the slope of a regression line.
- What is the difference between beta and R squared?
- Beta is the slope of the line, how far the stock moved per 1% of the index. R squared is how well the line fits, the share of the stock's variation the index explains. A beta with a low R squared is a weak guide.
Terms defined in this lesson
Continue
- Previous: The Sharpe and Sortino ratios
- Correlation and diversification
- Overfitting and curve-fitting (the cardinal sin)
- Out-of-sample testing and walk-forward analysis
- The real risks of automating (and why testing comes first)
- Statistics for Investors and Traders track
- All Agenticks lessons
- Trading glossary
Sources
- Illowsky, B., & Dean, S. (2023). Introductory statistics 2e. OpenStax.
- Sharpe, W. F. (1964). Capital asset prices: A theory of market equilibrium under conditions of risk. The Journal of Finance, 19(3), 425-442.
- Fama, E. F., & French, K. R. (2004). The capital asset pricing model: Theory and evidence. Journal of Economic Perspectives, 18(3), 25-46.
- Lopez de Prado, M. (2018). Advances in financial machine learning. John Wiley & Sons.
Written and reviewed by the Agenticks Learn editorial team. How we write and check lessons.
Agenticks Learn is general education. It is not financial, investment, tax or legal advice, it does not take your situation into account, and nothing on it is a recommendation to buy, sell or hold any security or to open any account. Examples use illustrative numbers. Investing involves risk, including losing money you put in, and past performance does not predict future results. Tax rules and limits change; the official sources linked in each lesson are the final word.