Statistics & Data Analysis

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.

01 · Make a predictionIf the fitted slope is 1.5, how much does Ŷ change for one percentage point of X?

Observed returns and fitted line

Stock monthly return (%)
Observed returns and fitted line7 observations. Horizontal axis: Market monthly return (%). Vertical axis: Stock monthly return (%). Read values with the observation selector or data table below.-40.755.5-303
Market monthly return (%)
Observed pairs (circles)Fitted line (dashed)
Observation 1 · Market monthly return (%): -3Stock monthly return (%): -3.5
Read the data table
7 observations; units are shown in the headings.
No.Market monthly return (%)Stock monthly return (%)
1-3-3.5
2-2-3
3-1-1.5
401.5
511.5
623
735.5

Ŷ = 0.50 + 1.50X

Substitute selected market monthly return % into the current fitted coefficients

Ŷ=0.5+(1.5)×1≈2
  1. Intercept and slope are fitted to the current pairs by least squares. This conditional estimate is not a guaranteed return.
Fitted slope1.50
Intercept (at X=0)0.50%
R²96.18%
Paired sample size7

At X=1.00%, Ŷ=2.00%. One additional percentage point of X changes the fitted value by 1.50 pp. R²=96.18% is the sample's reduction in squared deviations relative to using only the Y mean.

The slope of this same-period market/stock return model helps illustrate sample Beta. The intercept is fitted Y at X=0, not a completed risk-adjusted Jensen's alpha. r is a symmetric association measure; regression assigns an X→Y direction and units. Fit, R², and Beta do not guarantee future returns or provide price forecasts or trading advice.

Ordinary least squares selects the intercept and slope that minimize squared vertical residuals. A residual is observed Y minus fitted Ŷ. In simple linear regression with an intercept and varying Y, R²=r².

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

  1. Enter paired market X and stock Y returns from the same periods; 2 means 2%.
  2. Fit simple linear regression with an intercept and inspect the scatter plot and fitted line.
  3. 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.