Stata Code for Volatility Managed Portfolios

Stata Code for Volatility Managed Portfolios

Alan Moreira and Tyler Muir (2017) show that volatility managed portfolios can produce large alphas, higher Sharpe ratios, and significant gains for investors who take investment decisions on the mean-variance frontier of modern portfolio theory. They use a number of well-known factors such as  the market, value, momentum, profitability, return on equity, and investment factors in equities, as well as the currency carry trade.  The underlying rationale behind volatility timing is that volatility timing increases Sharpe ratios because changes in factors’ volatilities are not fully offset by proportional changes in average returns. We have developed easy to use Stata code for volatility managed portfolios.

How to construct volatility managed portfolios?

The authors define volatility managed factors by scaling an excess return by the inverse of its conditional variance. Then they run a time-series regression of the volatility managed portfolio on the original factors. A positive intercept implies that volatility timing increases Sharpe ratios relative to the original factors that include RMW, CMA, ROE, IA, SMB, HML, MOM, MKT, etc.

Further, the authors  form unconditional mean-variance efficient (MVE) portfolios using various combinations of factors. These underlying factors can be thought of as the relevant information set for a given investor (e.g., an investor who only has the market available, or a sophisticated investor who also has value and momentum available). They then volatility time each of these mean-variance efficient portfolios and report alphas of regressing the volatility managed portfolio on the original MVE portfolio. The volatility managed portfolio scales the portfolio by the inverse of the portfolios’ realized variance in the previous month.

Our Stata Code

We have developed code for Table 1 and 2 in the Stata language. The code is simple to use and self-contained. There are comments on each line of the code to help users understand the purpose and sequence of the code. The code imports the factors from a CSV file and build the results table in MS Word. However, the code can be modified to match any other dataset. When applied to the factors from the Fama and French library for the authors’ period, the results are closely replicated, see the following table.

Table: Regression results
(1) (2) (3)
mktrf 0.616***
smb 0.638***
hml 0.573***
Intercept 4.996*** -0.275 1.527
(1.533) (0.927) (1.117)
Observations 1073 1073 1073
R2 0.390 0.397 0.307
RMSE 49.861 30.299 36.389
Standard errors are in parentheses. *** p<.01, ** p<.05, * p<.1


The code for Table 1 is available for $149.

For both Table 1 and Table 2, it is available for $279. For any question or information, you may contact at: