Fama and MacBeth (1973) Two-Pass Regressions
Fama and MacBeth (1973) Two-Pass Regressions
Are there any RATS examples for estimating two-pass (2-step) regressions as in Fama and MacBeth (1973) "Risk, Return and Equilibirum: Empirical Tests", Journal of Political Economy, 81, 607-636?
Thanks.
Thanks.
Re: Fama and MacBeth (1973) Two-Pass Regressions
Code: Select all
*
* Example of a simple Fama-Macbeth regression with one factor
*
* Sample Data set from
* http://www.kellogg.northwestern.edu/faculty/petersen/htm/papers/se/se_programming.htm
*
open data "famamacbethset.txt"
*
compute nfirm=500
compute ntime=10
*
calendar(panelobs=ntime)
data(format=prn,nolabels,org=columns) 1//1 nfirm//ntime id time x y
*
* Cross section regressions at each point in time
* NF is the number of factors
*
compute nf=1
dec vect[series] b(nf+1)
clear(zeros) b
*
do tt=1,ntime
linreg(noprint,smpl=%period(t)==tt) y
# constant x
compute %pt(b,tt,%beta)
end do i
*
* Compute statistics on the components of b. This will give the same result as
* doing a STATISTICS instruction, but the LINREG form will allow you to do HAC
* standard errors if you want.
*
linreg b(1) 1 ntime
# constant
linreg b(2) 1 ntime
# constant
Re: Fama and MacBeth (1973) Two-Pass Regressions
Hi Tom, I am sorry to ask question here again. I have a sample of 2 portfolio returns from 1965:08 to 2007:12, 509 observations. I would like to apply the Two-Pass regressions to the sample data. I think I figure out the code for the first pass, the time series regressions, However, my question is how to do the second pass, the cross-section regressions, with the time series sample data. Could you please kindly take a look my code and share some tips on how to proceed the second pass with me? Many Thanks
Code: Select all
dec vect[series] b(2)
clear(zeros) b
linreg r1
# constant mktrf
compute %pt(b,509,%beta)
set b11 = 509*b(1), b12 = 509*b(2)
dec vect[series] c(2)
clear(zeros) c
linreg r2
# constant mktrf
compute %pt(c,509,%beta)
set b21 = 509*c(1), b22 = 509*c(2)
- Attachments
-
- model.pdf
- (500.97 KiB) Downloaded 1471 times
Re: Fama and MacBeth (1973) Two-Pass Regressions
The example I posted above starts with the cross section regressions.
Re: Fama and MacBeth (1973) Two-Pass Regressions
hi Tom. Thank you for the reply. The example code you posted is for cross-sectional data. I am not sure how I can modify the code to fit time-series data. Could you please kindly share some tips on how to do cross-section regression in time series data with me? Many ThanksTomDoan wrote:The example I posted above starts with the cross section regressions.
Re: Fama and MacBeth (1973) Two-Pass Regressions
It's for panel data. The first step is a set of cross sectional regressions, one for each time period. Isn't that what you need?fan wrote:hi Tom. Thank you for the reply. The example code you posted is for cross-sectional data. I am not sure how I can modify the code to fit time-series data. Could you please kindly share some tips on how to do cross-section regression in time series data with me? Many ThanksTomDoan wrote:The example I posted above starts with the cross section regressions.
Re: Fama and MacBeth (1973) Two-Pass Regressions
Hi Tom, thank you for the reply. It is my mistake. I actually mean that your sample code is for panel data and it gives the cross sectional regressions, one for each time period as you mentioned. What I am really trying to ask is how I can modify the code so that it can do the same job for time series data. So far, I kind of know how to do the time series regressions and save the coefficients as series in the first pass with time series data; however, I am not clear how to do the cross sectional regressions, one for each time period, using the estimated coefficients from the first pass as independent variables in the second pass. I know loops for dates are needed but I am not sure whether loops for series are also needed. My guess is that loops for series is not needed as what I want is coefficients from a cross-section regression at time t, not the averages of coefficients from 2 individual regressions at time t. The attachment is the sample data I am using. I am looking forward to hearing from you. Many ThanksTomDoan wrote:It's for panel data. The first step is a set of cross sectional regressions, one for each time period. Isn't that what you need?fan wrote:hi Tom. Thank you for the reply. The example code you posted is for cross-sectional data. I am not sure how I can modify the code to fit time-series data. Could you please kindly share some tips on how to do cross-section regression in time series data with me? Many ThanksTomDoan wrote:The example I posted above starts with the cross section regressions.
- Attachments
-
- examplesample.xlsx
- (26.05 KiB) Downloaded 1386 times
Re: Fama and MacBeth (1973) Two-Pass Regressions
So far as I can tell, you don't have anything approaching the type of data for doing Fama-French or Fama-MacBeth regressions. The cross section stage in Fama-MacBeth regresses returns on betas across N assets at a given point in time. You have returns but not betas and even if you had it, N=2 isn't going to be very interesting, since you get a perfect fit.
Re: Fama and MacBeth (1973) Two-Pass Regressions
hi Tom, Thank you for the reply. I actually have returns on the 25 portfolios formed by market size and book-to-market ratio and the three risk factors, market return, SMB and HML, from French data library for the period from 1965:08 to 2007:12. I generated the betas for each portfolio from the time series regressions and saved the coefficients as series in the first pass; now, I am trying to do the cross-section regressions, regressing returns on the estimated betas across the 25 portfolios at a given point in time. My question is how I can do the cross-section if the data sample is time series, not panel. Could you please kindly advice me how to proceed the cross-section regressions in the second pass with time series data? Many ThanksTomDoan wrote:So far as I can tell, you don't have anything approaching the type of data for doing Fama-French or Fama-MacBeth regressions. The cross section stage in Fama-MacBeth regresses returns on betas across N assets at a given point in time. You have returns but not betas and even if you had it, N=2 isn't going to be very interesting, since you get a perfect fit.
The attached are my example code for the time series regressions in the first pass and the sample data I have
Code: Select all
dec vect[series] bi(4)
clear(zeros) bi
linreg ri
# constant mktrf smb hml
compute %pt(b,509,%beta)
set bi1 = 509*bi(1), bi2 = 509*bi(2), bi3 = 509*bi(3), bi4 = 509*bi(4)
* i=1,...,25
- Attachments
-
- sample data.xlsx
- (124.37 KiB) Downloaded 1410 times
Re: Fama and MacBeth (1973) Two-Pass Regressions
Basically any "large T" panel data set is formed by stacking time series data (separate securities, exchange rates, firms, etc.). The reason for organizing the data set as a panel is rather clear in this case since you need to run regressions in both dimensions. There is no set command for running a regression across time series treating each series as an "observation". You can do such a regression "by hand" by using MAKE to create the required matrices or vectors---that's in effect what the Gauss code does by taking slices out of the data array. However, given that I've already posted an example of how to do the analysis using panel data, the simplest approach is simply to use PFORM to reformat the data into a panel data set and not reinvent the wheel.
Re: Fama and MacBeth (1973) Two-Pass Regressions
Hi Tom. Thank you for your reply. Just to check my understanding, you are suggesting to reformat the data into a panel data set after generating the betas from the time-series regressions in the first pass, right? In my actual study, the risk factors are unobserved and extracted from Kalman filter process. So I think it will be easier for me to run the time series regressions when the data is in time-series set and then reformate the data into a panel set for the second step regression in the Fama-MacBeth two-pass regressions. Could you please kindly let me know if my understanding is incorrect? Many ThanksTomDoan wrote:Basically any "large T" panel data set is formed by stacking time series data (separate securities, exchange rates, firms, etc.). The reason for organizing the data set as a panel is rather clear in this case since you need to run regressions in both dimensions. There is no set command for running a regression across time series treating each series as an "observation". You can do such a regression "by hand" by using MAKE to create the required matrices or vectors---that's in effect what the Gauss code does by taking slices out of the data array. However, given that I've already posted an example of how to do the analysis using panel data, the simplest approach is simply to use PFORM to reformat the data into a panel data set and not reinvent the wheel.
Re: Fama and MacBeth (1973) Two-Pass Regressions
Yes. I think that would be simplest.
Re: Fama and MacBeth (1973) Two-Pass Regressions
Hi, Tom. I tried to reformat the data into a panel data set after generating the betas from the time-series regressions. However, I got an error message which says " IO 43. Format EXCEL 2007 is illegal or not supported.' I am not sure what caused the error as I followed the examples in the reference manual. Could you please kindly take a look my code and let me know what I did wrong? Many ThanksTomDoan wrote:Yes. I think that would be simplest.
Code: Select all
OPEN DATA "C:\Users\Sam\Desktop\EW-2X3.xlsx"
CALENDAR(M) 1965:8
DATA(FORMAT=XLSX,ORG=COLUMNS) 1965:08 2007:12 Term Default Divyield tbill Divsp5 SENT1 SENT2 DSENT1 DSENT2 $
II sl sm sh bl bm bh mktrf SMB HML demo yr34
dec vect[series] bsl(4)
clear(zeros) bsl
linreg sl
# constant mktrf smb hml
compute %pt(bsl, 509, %beta)
set bsl1 = 509*bsl(1)
set bsl2 = 509*bsl(2)
set bsl3 = 509*bsl(3)
set bsl4 = 509*bsl(4)
dec vect[series] bsm(4)
clear(zeros) bsm
linreg sm
# constant mktrf smb hml
compute %pt(bsm, 509, %beta)
set bsm1 = 509*bsm(1)
set bsm2 = 509*bsm(2)
set bsm3 = 509*bsm(3)
set bsm4 = 509*bsm(4)
dec vect[series] bsh(4)
clear(zeros) bsh
linreg sh
# constant mktrf smb hml
compute %pt(bsh, 509, %beta)
set bsh1 = 509*bsh(1)
set bsh2 = 509*bsh(2)
set bsh3 = 509*bsh(3)
set bsh4 = 509*bsh(4)
dec vect[series] bbl(4)
clear(zeros) bbl
linreg bl
# constant mktrf smb hml
compute %pt(bbl, 509, %beta)
set bbl1 = 509*bbl(1)
set bbl2 = 509*bbl(2)
set bbl3 = 509*bbl(3)
set bbl4 = 509*bbl(4)
dec vect[series] bbm(4)
clear(zeros) bbm
linreg bm
# constant mktrf smb hml
compute %pt(bbm, 509, %beta)
set bbm1 = 509*bbm(1)
set bbm2 = 509*bbm(2)
set bbm3 = 509*bbm(3)
set bbm4 = 509*bbm(4)
dec vect[series] bbh(4)
clear(zeros) bbh
linreg bh
# constant mktrf smb hml
compute %pt(bbh, 509, %beta)
set bbh1 = 509*bbh(1)
set bbh2 = 509*bbh(2)
set bbh3 = 509*bbh(3)
set bbh4 = 509*bbh(4)
pform returns
# sl sm sh bl bm bh
pform factor1
# bsl1 bsm1 bsh1 bbl1 bbm1 bbh1
pform factor2
# bsl2 bsm2 bsh2 bbl2 bbm2 bbh2
pform factor3
# bsl3 bsm3 bsh3 bbl3 bbm3 bbh3
pform factor4
# bsl4 bsm4 bsh4 bbl4 bbm4 bbh4
cal(panelobs=%nobs) 1965 8 12
copy(format=xlsx,org=cols) / returns factor1 factor2 factor3 factor4
Re: Fama and MacBeth (1973) Two-Pass Regressions
FORMAT=XLSX isn't available on COPY until version 9.
What do you think this is doing? I can't make any sense out of it.
dec vect[series] bsl(4)
clear(zeros) bsl
linreg sl
# constant mktrf smb hml
compute %pt(bsl, 509, %beta)
set bsl1 = 509*bsl(1)
set bsl2 = 509*bsl(2)
set bsl3 = 509*bsl(3)
set bsl4 = 509*bsl(4)
What do you think this is doing? I can't make any sense out of it.
dec vect[series] bsl(4)
clear(zeros) bsl
linreg sl
# constant mktrf smb hml
compute %pt(bsl, 509, %beta)
set bsl1 = 509*bsl(1)
set bsl2 = 509*bsl(2)
set bsl3 = 509*bsl(3)
set bsl4 = 509*bsl(4)
Re: Fama and MacBeth (1973) Two-Pass Regressions
Hi Tom. Thank you for the quick reply.TomDoan wrote:FORMAT=XLSX isn't available on COPY until version 9.
What do you think this is doing? I can't make any sense out of it.
dec vect[series] bsl(4)
clear(zeros) bsl
linreg sl
# constant mktrf smb hml
compute %pt(bsl, 509, %beta)
set bsl1 = 509*bsl(1)
set bsl2 = 509*bsl(2)
set bsl3 = 509*bsl(3)
set bsl4 = 509*bsl(4)
Code: Select all
dec vect[series] bsl(4)
* I try to create a 4x1 vector (bsl(4)) to store the coefficients for portfolio sl and save the coefficients as series
clear(zeros) bsl
* the initial values for the vector are zero
linreg sl
# constant mktrf smb hml
compute %pt(bsl, 509, %beta)
* I try to save the estimated betas from the time-series regression into series. The time period is from 1965:08 to 2007:12, it has 509 time observations.
set bsl1 = 509*bsl(1)
set bsl2 = 509*bsl(2)
set bsl3 = 509*bsl(3)
set bsl4 = 509*bsl(4)
* I found that coefficients value saved in bsl are 1 509th of the original coefficients, so I multiply them by 509.
Last edited by fan on Mon Nov 24, 2014 11:22 pm, edited 2 times in total.