The CAPM states the following:
E(R) = Rf + β(E(Rm) – Rf)
where R is the return on the asset of interest, Rf is the risk-free rate of return, Rm is the rate of return for the entire market (the market portfolio) and β is a parameter that describes the sensitivity of the asset’s return to the market’s return.
To estimate a stock’s β, you therefore need historical data on a stock’s returns, the market’s returns, and the risk-free interest rate. You can calculate returns from an asset’s prices as follows:
Rt = (Pt + Dt – Pt-1) / (Pt-1)
Where Rt is the asset’s return in period t, Pt is the asset’s price in period t, and Dt is the dividend on the stock in period t (usually 0). It is customary to use a broad-based market index (such as the S&P 500 or the Wilshire 5000) to estimate the returns on the market portfolio and to use the returns on short term US Treasury bills to estimate the risk-free rate of return.
The following regression model can then be used to estimate a stock’s β:
Rt – Rft = α + β(Rmt – Rft) + ut
If the CAPM holds, α = 0, and the regression output allows you to test this hypothesis (as well as other hypotheses related to α and β.