Factor Models: CAPM to Machine Learning
Module: Fintech AI | Difficulty: Advanced
CAPM
Fama-French 3-Factor
Factor Zoo
Over 400 published factors, many fail to replicate.
Replication Criteria
| Criterion | Threshold |
|---|---|
| t-stat | > 3.0 |
| p-value | < 0.01 |
| Out-of-sample | Significant |
import numpy as np
from sklearn.linear_model import LinearRegression
class FactorModel:
def __init__(self):
self.model = LinearRegression()
def fit(self, factors, returns):
self.model.fit(factors, returns)
self.betas = self.model.coef_
self.alpha = self.model.intercept_
def predict(self, factors):
return self.model.predict(factors)
def r_squared(self, factors, returns):
return self.model.score(factors, returns)
Research Insight: The factor zoo crisis reveals the problem of p-hacking in finance. Many published factors are spurious. The key is to test factors out-of-sample and require economic rationale. Machine learning can discover factors but increases the risk of overfitting.