Exercise: Stock Beta via OLS — Numerical Example
Prerequisites: Linear Regression Derivation
Problem
You have two years of daily returns ( days) for a stock and an index . The true data-generating process is , with (stock-specific noise) and (market returns).
-
Simulate the data with a seeded RNG.
-
Compute the standard error (using the true , or use residual for a real-world estimate). Report a 95% confidence interval for .
-
Interpret. Is your estimate statistically significantly different from the reference "market beta" of ? From the "true" beta of ? What is the minimum sample size you would need to distinguish a beta of from at 5% significance?
Hint
For part 3: the "residual " is , which estimates noise std from the regression residuals. Use
np.polyfit(..., full=True) to get residuals or compute manually.Jump to the solution when you're ready.