Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: RE: Fama-MacBeth regression


From   Richard Herron <[email protected]>
To   [email protected]
Subject   Re: st: RE: Fama-MacBeth regression
Date   Fri, 3 Jan 2014 14:54:13 -0500

You code fails because you subset to both month *and* portfolio, which
is a regression with one data point. I would -reshape long-, then use
-statsby- to run the cross-sectional regression. You could also
-reshape long- then use -xtfmb- from SSC.

Does the following help?

* * * * *

clear

* generate test data
set obs 200
generate date = _n - 1 + ym(1987, 1)
format date %tm
foreach v of newlist bm1 bm2 bm3 size1 size2 size3 {
 generate ret`v' = 5 + 10*rnormal()
 generate beta`v' = 0.5 + runiform()
}
list in 1/10

* reshape to long
reshape long beta ret, i(date) j(portfolio) string
preserve // I'll show two ways to do the Fama-MacBeth

* then run cross-sectional regression each month
statsby, by(date) clear: regress ret beta
format date %tm
list in 1/10

* generate time series means and SEs
summarize, detail
collapse (mean) mean_beta = _b_beta ///
 mean_alpha = _b_cons ///
 (semean) se_beta = _b_beta ///
 se_alpha = _b_cons
list

* could also use xtfmb package from SSC
restore
encode portfolio, generate(p)
xtset p date
xtfmb ret beta

On Fri, Jan 3, 2014 at 2:08 PM, Francis, Richard N <[email protected]> wrote:
> Adrian,
>
> I'm sorry. Hope you find what you need!
>
> Rick Francis
> Associate Professor
> Department of Accounting
> College of Business Administration
> University of Texas at El Paso
> 500 W. University Avenue
> El Paso, TX  79968
> Office: 915-747-7953
> FAX: 915-747-8618
> Email:  [email protected]
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On Behalf Of Adrian Stork
> Sent: Friday, January 03, 2014 12:02 PM
> To: [email protected]
> Subject: Re: st: RE: Fama-MacBeth regression
>
> Dear Rick
>
> Thank you for answering. I know about that side and that code and I also would use it but unfortunately to use it I would need to get my dataset (as described below) into a panel dataset which as simple as it sounds at the beginning is not as easy because I have 306 rows (i.e. months)  and 201 columns (one column for the date, 100 columns for the portfolios, and 100 columns for the estimated coefficients from first-pass regressions). And simply reshaping does not help because it only reshapes either the portfolios or the coefficients).
> Also Mitch Petersen's fm-code does not include the first-pass regression.
>
> Best,
> Adrian
>
> 2014/1/3 Francis, Richard N <[email protected]>:
>> Adrian,
>>
>> Attached is the Stata code for the FM regression.
>>
>> Code is from Mitch Petersen (http://www.kellogg.northwestern.edu/faculty/petersen/htm/papers/se/se_programming.htm).
>>
>> Good luck!
>>
>> Rick Francis
>> Associate Professor
>> Department of Accounting
>> College of Business Administration
>> University of Texas at El Paso
>> 500 W. University Avenue
>> El Paso, TX  79968
>> Office: 915-747-7953
>> FAX: 915-747-8618
>> Email:  [email protected]
>>
>>
>> -----Original Message-----
>> From: [email protected]
>> [mailto:[email protected]] On Behalf Of Adrian
>> Stork
>> Sent: Friday, January 03, 2014 11:23 AM
>> To: [email protected]
>> Subject: st: Fama-MacBeth regression
>>
>> Dear all
>>
>> I'm trying to run a second-pass cross-sectional regression which is part of what finance researchers call a Fama-MacBeth regression.
>> I managed to get the beta-coefficients from the first-pass regression but now I'm stuck at the second-pass CSR.
>> So my dataset looks currently like this (time period starts in 1987m7 and ends 2012m12):
>>
>>
>>                    ________________portfolios________________________
>>        _________________coefficients__________________________
>>
>> date2   exsize_1        exsize_2        exsize_3        exbm_1  exbm_2  exbm_3  betaexsize_1    betaexsize_2    betaexsize_3    betaexbm_1      betaexbm_2      betaexbm_3
>> .... etc.
>> 1989m6  .31     3.41    3.10    2.83    2.25    1.02    .64     .68     .67     .63     .76     .65
>> 1989m7  1.16    1.85    4.93    9.40    3.31    4.65    .64     .68     .67     .63     .76     .65
>> 1989m8  2.45    2.94    6.85    4.50    3.82    4.76    .64     .68     .67     .63     .76     .65
>> 1989m9  -.60    1.38    -1.56   2.69    -.72    -1.38   .64     .68     .67     .63     .76     .65
>> 1989m10 -1.46   -1.41   -.89    .11     -1.25   1.89    .64     .68     .67     .63     .76     .65
>> etc.
>>
>> Now I need to regress at each individual month all the portfolios against the their estimated coefficient.
>> But that is exactly what I'm not able to manage. In the end there should be one figure at each time period t which corresponds to the new coefficient from the individual cross-sectional regressions As you can see I merely added the prefix "beta" for the coefficients with respect to its portfolio.
>>
>> The best I could come with is the following:
>>
>> .ds ex*
>>
>> .forval i=330/635{
>> .foreach v of varlist `r(varlist)' {
>> .       regress `v' beta`v' if date2==`i'
>> .       gen lambda`v' = _b[beta`v']
>> .}
>> .}
>>
>> but here the error message is "insufficient observations" although all obsevations are nonmissing.
>> I know there is a code from Kellog University
>> (http://www.kellogg.northwestern.edu/faculty/petersen/htm/papers/se/fm
>> .ado) but that does not include the first pass regression and brings
>> me to the same point. Also I want to understand the entire procedure and follow my results.
>> Thus, does anyone have an idea how to retrieve the second pass regression coefficients (the beta coefficient in the second pass regression is perfectly fine and enough - no need for the constant or the residuals right now).
>> I guess reshaping the dataset might also be an alternative beginning compared to the code I wrote above.
>>
>> Best,
>> Adrian
>> *
>> *   For searches and help try:
>> *   http://www.stata.com/help.cgi?search
>> *   http://www.stata.com/support/faqs/resources/statalist-faq/
>> *   http://www.ats.ucla.edu/stat/stata/
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index