Stata Codes | Uncertainty and Downside Risk using Rollwing Window Fama Macbeth Regressions

This project investigates the cross-sectional risk premiums of uncertainty risk factors in addition to traditional risk factors. The project uses 25 portfolios formed on size and book-to-market as test assets. The risk factors include RM-RF, SMB, HML, UMD, and economic policy uncertainty (EPU) indices from Baker, Bloom, and Davis (2016). The project examines the cross-sectional relation between the risk factors and expected stock returns using two-step Fama and Macbeth (1973) regressions. In the first step, time series regressions are used to estimate factor betas and in the second step, the cross-sectional regressions are used to estimate risk premiums. The estimation involves a 60-month rolling window estimation. Further details are given below:

  1. Importing different files from Excel

  2. Reshaping the data to a long format

  3. Merging different datasets

  4. The test portfolios and risk factors are downloaded from the Fama and French library.

  5. For each test assets, betas are estimated using a 60-month rolling window.

  6. Descriptive statistics are reported for the estimated betas.

  7. Then cross-sectional regressions are run in each period, using newey standard errors.

  8. Regression coefficients are then reported.

Our Stata Code

We have developed easy to use yet robust codes for the above steps. The codes need just a basic understanding of Stata. Further, our comments on each line of code will surely help you in running the code as well as in understanding the process more clearly. We normally share all Stata files, the raw data files, and Stata codes with comments. The purpose is to help researchers to learn and apply these codes on their own. We also try to answer questions that might arise at a later stage when the
researcher applies these codes.


The code is available for $ $99 with some example data. The Fama and French factors are downloaded from Fama and French library. In case the Fama and French Factors need to be developed from scratch, there is an additional fee of $100.

For further details, please contact us at:

See our full list of completed projects

Project tags: Fama MacBeth, rolling window, cross-sectional regression, Fama and French, Stata , FinTechprofessor