Background
Fama Macbeth procedure is proposed by Fama and Macbeth(1973). It is an alternative way to ran cross-section regression.
Procedure
There are three steps to obtain the Fama Macbeth regression estimates and test statistics: obtain betas with time-series regression for each firm, do cross-sectional regression for each date, and conduct newey-west adjustments for standard error. The following three subsection describe them, respetively.
Rolling Betas
Time-series regression to get betas[1]
Where refers to the stock return of firm at time . represents a factor that affect , and is the estimated coefficient on factor .
Genernally, estimating the model involves using rolling regressions with historic data. For example,a dataset includes 50 stocks with each stock has 36-month observations with variables: stock return, factor 1, 2, 3. If we require the number of observations for estimating beta1,2,3 is 24. Then for each firm at month , the monthly observation used to estimate the beta is from to .
Now, How do we achieve calculating So the input dataset looks like
gvkey | date | return | factor1 | factor2 |
---|---|---|---|---|
000001 | 01/31/1963 | 0.0345 | 0.8 | 0.2 |
... | ... | ... | ... | ... |
000001 | 10/31/2017 | 0.0345 | 0.7 | 0.3 |
000002 | 01/31/1963 | 0.0789 | 0.5 | 0.3 |
... | ... | ... | ... | ... |
000002 | 12/31/1989 | 0.0121 | 0.4 | 0.6 |
... | ... | ... | ... | ... |
Calculate Rolling Betas with SAS
a. Rolling beta estimation with Macro. In chapter 4 of Boehmer,Broussard, and Kallunki(2002)[2], they employ macro to achieve rolling regression and get betas. The first step is to construct a dataset called good data with additional variable n
data gooddata;
set msf8;
by gvkey;
n+1;
if first.gvkey then n =1;
run;
gvkey | date | return | factor1 | factor2 | n |
---|---|---|---|---|---|
000001 | 01/31/2014 | 0.0345 | 0.8 | 0.2 | 1 |
... | ... | ... | ... | ... | ... |
000001 | 10/31/2017 | 0.0345 | 0.7 | 0.3 | 46 |
000002 | 01/31/1963 | 0.0789 | 0.5 | 0.3 | 1 |
... | ... | ... | ... | ... | ... |
000002 | 12/31/1989 | 0.0121 | 0.4 | 0.6 | 624 |
... | ... | ... | ... | ... | ... |
%MACRO estim; /* begin macro definition */
%do X = 50 %to 66;
DATA temp;
SET gooddata;
if &X - 49 <= N <= &X;
per = &x;
PROC REG DATA = temp NOPRINT OUTEST = results;
MODEL r = rm;
BY firm per;
quit;
PROC APPEND BASE = betas1 DATA = results;
%end;
%mend estim; /* end macro definition */
%estim; /* execute macro */
b. Rolling regressions without macros. André de Souza provides a approach to do rolling regression without invoke macros. The basic idea is to construct a dataset that can be used with proc reg directly. You click the link for more detail.
Calculate Rolling Betas with Python
Step2: Cross-sectional regressions
Cross-ection regression at each time period
How many firms are needed for cross sectional regression.
Averaging across time to get the final estimates
Step3: Newey West Adjusted Standard Error
Reference
[1] This procedure part is constructed based on Johan Cochrane Teaching Notes.
[2]Boehmer, E., Broussard, J. P., & Kallunki, J. P. (2002). Using SAS in financial research. SAS Institute.