Linear Regression & Fit
Use market monthly returns as X and stock monthly returns as Y to explore what a fitted line explains and what it cannot promise.
Question, try, then observe
What changes when market return rises by one percentage point?
X is market monthly return and Y is stock monthly return. Change the illustrative slope and disturbance, then append an outlier pair. Observe the refitted ordinary least-squares line.
Illustrative data, not live market data. A monthly return of 2 = 2%; dispersion and return differences use percentage points, with no annualization.
What did you just see?
Slope is the model's conversion rule: for each one-percentage-point increase in market return, fitted stock return changes by b percentage points, reversing direction when b is negative.
Correlation and regression ask different questions
is symmetric when X and Y are swapped and is unitless. Regression assigns X as explanatory and Y as response; slope depends on their units. In simple regression with an intercept and nonconstant X and Y, =r².
Sample fit and limitations
A residual is observed Y minus fitted Y. Outliers can change the slope and intercept substantially. Serial dependence, heteroskedasticity and nonlinearity also matter. This tool does not provide coefficient confidence intervals, causal conclusions or trading advice.
Another example
- Enter paired market X and stock Y returns from the same periods; 2 means 2%.
- Fit simple linear regression with an intercept and inspect the scatter plot and fitted line.
- Read slope, intercept, R² and residuals together, considering outliers and model limitations.
Show formal definition and formula
Simple linear regression with an intercept uses ordinary least squares to minimize squared residuals in the Y direction.
Ordinary least squares with an intercept
Fitted Y equals intercept a plus slope b times X. b is the paired deviation-product sum divided by the X squared-deviation sum; a is mean Y minus b times mean X.
Residuals and sample explanatory proportion
A residual is observed Y minus fitted Y. R² is one minus residual squared error divided by total squared deviations of Y from its mean; it is undefined for constant Y.
- xᵢ / yᵢ
- Observations from the same period. A return input of 2 means 2%, calculated directly in percentage units.
- a / b / ŷ
- a is fitted Y at X=0. b is fitted Y's percentage-point change per additional percentage point of X. Ŷ is a fitted value, not a future guarantee.
- eᵢ / R²
- eᵢ is observed Y minus fitted Y. R² is this sample's reduction in squared deviations and is undefined for constant Y.
- Model
- Slope illustrates sample Beta in this market/stock return model; the intercept is not a completed risk-adjusted Jensen's alpha.
Common mistakes
Do not call an ordinary-return intercept a completed risk-adjusted alpha estimate, or use in-sample R² to claim accurate future stock-price forecasts.
Frequently asked questions
Can this slope be interpreted as beta?
With market returns as X and stock returns as Y using matching periods and units, the slope describes sample market sensitivity. Its estimate depends on the window, data quality and model assumptions.
Is the intercept Jensen’s alpha?
Not directly. This tool uses ordinary paired returns, without establishing an excess-return CAPM specification relative to a risk-free rate or testing risk-adjusted performance.
Does a high R² predict stock prices?
No. R² describes the share of in-sample Y variation explained by the fitted model. It is not causation, future forecast accuracy or trading advice.
What happens when X or Y is constant?
With no variation in X, slope is not uniquely identifiable. A constant Y can yield a horizontal line, but R² and Pearson r are undefined and must not be called perfect explanatory power.
You can now explore…
- How slope and intercept set the fitted line
- Read R² as in-sample fit with limitations
Term reference3 terms
Open a term when you need a reminder. Underlined words in the article work too.