StataNow spotlight: The facts and the factors of CAPM
Have you explored the new financial statistics suite of commands that was introduced in the June update to StataNow? You can use them to generate returns, compute financial summary statistics, select assets in portfolios, compute value at risk, and fit financial regression models. Here we will take the new finregress capm command for a spin and learn about the capital asset pricing model (CAPM) and its extensions.
We do not often run into a serious econometric model that has just one dependent variable and one independent variable. But the vanilla version of the CAPM is just that. This is the most basic specification in Stata’s new finregress capm command. So why are we so confident that this one regressor—the market factor—is enough to explain asset returns? Where does that assumption come from? How do we test whether it holds?
The story of how this assumption was born and how it evolved is an important one in the study of financial markets. We tell it here and illustrate with a fantastic dataset from the Brazilian stock market.
The CAPM
Markowitz (1959) developed a theory of how investors should allocate their wealth across assets, that is, how they should construct portfolios of assets. In his model, investors are concerned only with the tradeoff between the expected returns and the variance of those returns. An asset with the same expected return as others but with lower variance (lower risk) will be preferred, as will an asset with the same risk as others but with higher expected returns. Motivated like this, every investor holds the same optimal portfolio. The weights of this portfolio are the market-clearing prices of the assets, that is, the prices at which demand equals supply.
The CAPM, developed by William Sharpe and John Lintner in the 1960s, allows us to detect whether this investment logic holds in a market. The CAPM for \(r_{it}\), the returns of asset \(i\) at time \(t\), is
\(r_{it} - r_t^f = \alpha_i + \beta_i(r_t^m - r_t^f) + e_{it}\)Here \(r_t^m\) are the returns of the theoretical “market” portfolio we just discussed. As a proxy, analysts typically use the returns of a financial index, like the S&P 500 in the US. \(r_t^f\) are the risk-free returns one may obtain “for sure” (or with negligible risk) in this market, such as the returns of trusty government bonds. \(e_{it}\) is a linear regression error.
The left-hand side of CAPM is the difference between the returns of the asset \(i\) and risk-free returns. On the right-hand side, we see the difference between the market returns and risk-free returns. We model these excess returns because only returns above returns of risk-free assets are of interest. If no excess returns were possible, everyone would put their money into risk-free assets and go home.
So CAPM says that 1) the excess returns of asset \(i\) are proportional to the excess market returns by a factor of \(\beta_i\) (the “market beta”). Some assets move with the market (positive \(\beta_i\)), some move against the market (negative \(\beta_i\)), and some are uncorrelated with the market (\(\beta_i\) = 0). And CAPM says that 2) when excess market returns are 0, asset \(i\) may still gain (\(\alpha_i>0\)) or lose (\(\alpha_i<0\)) value.
This last point explains why CAPM is a “pricing” model. Everything is priced perfectly in the ideal market envisioned by Markowitz: no asset systematically outperforms or underperforms the market. If asset \(i\) systematically makes investors money when the market at large does not
(\(\alpha_i>0\)), asset \(i\) is undervalued and everyone should buy shares. If asset \(i\) systematically loses investors money when the market at large does not
(\(\alpha_i<0\)), asset \(i\) is currently overvalued and everyone should sell shares. Thus, an \(\alpha_i\) equal to 0 indicates that asset \(i\) is fairly priced. If every asset in the market has an \(\alpha\) of 0, the market is behaving rationally.
A more detailed summary of all the assumptions of CAPM and the portfolio-choice model it emerged from (Markowitz 1959) can be found in Fama and French (2004).
CAPM in Brazil
To demonstrate, we use simple monthly returns of nine Brazilian companies from March 2001 to December 2018 stored in variables r_bbas3 through r_vale3:
. use ibovespa, clear
. tsset month
Time variable: month, 2001m3 to 2018m12
Delta: 1 month
. describe
Contains data from ibovespa.dta
Observations: 214
Variables: 16 11 Aug 2026 09:31
| Variable Storage Display Value | ||
| name type format label Variable label | ||
| month int %tm Month of return r_bbas3 double %10.0g Banco do Brasil S.A. r_brap3 double %10.0g Bradespar S.A. r_coce5 double %10.0g Companhia Energética do Ceará r_cple3 double %10.0g Companhia Paranaense de Energia r_fjta4 double %10.0g Forjas Taurus r_ggbr4 double %10.0g Gerdau S.A. r_lame4 double %10.0g Lojas Americanas S.A. r_unip6 double %10.0g Unipar Carbocloro S.A. r_vale3 double %10.0g Vale S.A. rmkt double %9.0g IBOVESPA return rf double %9.0g 30-day DI swap smb double %9.0g Small minus big hml double %9.0g High minus low wml double %9.0g Winners minus losers iml double %9.0g Illiquid minus liquid | ||
Our market returns, rmkt, are the returns of the BOVESPA index from Brazil. Our risk-free rate, rf, is the interbank deposit rate in Brazil.
To fit a CAPM to each of the nine return series, we type
. finregress capm r_bbas3-r_vale3 = rmkt, rfrate(rf) adjust Capital asset pricing model Sample: 2001m3 thru 2018m12 Number of obs = 214
| Robust | ||
| Coefficient std. err. z P>|z| [95% conf. interval] | ||
| r_bbas3 | ||
| rmkt | 1.6045 .1049861 15.28 0.000 1.398731 1.810269 | |
| _cons | .0056299 .0050882 1.11 0.269 -.0043429 .0156026 | |
| r_brap3 | ||
| rmkt | 1.369006 .1093856 12.52 0.000 1.154614 1.583398 | |
| _cons | .0001207 .0060453 0.02 0.984 -.0117279 .0119694 | |
| r_coce5 | ||
| rmkt | .5670884 .1039797 5.45 0.000 .3632919 .7708849 | |
| _cons | -.0019433 .0056736 -0.34 0.732 -.0130633 .0091767 | |
| r_cple3 | ||
| rmkt | .8780186 .1069481 8.21 0.000 .6684042 1.087633 | |
| _cons | -.0056245 .0056035 -1.00 0.315 -.0166071 .005358 | |
| r_fjta4 | ||
| rmkt | .6627828 .1450281 4.57 0.000 .3785329 .9470327 | |
| _cons | -.0034111 .0096386 -0.35 0.723 -.0223025 .0154802 | |
| r_ggbr4 | ||
| rmkt | 1.509779 .1503265 10.04 0.000 1.215144 1.804413 | |
| _cons | .0020659 .0065154 0.32 0.751 -.0107041 .0148359 | |
| r_lame4 | ||
| rmkt | 1.103622 .1278843 8.63 0.000 .8529732 1.35427 | |
| _cons | .0110503 .0067633 1.63 0.102 -.0022055 .0243061 | |
| r_unip6 | ||
| rmkt | .7635458 .1515232 5.04 0.000 .4665659 1.060526 | |
| _cons | -.0009873 .0076634 -0.13 0.897 -.0160073 .0140327 | |
| r_vale3 | ||
| rmkt | .9863664 .1116284 8.84 0.000 .7675788 1.205154 | |
| _cons | .0036402 .005877 0.62 0.536 -.0078785 .0151588 | |
Stata adjusts the dependent variables with the risk-free rate to compute their excess returns when rfrate() is specified. We also specify the adjust option to adjust the right-hand-side variable.
The estimated market betas are all positive, indicating that these stocks moved with the market (rather than against it, \(\beta<0\), or independently from it, \(\beta=0)\) during the period 2001–2018.
The alphas (the intercepts) are very close to 0, and their p-values suggest that these stocks were fairly valued throughout the period. A joint test of the alphas is unnecessary in this case, but the postestimation of finregress capm does include the Gibbons–Ross–Shanken test:
. estat grstest
Gibbons–Ross–Shanken test
H0: All intercept terms are zero
No. of dependent vars. = 9
No. of independent vars. = 1
No. of time periods = 214
chi2(9) = 7.410
Prob > chi2 = 0.5945
Naturally, the conclusion is the same: we cannot reject the joint null that all the alphas are 0.
However, 2001–2018 is a rather heterogeneous period for Brazil's economy and financial markets:
. tsline r_bbas3-r_vale3, title("Monthly, simple returns of nine Brazilian stocks (2001-2018)")
ytitle("Simple returns")
On this plot of the returns, the years after the 2008–2009 global financial crisis are visibly more volatile than the years before, particularly toward the end of the series. Fitting separate CAPMs for each period, we can ask whether and how the pricing of these stocks was different before and after the crisis:
. quietly finregress capm r_bbas3-r_vale3 = rmkt if
tin(2001m3, 2008m8), rfrate(rf) adjust
. estimates store capm_pre
. quietly finregress capm r_bbas3-r_vale3 = rmkt if
tin(2010m1, 2018m12), rfrate(rf) adjust
. estimates store capm_post
. estimates table capm_pre capm_post, star
| Variable | capm_pre capm_post | |
| r_bbas3 | ||
| rmkt | 1.2791123*** 2.114471*** | |
| _cons | .01119046 .00503015 | |
| r_brap3 | ||
| rmkt | 1.2287438*** 1.5549549*** | |
| _cons | .00474036 -.00202251 | |
| r_coce5 | ||
| rmkt | .60601011*** .47409454** | |
| _cons | -.00670045 -.00058211 | |
| r_cple3 | ||
| rmkt | .60331791*** 1.1512286*** | |
| _cons | -.00602278 -.00460061 | |
| r_fjta4 | ||
| rmkt | .52163763** .53118323 | |
| _cons | .02140595 -.02292301 | |
| r_ggbr4 | ||
| rmkt | 1.3188725*** 1.6985781*** | |
| _cons | .01515967 -.00466273 | |
| r_lame4 | ||
| rmkt | 1.056934*** .92798936*** | |
| _cons | .02480513 -.000811 | |
| r_unip6 | ||
| rmkt | .93160088*** .33039719 | |
| _cons | -.0115613 .00902624 | |
| r_vale3 | ||
| rmkt | .83468659*** 1.1372086*** | |
| _cons | .01260024 -.00117118 | |
We specified the star option in this last command to print stars on the table, representing statistical significance.
Our estimates suggest that all alpha coefficients were 0 both before and after the crisis, leading us to conclude that these stocks were fairly priced in both periods. Some of the market betas, however, look quite different before and after the crisis:
- Banco do Brasil (r_bbas3) and Companhia Paranaense de Energia (r_cple3) were about twice as sensitive to market movements after the crisis than before.
- The firearms manufacturer Forjas Taurus (r_fjta4) and the chemical manufacturer Unipar Carbocloro (r_unip6) seemed to move with the market before the crisis but seemingly lost this linkage after the crisis.
Beyond CAPM: The Fama–French five-factor model
In the decades after its introduction, CAPM was fit to financial data around the world and tested to see whether it was a good enough model. In many cases, CAPM was found to be an incomplete representation of how real-world financial assets are assigned a price.
One of the aspects tested was the assumption that market returns can explain asset returns on their own. Does the mass of investors really compute asset prices following the simple, rational rules outlined by Markowitz (1959)? Or do investors account for other pieces of information? That is, should additional explanatory variables be specified?
For our Brazilian stocks, we determined that regressing against market returns is enough because the intercepts of those regressions (the alphas) are 0. If the intercepts were not 0, we could consider adding further explanatory variables. For the sake of example, let us add four other so-called risk factors, as suggested by Fama and French (1992, 2004):
- The small-minus-big factor (smb), which is the return of a portfolio long on stocks with low market capitalization (“small”) and short on stocks with high market capitalization (“big”).
- The high-minus-low factor (hml), which is the return of a portfolio long on stocks with high book-to-market ratio (“high”) and short on stocks with low book-to-market ratio (“low”).
- The winners-minus-losers factor (wml), which is the return of a portfolio long on stocks with high past returns (“winners”) and short on stocks with low past returns (“losers”).
- The illiquid-minus-liquid factor (iml), which is the return of a portfolio long on stocks with high illiquidity (“illiquid”) and short on stocks with low illiquidity (“liquid”).
. quietly finregress capm r_bbas3-r_vale3 = rmk smb hml wml iml if
tin(2001m3, 2008m8), rfrate(rf) adjust
. estimates store ff5_pre
. quietly finregress capm r_bbas3-r_vale3 = rmk smb hml wml iml if
tin(2010m1, 2018m12), rfrate(rf) adjust
. estimates store ff5_post
. estimates table ff5_pre ff5_post, star
| Variable | ff5_pre ff5_post | |
| r_bbas3 | ||
| rmkt | 1.2161535*** 1.9327025*** | |
| smb | .08926031 .6715019** | |
| hml | .27126664 -.17544163 | |
| wml | -.3104217* -.17240181 | |
| iml | -.15031259 -.73127731** | |
| _cons | .01146351 .00771953 | |
| r_brap3 | ||
| rmkt | 1.3224288*** .93163761*** | |
| smb | .53115944* .32953139 | |
| hml | -.05862408 1.1128567*** | |
| wml | .30872385* -.22564095 | |
| iml | -.00380231 -.16386892 | |
| _cons | .0122481 .01133382 | |
| r_coce5 | ||
| rmkt | .60278353*** .26920545 | |
| smb | .84822375*** .08623281 | |
| hml | .20403466 .21596799 | |
| wml | .04332161 -.24072772 | |
| iml | -.51302322* .10620967 | |
| _cons | -.00011663 .00520664 | |
| r_cple3 | ||
| rmkt | .54086572*** 1.0951186*** | |
| smb | .15728785 -.09987355 | |
| hml | .6157038*** .46505875** | |
| wml | -.12902891 .23983094 | |
| iml | -.45609126 .19652049 | |
| _cons | -.00765877 -.00244036 | |
| r_fjta4 | ||
| rmkt | .58469693** .24893419 | |
| smb | .29178711 -.00778443 | |
| hml | -.07271868 .46095557 | |
| wml | .2814204 -.25804874 | |
| iml | -.04344613 .30763386 | |
| _cons | .02486731 -.0145505 | |
| r_ggbr4 | ||
| rmkt | 1.4476415*** .95685909*** | |
| smb | .22082346 .03648726 | |
| hml | .43418951* 1.1275993*** | |
| wml | .27073922 -.60026318 | |
| iml | .27964916 -.93250787 | |
| _cons | .0230776** -.00038984 | |
| r_lame4 | ||
| rmkt | 1.1920083*** 1.1110386*** | |
| smb | .04508254 .59104825 | |
| hml | .33518553 -.26792405 | |
| wml | -.15999905 .52754349* | |
| iml | .88928917 -.26400006 | |
| _cons | .03762622*** -.00064869 | |
| r_unip6 | ||
| rmkt | 1.0558131*** .00588748 | |
| smb | .08983627 .45286407 | |
| hml | .34773608* .16443876 | |
| wml | .23291402 -.34047863 | |
| iml | .37487318 -.3018025 | |
| _cons | -.00460718 .01657187 | |
| r_vale3 | ||
| rmkt | .98056858*** .52448866* | |
| smb | -.36757442 .32101369 | |
| hml | -.56365294*** .98749988*** | |
| wml | .54539253*** -.29319853 | |
| iml | .59666878** -.59779429 | |
| _cons | .01295424 .00729895 | |
A full explanation of how these factors were computed for the Brazilian dataset can be found in the NEFIN documentation we reference below.
Our CAPM with just the market factor was already good enough in this application, so the additional risk factors do not change our main conclusions. Still, we see that the additional factors may have explanatory power for the returns of some of these series even after controlling for market returns. Investors in this market were likely accounting for market capitalization, the book-to-market ratio, the stocks’ “momentum” (their recent good or bad performance), and the firms’ liquidity in their investment decisions.
Concluding remarks
In this example, we fit separate CAPMs to the periods before and after the 2008–2009 global financial crisis to determine whether and how nine Brazilian equities behaved differently in these two distinct periods. Our results suggest that all equities were fairly priced (in the mean-variance sense of Markowitz) through both periods, but in some cases, their sensitivity to the market was very different before versus after the crisis.
If you are currently researching, teaching, or learning about quantitative finance, see all the new tools in the Stata Financial Statistics Reference Manual:
| finreturns | Compute various types of returns from price data |
| finportfolio | Create asset portfolios |
| finsummarize | Compute summary statistics like the Sharpe ratio or the Treynor index |
| finvalrisk | Value-at-risk analysis |
| finregress fmb | Fama–MacBeth regression |
| finregress capm | Which we just learned about |
References
Fama, E. F., and K. R. French. 1992. The cross-section of expected stock returns. Journal of Finance 47: 427–465. https://doi.org/10.1111/j.1540-6261.1992.tb04398.x.
Fama, E. F., and K. R. French. 2004. The capital asset pricing model: Theory and evidence. Journal of Economic Perspectives 18: 25–46. DOI: 10.1257/0895330042162430.
Markowitz, H. M. 1959. Portfolio selection: Efficient diversification of investments. New Haven: Yale University Press. http://www.jstor.org/stable/j.ctt1bh4c8h.
Núcleo de Pesquisa em Economia Financeira (NEFIN). 2017. Methodology. https://nefin.com.br/resources/NEFIN_methodology.pdf.
— Alvaro Fuentes Higuera
Senior Econometrician