Module contents
Lesson 5 of 30Core 95 min

The CAPM: equilibrium, beta and its tests

Derive CAPM, estimate alpha and beta, interpret the GRS test, and examine market proxies and empirical security market lines.

After this lesson you can

  • Derive CAPM from the tangency portfolio first-order condition and market equilibrium.
  • Estimate betas and alphas by time-series regression and quantify their uncertainty.
  • Implement the GRS joint-zero-alpha test and interpret it as Sharpe distance from the frontier.
  • Explain Roll's critique and the limitations of testing CAPM with a market-index proxy.
  • Reproduce the historical security market line with beta-sorted portfolios and relate it to the low-beta anomaly.

Before you start

Which risk should be rewarded?

A stock can fluctuate greatly because of its own news and still add little risk to a broad portfolio. CAPM asks what expected premium rewards the risk remaining when an investor can diversify. Its theoretical answer is covariance with the market portfolio, not the asset’s isolated volatility.

InteractiveDiversifiable and common risk
  • Equal-weight portfolio
  • Factor limit
10
0.25
Portfolio volatility11.4 %
Systematic limit10.0 %
The model assumes assets with 20% volatility and a nonnegative common correlation. Change the number of assets and correlation: idiosyncratic variation averages out, while the common component leaves a floor. This is a hypothetical formula, not market data.

For NN equally weighted assets with variance σ2\sigma^2 and common correlation ρ≥0\rho\ge0, the variance of the average is σ2[ρ+(1−ρ)/N]\sigma^2[\rho+(1-\rho)/N]. The sum contains NN diagonal terms and N(N−1)N(N-1) covariances. The limit is σ2ρ\sigma^2\rho: if ρ=0\rho=0 all risk in this model vanishes; a shared factor remains. Diversification does not guarantee eliminating every risk in a real market.

From the investor to equilibrium

The capital asset pricing model (CAPM) combines fund separation with equilibrium. In a one-period version, all investors have the same asset set, the same return distribution and mean-variance preferences with positive risk aversion; they can lend or borrow at the same risk-free rate, and no costs or constraints prevent them from holding the portfolios. The market is also assumed to clear, the aggregate risky portfolio to have positive supply and variance, and the market premium to be positive.

Under these assumptions, each investor holds a combination of the risk-free asset and the same tangency portfolio, though total exposures differ. Adding positions makes the aggregate supply of risky assets proportional to that portfolio. The market portfolio MM, weighted by the value of all risky assets, therefore coincides with it. This conclusion depends on equilibrium and common assumptions; it does not follow from optimizing one isolated investor’s portfolio.

Write a=μ−rf1\vb{a}=\vb{\mu}-r_f\vb{1}, let wM\vb{w}_M be market weights and σM2=wM⊤ΣwM>0\sigma_M^2=\vb{w}_M\T\mat{\Sigma}\vb{w}_M>0. Tangency gives a=cΣwM\vb{a}=c\mat{\Sigma}\vb{w}_M for some c>0c>0. Multiplying by wM⊤\vb{w}_M\T gives c=(E[RM]−rf)/σM2c=(\E[R_M]-r_f)/\sigma_M^2. Component ii is

E[Ri]−rf=Cov⁡(Ri,RM)Var⁡(RM)⏟βi(E[RM]−rf).\E[R_i]-r_f=\underbrace{\frac{\Cov(R_i,R_M)}{\Var(R_M)}}_{\beta_i}\big(\E[R_M]-r_f\big).

Beta is the asset’s covariance with the market divided by market variance. It is dimensionless, can be negative and can also be written ρiMσi/σM\rho_{iM}\sigma_i/\sigma_M. The model rewards beta: a highly volatile asset with negative covariance can have a negative premium, under the model’s assumptions and expectations.

The security market line (SML) plots expected mean against beta: intercept rfr_f, slope E[RM]−rf\E[R_M]-r_f. In excess returns it passes through the origin. It differs from the capital market line, which relates mean to volatility for efficient combinations. Do not confuse the horizontal axes or treat a historical scatter as known expectations.

InteractiveSML with public data
  • Portfolios
  • SML with observed premium
  • Cross-sectional fit
Months738
Annualized market premium7.0 %
Annualized cross-sectional slope3.2 %
Annualized cross-sectional intercept4.5 %
Choose beta deciles or the 25 size-value portfolios and change period. Points are OLS betas and annualized average excess returns; the dark line uses the observed market premium and the orange line is a descriptive cross-sectional fit. These are monthly Kenneth French data with CRSP vintage 202609, not causal proof or a guarantee of a flat slope in every sample.

The points were calculated using the market factor and risk-free rate from the Kenneth French Data Library, over the fixed window July 1963 to December 2024. The cross-sectional fit uses betas and means from the same period, so it is descriptive and can suffer estimation error on both axes. Beta deciles are formed each June using historical information; their plotted betas are re-estimated over the selected period. The library may revise historical data.

In this particular download, the ten beta deciles in 1963-2024 give an annualized cross-sectional slope of 0.03230, versus an annualized market premium of 0.07041. The 25 size-value portfolios give slope −0.04323 with the same factor and period. These are two summaries of the same US history, with different errors and compositions; they do not prove the future slope must be flat. The lab recalculates them from original files.

Regression, alpha and beta

For excess returns rit=Rit−rftr_{it}=R_{it}-r_{ft} and ft=RMt−rftf_t=R_{Mt}-r_{ft}, estimate

rit=αi+βift+εit.r_{it}=\alpha_i+\beta_i f_t+\varepsilon_{it}.

Jensen’s alpha is the intercept of this regression relative to the chosen factor. In population CAPM with the correct market portfolio and appropriate conditions, αi=0\alpha_i=0. The estimate β^i=∑t(ft−fˉ)(rit−rˉi)/∑t(ft−fˉ)2\hat\beta_i=\sum_t(f_t-\bar f)(r_{it}-\bar r_i)/\sum_t(f_t-\bar f)^2 is an ordinary least squares slope; α^i=rˉi−β^ifˉ\hat\alpha_i=\bar r_i-\hat\beta_i\bar f. R2R^2 measures variance explained in sample, not whether the model prices the asset correctly.

Uncertainty matters: a positive estimated alpha may be noise, and examining many alphas increases the chance of finding a large one by chance. Classical standard errors require the regression assumptions; heteroskedasticity or temporal dependence require suitable estimators, such as a robust matrix with appropriate lags. The exact GRS inference below does not automatically survive those modifications.

With one factor treated as fixed, positive variation ∑t(ft−fˉ)2>0\sum_t(f_t-\bar f)^2>0 and independent zero-mean errors with constant variance σε2\sigma_\varepsilon^2, Var⁡(β^∣f)=σε2/∑t(ft−fˉ)2\Var(\hat\beta\mid\vb{f})=\sigma_\varepsilon^2/\sum_t(f_t-\bar f)^2 and Var⁡(α^∣f)=σε2[1/T+fˉ2/∑t(ft−fˉ)2]\Var(\hat\alpha\mid\vb{f})=\sigma_\varepsilon^2[1/T+\bar f^2/\sum_t(f_t-\bar f)^2]. Replace unknown variance with residual sum of squares divided by T−2T-2 for classical standard errors. The normality assumption permits exact t intervals; with dependent errors, an HAC estimator and its lag count require additional choices.

Two practical adjustments address different problems. Vasicek combines a noisy beta with a prior mean using an uncertainty-dependent weight under an explicit beta-distribution model. Dimson includes lags and leads of market return in the regression and sums their coefficients to capture quotes that react with delay; lag choice and calendar matter. Neither alone removes selection bias or structural change.

For example, if βi∼N(b0,τ2)\beta_i\sim\Normal(b_0,\tau^2) and, conditionally on it, β^i∼N(βi,si2)\hat\beta_i\sim\Normal(\beta_i,s_i^2) with known parameters, the posterior mean is τ2τ2+si2β^i+si2τ2+si2b0\frac{\tau^2}{\tau^2+s_i^2}\hat\beta_i+\frac{s_i^2}{\tau^2+s_i^2}b_0. A less precise beta receives more prior weight. Estimating b0b_0, τ2\tau^2 and si2s_i^2 introduces additional uncertainty; the adjustment does not replace a confidence interval.

Joint testing and geometry

Let R∈RT×N\mat{R}\in\R^{T\times N} be a matrix of asset excess returns and F∈RT×K\mat{F}\in\R^{T\times K} a factor matrix. The regression includes an intercept and KK factor columns. Let α^\hat{\vb{\alpha}} be the intercept vector, Σ^=E⊤E/T\hat{\mat{\Sigma}}=\mat{E}\T\mat{E}/T residual covariance with divisor TT, fˉ\bar{\vb{f}} the factor mean and Ω^\hat{\mat{\Omega}} its centered covariance, also with divisor TT.

The Gibbons-Ross-Shanken test (GRS) for H0:α=0H_0:\vb{\alpha}=\vb{0} uses the following form, consistent with the original derivation:

FGRS=T−N−KN α^⊤Σ^−1α^1+fˉ⊤Ω^−1fˉ.F_{\rm GRS}=\frac{T-N-K}{N}\, \frac{\hat{\vb{\alpha}}\T\hat{\mat{\Sigma}}\inv\hat{\vb{\alpha}}} {1+\bar{\vb{f}}\T\hat{\mat{\Omega}}\inv\bar{\vb{f}}}.

With T>N+KT>N+K, full-rank design and errors independent over time, zero-mean and multivariate normal conditional on factors, with constant positive-definite residual covariance, under H0H_0 it follows FN,T−N−KF_{N,T-N-K}. These divisor conventions are essential: if you use the residual estimator with divisor T−K−1T-K-1, adjust the scaling factor. The distribution is exact under those assumptions; it is not guaranteed for residuals with heteroskedasticity, autocorrelation or arbitrary tails.

The scale can be reconstructed without memorization. Let X=[1  F]\mat{X}=[\vb{1}\;\mat{F}], W=E⊤E\mat{W}=\mat{E}\T\mat{E} and c=[(X⊤X)−1]11c=[(\mat{X}\T\mat{X})\inv]_{11}, corresponding to the intercept. By the Schur complement, c=(1+fˉ⊤Ω^−1fˉ)/Tc=(1+\bar{\vb{f}}\T\hat{\mat{\Omega}}\inv\bar{\vb{f}})/T. Conditional on the design, under the null α^\hat{\vb{\alpha}} is normal with covariance cΣc\mat{\Sigma} and independent of W\mat{W}, which has T−K−1T-K-1 Wishart degrees of freedom. Hotelling’s transformation gives T−N−KNcα^⊤W−1α^∼FN,T−N−K\frac{T-N-K}{Nc}\hat{\vb{\alpha}}\T\mat{W}\inv\hat{\vb{\alpha}}\sim F_{N,T-N-K}. Substituting W=TΣ^\mat{W}=T\hat{\mat{\Sigma}} gives exactly the formula above.

In the block decomposition of factor and asset covariance, the difference between maximum squared Sharpe of the expanded set and that of factors alone is α^⊤Σ^−1α^\hat{\vb{\alpha}}\T\hat{\mat{\Sigma}}\inv\hat{\vb{\alpha}} with the divisors above. The denominator is one plus squared Sharpe of the factors. Thus GRS measures relative improvement in the frontier, weights alphas by residual covariance and has a null distribution under the stated assumptions. A small sample or highly correlated assets can reduce power; failure to reject does not prove all alphas are exactly zero.

InteractiveGRS as Sharpe improvement
  • Factor and risk-free asset
  • Factor and two assets
1.2 %
0.4 %
120
Factor Sharpe²0.0225
Increase in Sharpe²0.0609
GRS for these moments3.482
5% critical value3.074
Reject at 5% under the stated assumptions.
In a hypothetical summary with one factor and two assets, move the two alphas and T. Lines are combinations with a risk-free asset; the increase in squared Sharpe matches the alpha quadratic form. The exact F threshold applies under normality assumptions and does not make these hypothetical moments observed data.

What an index tests

Roll’s critique notes that CAPM refers to the portfolio of all risky assets, which is not fully observed. With an index as a substitute, a joint test evaluates that index’s mean-variance efficiency within the chosen set, together with statistical assumptions. Rejecting that proxy does not by itself show the true market portfolio is inefficient. It also does not make a test useless: it precisely defines the portfolio and set tested.

Without unlimited borrowing at the risk-free rate, Black’s zero-beta CAPM uses a reference portfolio uncorrelated with the market instead of a common financing rate. Intertemporal CAPM adds hedging demands against changes in investment opportunities; one market beta may not summarize all relevant risks. These are models with additional assumptions and factors, not automatic repairs for an observed alpha.

Frazzini and Pedersen study a betting against beta portfolio combining long exposure to low beta and short exposure to high beta, scaled to neutralize beta in the model. Their financing-constraint mechanism is a modeled explanation, not a deduction from this figure. Evidence of a flat historical SML is sensitive to period, portfolio construction, beta measurement, costs and proxy choice.

Lab: matrix OLS and test size

The first cell implements regression for all assets simultaneously and the statistic with divisors TT. It solves linear systems instead of forming inverses. A rank error or singular residual covariance prevents applying this version of the test.

[ ]GRS with explicit divisorsBrowser
import numpy as np
from scipy.stats import f as f_dist

def grs_test(excess_returns, factor_returns):
    Y=np.asarray(excess_returns,dtype=float)
    F=np.asarray(factor_returns,dtype=float)
    if F.ndim==1: F=F[:,None]
    if Y.ndim!=2 or F.ndim!=2 or len(Y)!=len(F):
        raise ValueError('Se requieren matrices con el mismo número de filas')
    T,N=Y.shape
    K=F.shape[1]
    if N<1 or K<1 or T<=N+K or not np.isfinite(Y).all() or not np.isfinite(F).all():
        raise ValueError('Dimensiones insuficientes o datos no finitos')
    X=np.column_stack((np.ones(T),F))
    coef,_,rank,_=np.linalg.lstsq(X,Y,rcond=None)
    if rank<K+1: raise ValueError('Factores de rango insuficiente')
    residuos=Y-X@coef
    S=residuos.T@residuos/T
    centred=F-F.mean(axis=0)
    Omega=centred.T@centred/T
    alpha=coef[0]
    if np.linalg.matrix_rank(S)<N or np.linalg.matrix_rank(Omega)<K:
        raise ValueError('Covarianza singular')
    try:
        num=alpha@np.linalg.solve(S,alpha)
        den=1+F.mean(axis=0)@np.linalg.solve(Omega,F.mean(axis=0))
    except np.linalg.LinAlgError as exc:
        raise ValueError('Covarianza singular') from exc
    stat=(T-N-K)/N*num/den
    return float(stat),float(f_dist.sf(stat,N,T-N-K))

def ajustar_capm(Y,factor):
    Y=np.asarray(Y,dtype=float)
    X=np.column_stack((np.ones(len(factor)),np.asarray(factor)))
    coef=np.linalg.lstsq(X,Y,rcond=None)[0]
    residual=Y-X@coef
    return coef,residual

To check size and power, we use normal factors, normal residuals with a common and an idiosyncratic component, and independence between factors and residuals. The alternative plants alternating-sign alphas; the observed outcome depends on the seed and alternative size. The experiment is divided into blocks to keep each browser cell brief.

[ ]Prepare the simulationBrowser
def bloque(seed,reps=100):
    g=np.random.default_rng(seed)
    T,N=120,25
    alpha_alt=.006*np.where(np.arange(N)%2==0,1.,-1.)
    rechazos=np.zeros(2,dtype=int)
    for _ in range(reps):
        factor=g.normal(.006,.04,size=T)
        errors=.05*(.4*g.normal(size=(T,1))+np.sqrt(1-.4**2)*g.normal(size=(T,N)))
        base=factor[:,None]*np.linspace(.6,1.4,N)+errors
        for j,alpha in enumerate((np.zeros(N),alpha_alt)):
            _,p=grs_test(base+alpha,factor)
            rechazos[j]+=p<.05
    return rechazos

cuentas=bloque(280501)
print('Bloque 1:',cuentas)
[ ]Block 2Browser
cuentas+=bloque(280502)
print('Acumulado:',cuentas)
[ ]Block 3Browser
cuentas+=bloque(280503)
print('Acumulado:',cuentas)
[ ]Block 4Browser
cuentas+=bloque(280504)
print('Acumulado:',cuentas)
[ ]Block 5 and Monte Carlo errorBrowser
cuentas+=bloque(280505)
prob=cuentas/500
error=np.sqrt(prob*(1-prob)/500)
print('Rechazos nula y alternativa:',cuentas,'de 500')
print('Proporciones:',np.round(prob,4),'| error estándar Monte Carlo:',np.round(error,4))

Size is the rejection probability when the null is true; power is the rejection probability under this particular alternative. The simulation does not demonstrate robustness to real non-Gaussian residuals or measure power for every alpha vector.

With these five seeds, the run produced 25 rejections in 500 replicates under the null and 492 under the alternative: proportions 0.050 and 0.984, with approximate Monte Carlo standard errors 0.0097 and 0.0056. These figures describe the cell’s generator; another alternative or residual covariance can have different power.

Lab: Kenneth French portfolios

We repeat the analysis on the 25 size-value portfolios and beta-sorted deciles. The library publishes monthly simple returns in percent; subtract the same month’s risk-free rate and use Mkt-RF as a proxy for market excess return. The previous figure retains a summary of a download with CRSP vintage 202609. The cell queries current files, whose history may be revised, so figures may change. It needs local Python and network access; the interactive’s copy does not depend on downloading while reading.

The cross-sectional slope fits means to betas estimated in the same period. Means are multiplied by 12 as an arithmetic scale, not compounded annual returns. The example HAC standard errors relax some individual-error assumptions, but do not turn classical GRS into a robust test.

[ ]Download and align the seriesLocal GPU
import io,zipfile,urllib.request
import numpy as np
import pandas as pd
import statsmodels.api as sm
from scipy.stats import f as f_dist

base='https://mba.tuck.dartmouth.edu/pages/Faculty/ken.french/ftp/'
def tabla_mensual(nombre,marca,n_columnas):
    with urllib.request.urlopen(base+nombre,timeout=30) as response:
        contenido=response.read()
    with zipfile.ZipFile(io.BytesIO(contenido)) as z:
        texto=z.read(z.namelist()[0]).decode('latin1')
    lineas=texto.splitlines()
    i=next(j for j,linea in enumerate(lineas) if marca in linea)
    i += 1 if marca.startswith(',') else 2
    datos=[]
    for linea in lineas[i:]:
        campos=[v.strip() for v in linea.split(',')]
        if len(campos)!=n_columnas+1 or len(campos[0])!=6 or not campos[0].isdigit(): break
        datos.append([int(campos[0])]+[float(v) for v in campos[1:]])
    return np.asarray(datos)

factores=tabla_mensual('F-F_Research_Data_Factors_CSV.zip',',Mkt-RF,SMB,HML,RF',4)
valor=tabla_mensual('25_Portfolios_5x5_CSV.zip','Average Value Weighted Returns -- Monthly',25)
beta=tabla_mensual('Portfolios_Formed_on_BETA_CSV.zip','Value Weighted Returns -- Monthly',15)
beta=np.column_stack((beta[:,0],beta[:,6:])) # los últimos diez son los deciles

def alinear(portafolios,desde,hasta):
    fechas=np.intersect1d(factores[:,0],portafolios[:,0])
    fechas=fechas[(fechas>=desde)&(fechas<=hasta)]
    f=factores[np.isin(factores[:,0],fechas)]
    p=portafolios[np.isin(portafolios[:,0],fechas)]
    meses=(fechas//100)*12+fechas%100
    if (len(f)==0 or fechas[0]!=desde or fechas[-1]!=hasta or np.any(np.diff(meses)!=1)
            or not np.array_equal(f[:,0],p[:,0]) or np.any(p[:,1:]<=-99)
            or np.any(f[:,1:]<=-99)):
        raise ValueError('Fechas incompatibles o datos ausentes')
    return (p[:,1:]-f[:,4,None])/100,f[:,1]/100
print('Se descargaron factores, 25 carteras y deciles de beta.')
This cell needs the local lab (PyTorch with your GPU). Start it with npm run lab and open the connection link.

Both results tables are recalculated, not copied from the widget. Three preset periods are calculated and the first regression is checked with statsmodels. A difference between cross-sectional slope and market premium summarizes a sample; it does not control for beta error or by itself prove an exploitable anomaly.

[ ]Alphas, betas and GRS on public dataLocal GPU
def estimar(Y,f):
    X=np.column_stack((np.ones(len(f)),f))
    coef=np.linalg.lstsq(X,Y,rcond=None)[0]
    E=Y-X@coef
    T,N=Y.shape
    S=E.T@E/T
    omega=np.mean((f-f.mean())**2)
    if T<=N+1 or omega<=0 or np.linalg.matrix_rank(S)<N:
        raise ValueError('Muestra o covarianza insuficientes')
    F=(T-N-1)/N*(coef[0]@np.linalg.solve(S,coef[0]))/(1+f.mean()**2/omega)
    return coef,float(F),float(f_dist.sf(F,N,T-N-1))

for etiqueta,datos in [('tamaño-valor',valor),('deciles beta',beta)]:
    for periodo,desde,hasta in [('1963-1990',196307,199012),('1991-2024',199101,202412),('1963-2024',196307,202412)]:
        Y,f=alinear(datos,desde,hasta)
        coef,F,p=estimar(Y,f)
        pendiente,intercepto=np.polyfit(coef[1],12*Y.mean(axis=0),1)
        print(etiqueta,periodo,'n',len(f),'prima anualizada',round(float(12*f.mean()),5),
              'pendiente',round(float(pendiente),5),'GRS',round(F,4),'p',f'{p:.3g}')
    Y,f=alinear(datos,196307,202412)
    coef,_,_=estimar(Y,f)
    ajuste=sm.OLS(Y[:,0],sm.add_constant(f)).fit(cov_type='HAC',cov_kwds={'maxlags':3})
    print('Statsmodels coincide en alfa y beta:',bool(np.allclose(ajuste.params,coef[:,0])),
          '| alfa y beta:',np.round(ajuste.params,5),
          '| errores HAC alfa y beta:',np.round(ajuste.bse,6),
          '| R²:',round(float(ajuste.rsquared),4))
This cell needs the local lab (PyTorch with your GPU). Start it with npm run lab and open the connection link.

The test family is large: a joint rejection does not by itself identify which portfolio causes the deviation, and a notable individual alpha after many searches is not independent evidence. Compare periods, intervals and definitions before attributing an economic cause.

In the download used for the figure, the first size-value portfolio in 1963-2024 gave monthly α^≈−0.00537\hat\alpha\approx-0.00537 and β^≈1.41012\hat\beta\approx1.41012; statsmodels obtained R2≈0.6258R^2\approx0.6258 and HAC alpha standard error 0.001909 with three lags. These figures check the regression on that sample, not skill or proof that the proxy is the complete market. Updated data or a different lag choice can change them.

Exercises

ProofFrom tangency to beta
Prove: If the market portfolio is the tangency portfolio and its premium and variance are positive, prove the CAPM relationship.
0
Let a=μ−rf1\vb{a}=\vb{\mu}-r_f\vb{1} and Σ\mat{\Sigma} be positive definite.

Step 1 of 3. What relationship does tangency imply?

NumericFrom correlation to required return
An asset has correlation 0.6 with the market, volatility 30% and market volatility 15%. With a 3% risk-free rate and 5% market premium, calculate its CAPM expected return as a percentage.
ProofThe frontier improvement
Prove: Prove that the improvement in maximum squared Sharpe from adding assets is α^⊤Σ^−1α^\hat{\vb{\alpha}}\T\hat{\mat{\Sigma}}\inv\hat{\vb{\alpha}}.
0
Use sample means and covariances with divisor TT, centered factors with invertible covariance, and positive-definite residual covariance.

Step 1 of 3. How does the asset mean decompose?

QuizHigh volatility and a negative premium
Under CAPM, how can an asset with volatility 60% have expected return below the risk-free rate when the market premium is positive?
CodeJoint test
Implement grs_test(Y,F), with Y shaped T×N and F shaped T×K or T. Return (statistic, p) using covariances with divisor T and the exact F distribution. Reject incompatible dimensions, deficient rank or singular covariances with ValueError.
def grs_test(Y,F):
  raise NotImplementedError()
Shift+Enter to run

Ideas to remember

CAPM identifies rewarded risk with covariance relative to the market portfolio under demanding equilibrium assumptions. Estimating beta and testing alphas are different problems: GRS combines alphas and their covariance, but its exact distribution depends on its assumptions, and empirical results also depend on the proxy and sample.