Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Since all independent variables in your dataset are panel-invariant, asreg cannot find a way to fit a regression model. Specifically, this happens when all the independent variables are perfectly correlated. Since Fama and MacBeth's regression is a cross-sectional regression, each period the regression finds the same values for the given independent variables. Long story short, do not use FMB regressions with panel invariant variables. Even if you get some results on the screen, they are not valid. I shall change asreg in its future update to show empty values if the variables do not have variations across panels.
    Regards
    --------------------------------------------------
    Attaullah Shah, PhD.
    Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
    FinTechProfessor.com
    https://asdocx.com
    Check out my asdoc program, which sends outputs to MS Word.
    For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

    Comment


    • #17
      My goal was to run a rolling-window FMB regression using five Fama-French (2015) factors and one additional sentiment factor (all variables are cross-sectionally invariant, by the way).
      ASREG seemed to be of no help.

      Honestly, I don't get why ASREG has a fmb option, as it doesn't work correctly with some factors. Mr. Shah was not able to explain the mystery.

      In the end, I found the below code do the job:

      Code:
      forval t=1/228{
          local j=`t'+ 6
          
      quietly{
      gen beta_rmrf=.
      gen beta_smb=.
      gen beta_hml=.
      gen beta_rmw=.
      gen beta_cma=.
      gen beta_sent=.
      
      }
      
      forvalues i=1/46{
      quietly{
      reg logret rmrf if id==`i' | month>=`t' & month<=`j'
          replace beta_rmrf=_b[rmrf] if id==`i'
          
      reg logret smb  if id==`i' | month>=`t' & month<=`j'
          replace beta_smb=_b[smb] if id==`i'
          
      reg logret hml  if id==`i' | month>=`t' & month<=`j'
          replace beta_hml=_b[hml] if id==`i'
          
      reg logret rmw  if id==`i' | month>=`t' & month<=`j'
          replace beta_rmw=_b[rmw] if id==`i'
          
      reg logret cma if id==`i' | month>=`t' & month<=`j'
          replace beta_cma=_b[cma] if id==`i'
          
      reg logret sentiment if id==`i' | month>=`t' & month<=`j'
          replace beta_sent=_b[sentiment] if id==`i'
      
      }
                  
      }
          
      display _n(3) in white _col(30) "Time period:" `t' "-" `j'
      
      xtfmb logret beta_rmrf beta_smb beta_hml beta_rmw beta_cma beta_sent if month==`j'+1
      
      quietly outreg2 using sentiment_6month, append excel        
          
      drop beta_rmrf beta_smb beta_hml beta_rmw beta_cma beta_sent
      
      local j=`j'+ 1
      
      }
      
      set more on
      Last edited by Christian Backross; 18 May 2019, 05:17.

      Comment


      • #18
        Attaullah Shah Christian Backross -

        It seems possible to me that the two of you have different understandings of what constitutes "Fama-MacBeth regression". Perhaps as someone who has been trying to learn about it, I can give another perspective.

        First, I note that in post #5 we read

        both asreg and xtfmb are similar and produce the same results
        In post #17 we see that each use use of xtfmb is preceded by the series of firm-specific time series regressions to calculate the "betas" for the various independent variables, and those betas, rather than the variables themselves, become the independent variables in xtfmb. By contrast, in post #10 asreg was run directly on the data. If indeed asreg and xtfmb are similar, then perhaps asreg also does not incorporate the calculation of the betas, consistent with the description of asreg and xtfmb as similar.. And this leads me to think that there are different understandings of what constitutes the FMB technique.

        My initial understanding of the FMB technique was that demonstrated by the code in post #17, but in fact that understanding was based on the sorts of coding questions asked on Statalist by members trying to implement FMB on their own. My usual source of superficial technical understanding is Wikipedia, but it fails me in this instance with a very slender explanation that's assumes a lot of prior knowledge.

        More general searching and following links to references brought me to
        Mitchell A. Petersen, Estimating Standard Errors in Finance Panel Data Sets: Comparing Approaches, The Review of Financial Studies, Volume 22, Issue 1, January 2009, Pages 435–480, https://doi.org/10.1093/rfs/hhn053
        and I will quote the abstract in full.
        In corporate finance and asset pricing empirical work, researchers are often confronted with panel data. In these data sets, the residuals may be correlated across firms or across time, and OLS standard errors can be biased. Historically, researchers in the two literatures have used different solutions to this problem. This paper examines the different methods used in the literature and explains when the different methods yield the same (and correct) standard errors and when they diverge. The intent is to provide intuition as to why the different approaches sometimes give different answers and give researchers guidance for their use.
        where I have highlighted in bold the references to alternative models of the correlation.

        The paper is behind a paywall, but at this time simple searches turn up freely available copies. It's beyond my comprehension, but perhaps it sheds some light on the divergence of your views.

        Comment


        • #19
          Christian Backross You said that
          "My goal was to run a rolling-window FMB regression using five Fama-French (2015) factors and one additional sentiment factor (all variables are cross-sectionally invariant, by the way).
          I did not find this specification in your previous posts. Can you please point out where did you mention that you want to estimate a rolling window regression in your previous posts?

          Then you alleged
          "ASREG seemed to be of no help. Honestly, I don't get why ASREG has a fmb option, as it doesn't work correctly with some factors.
          .
          If you carefully read the asreg help file, it mentions that "

          "Option fmb applies a two-step Fama-McBeth procedure. The first step involves estimation of N cross-sectional regressions and the second step involves T time-series averages of the coefficients of the N-cross-sectional regressions. The standard errors are adjusted for cross-sectional dependence."
          What your code in #17 shows, it is more work than those two FMB steps. Rather, it involves some prior spadework before the fmb option can be used in asreg i.e. ie estimation of betas prior to using fmb option.

          Although you have already shown that you have no respect for my input, still I am daring to add the following points for those who might be interested and stumble on this post for help.

          1. First of all, your rolling window code is forward-looking, which make little sense to me. Usually, it is rare in the finance literature that betas are calculated from future returns. I hope you have a strong rationale and theoretical support for it.

          2. The window of 7 observation is too small, you must have strong support for this from the literature.

          3. The following rolling-window code is incorrect if you are doing rolling window regressions for each firm. On a strictly balanced data, the following code will include 543 observations if you have 46 companies and 228 months.

          The first line of code in the two nested loops
          Code:
           reg logret rmrf if id==`i' | month>=`t' & month<=`j'
          will translate to

          Code:
          reg logret rmrf if id==1 | month>=1 & month<=7
          which means either firm ID = 1 OR month 1 to month 7. You can see it is not a rolling-window for a single firm.

          4. Finally, the xtfmb equivalent code of asreg would be
          Code:
          asreg logret beta_rmrf beta_smb beta_hml beta_rmw beta_cma beta_sent if month==`j'+1
          5. rolling window regressions are super fast with asreg. The help file of asreg provides several examples on that. Therefore, if back-ward looking rolling window of 12 months is used with the first regression, the code would be

          Code:
          bys id : asreg logret rmrf, window(month 12)
          6. The code in #17 seems to find rolling beta separately for each factor. This is again uncommon. The Fama and French (2015) five factor model has all the factors in one model, why would someone estimate these factors separately. Therefore, the correct code for rolling window betas of the five factor model, estimated separately for each firm would be
          Code:
          bys id: asreg logret rmrf smb hml rmw cma, window( month 12)
          Last edited by Attaullah Shah; 18 May 2019, 14:57.
          Regards
          --------------------------------------------------
          Attaullah Shah, PhD.
          Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
          FinTechProfessor.com
          https://asdocx.com
          Check out my asdoc program, which sends outputs to MS Word.
          For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

          Comment


          • #20


            Originally posted by Attaullah Shah View Post
            Although you have already shown that you have no respect for my input, still I am daring to add the following points for those who might be interested and stumble on this post for help.
            I did not mean to disrespect your input. I was frustrated that asreg does not operate with cross-sectional invariant variables. But as William Lisowski correctly mentioned, we might have a divergence in the view on FMB technique.

            Originally posted by Attaullah Shah View Post
            2. The window of 7 observation is too small, you must have strong support for this from the literature.
            My data consists of daily observations.

            Originally posted by Attaullah Shah View Post
            which means either firm ID = 1 OR month 1 to month 7. You can see it is not a rolling-window for a single firm.
            Thank you, this is indeed incorrect.

            Comment


            • #21
              I will add that it appears to me that Fama-MacBeth regression is narrowly defined as a two-step process of (1) running a series of cross-sectional regressions and then (2) doing something further using those results that I'm not clear about. And both xtfmb and asreg implement this definition of Fama-MacBeth regression.

              However, the Fama-MacBeth regression technique is commonly the final step in techniques (often including the name Fama) that begin with the estimation of firm-specific betas, and the two techniques become confused. This is especially true for students newly introduced to the broader techniques that involve first calculating the betas, based on earlier questions posted on Statalist. For example at post #5 here

              https://www.statalist.org/forums/for...73#post1488673

              the author seems to imply the estimation of the betas is part of the definition of FMB. That assertion stayed with me and led to the confusion I expressed in post #18.

              So although xtfmb includes "fmb" in its name, and asreg includes an "fmb" option, in both cases that signifies the implementation of Fama-MacBeth regression, not the broader technique. And as Prof. Shaw correctly points out FMB starts with cross-sectional regressions that preclude using cross-sectionally invariant data. It's the prior calculation and use of the firm-specific betas that make FMB regression - through xtfmb or through asreg - feasible as part of - but not all of - the broader technique.

              Comment


              • #22
                Originally posted by William Lisowski View Post
                So although xtfmb includes "fmb" in its name, and asreg includes an "fmb" option, in both cases that signifies the implementation of Fama-MacBeth regression, not the broader technique. And as Prof. Shaw correctly points out FMB starts with cross-sectional regressions that preclude using cross-sectionally invariant data. It's the prior calculation and use of the firm-specific betas that make FMB regression - through xtfmb or through asreg - feasible as part of - but not all of - the broader technique.
                Thank you! If I got it right, the confusion comes from the fact that I expected asreg to calculate the betas for me.

                I replaced the xtfmb command with asreg as follows:
                Code:
                set more off
                forval t=1/228{
                    local j=`t'+ 2
                    
                quietly{
                gen beta_rmrf=.
                gen beta_smb=.
                gen beta_hml=.
                gen beta_rmw=.
                gen beta_cma=.
                gen beta_sent=.
                
                }
                
                forvalues i=1/46{
                quietly{
                capture{
                reg logret rmrf if id==`i' & (month>=`t' & month<=`j')
                    replace beta_rmrf=_b[rmrf] if id==`i'
                    
                reg logret smb  if id==`i' & (month>=`t' & month<=`j')
                    replace beta_smb=_b[smb] if id==`i'
                    
                reg logret hml  if id==`i' & (month>=`t' & month<=`j')
                    replace beta_hml=_b[hml] if id==`i'
                    
                reg logret rmw  if id==`i' & (month>=`t' & month<=`j')
                    replace beta_rmw=_b[rmw] if id==`i'
                    
                reg logret cma if id==`i' & (month>=`t' & month<=`j')
                    replace beta_cma=_b[cma] if id==`i'
                    
                reg logret sentiment if id==`i' & (month>=`t' & month<=`j')
                    replace beta_sent=_b[sentiment] if id==`i'
                
                }
                }
                            
                }
                    
                display _n(3) in white _col(30) "Time period:" `t' "-" `j'
                
                asreg logret beta_rmrf beta_smb beta_hml beta_rmw beta_cma beta_sent if month==`j', fmb
                
                quietly outreg2 using fmb_1by1_month_sentiment_v2_6month, append excel        
                    
                drop beta_rmrf beta_smb beta_hml beta_rmw beta_cma beta_sent
                
                local j=`j'+ 1
                
                }
                
                set more on
                This code provides identical results to the one in post #17. Although asreg is indeed faster than xtfmb, the speed does not improve noticeably in my case. Is there a way to make my code more efficient?
                Last edited by Christian Backross; 19 May 2019, 08:38.

                Comment


                • #23
                  I expect that using the single asreg command to do your rolling regressions, estimating all your firm-specific betas for all windows and all firms in a single command, as suggested in item 6 of post #19, would result in further efficiencies.

                  The fact that you have daily data but want to run your regressions on monthly windows gives me pause, however. Remember, I'm not an actual econometrician, and I have never knowingly used any of the methodology discussed in the current topic.

                  Comment


                  • #24
                    Originally posted by William Lisowski View Post
                    I expect that using the single asreg command to do your rolling regressions, estimating all your firm-specific betas for all windows and all firms in a single command, as suggested in item 6 of post #19, would result in further efficiencies.

                    The fact that you have daily data but want to run your regressions on monthly windows gives me pause, however. Remember, I'm not an actual econometrician, and I have never knowingly used any of the methodology discussed in the current topic.

                    I am a bit confused. Using item 6 of post #19 only generates risk betas. My ultimate goals is to calculate rolling-window lambdas (risk premia),and asreg therefore only provides betas. How do I get the second part using asreg?
                    Last edited by Christian Backross; 19 May 2019, 10:07.

                    Comment


                    • #25
                      Having first used asreg to generate the risk betas (replacing your looping over firms and windows of time), you then use asreg with the risk betas as the independent variables in a series of FMB regressions. Schematically, I think the idea is to do something like
                      Code:
                      bysort id: asreg logret rmrf smb hml rmw cma, window( month 3)
                      rename (_b_*) (beta_*)
                      forvalue j=3/230 {
                      asreg logret beta_rmrf beta_smb beta_hml beta_rmw beta_cma beta_sent if month==`j', fmb
                      outreg2 ...
                      }
                      but again I am not an econometrician and I understand neither your data nor your methodology.

                      Comment


                      • #26
                        Originally posted by William Lisowski View Post
                        I expect that using the single asreg command to do your rolling regressions, estimating all your firm-specific betas for all windows and all firms in a single command, as suggested in item 6 of post #19, would result in further efficiencies.

                        The fact that you have daily data but want to run your regressions on monthly windows gives me pause, however. Remember, I'm not an actual econometrician, and I have never knowingly used any of the methodology discussed in the current topic.
                        I think I got it!

                        The following code
                        Code:
                        bys id: asreg logret rmrf smb hml rmw cma sentiment
                        
                        drop _R2 _adjR2
                        
                        asreg logret _b_cma  _b_hml _b_rmrf _b_rmw _b_sentiment _b_smb, fmb

                        ...provides same output as:
                        Code:
                        quietly{
                        gen beta_rmrf=. 
                        gen beta_smb=.
                        gen beta_hml=. 
                        gen beta_rmw=.
                        gen beta_cma=.
                        gen beta_sent=.
                        
                        }
                        
                        forvalues i=1/59{ 
                        quietly{
                        
                        reg logret rmrf smb hml rmw cma sentiment if id==`i' 
                        replace beta_rmrf=_b[rmrf] if id==`i'
                        replace beta_smb=_b[smb] if id==`i'
                        replace beta_hml=_b[hml] if id==`i'
                        replace beta_rmw=_b[rmw] if id==`i'
                        replace beta_cma=_b[cma] if id==`i'
                        replace beta_sent=_b[sentiment] if id==`i'
                        }
                        }
                        
                        xtfmb logret beta_rmrf beta_smb beta_hml beta_rmw beta_cma beta_sent
                        The only thing left is to add rolling window option.

                        Thank you, Attaullah Shah for spotting several mistakes in my code and thank you, William Lisowski, for identifying the main cause of my confusion.

                        Comment


                        • #27
                          Christian Backross I had the same issue as you and this post was incredibly helpful. I used
                          Code:
                           
                           bys id: asreg logret rmrf smb hml rmw cma sentiment  drop _R2 _adjR2  asreg logret _b_cma  _b_hml _b_rmrf _b_rmw _b_sentiment _b_smb, fmb
                          And was able to get a fmb output for each variable and the fama french factors. But what would you need a rolling window now? and how do you specify it? Best, Juana

                          Comment


                          • #28
                            William Lisowski Maybe you can enlighten me?

                            Comment

                            Working...
                            X