Announcement

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

  • De-trending Panel Data

    Hi everyone,
    I need help with detrending panel data.
    I have a panel of firm observations across years and industries. I want to detrend the performance variable (ROA) to remove year and industry effects so i can use the detrennded variable on the left hand side of another model that does not work well with controls, thus requiring ex-ante detrending.

    My idea was to simply run the following code, essentially regressing ROA on a set of multiplicative year X industry dummies, and use the residuals as the detrended variable.
    Code:
    gen indxyear=ind*year
    tab indxyear, gen(trenddummy)
    reghdfe roa trenddummy*, nosample fastregress residual(res_roa)
    I am posting data below. The variables are id, year, ROA and industry designator, in that order. Thanks for the help!

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input long id double year float(roa ind)
    1380 1992  .020091366 3
    1380 1993 -.010184983 3
    1380 1994   .04607277 3
    1380 1995   .03616318 3
    1380 1996   .06704622 3
    1380 1997  .029870747 3
    1380 1998   -.0048403 3
    1408 1992   .11132794 1
    1408 1993   .08327315 1
    1408 1994    .1268582 1
    1408 1995    .1289832 1
    1408 1996   .11449675 1
    1408 1997   .08191574 1
    1408 1998   .08418822 1
    1609 1992  .036867816 3
    1609 1993    .0833743 3
    1609 1994   .06494747 3
    1609 1995    .0918747 3
    1609 1996   .11155763 3
    1609 1997   .10006464 3
    1661 1992   .10992254 3
    1661 1993   .07423703 3
    1661 1994    .0861485 3
    1661 1995   .10034772 3
    1661 1996   .08848996 3
    1661 1997   .12681246 3
    1661 1998   .12572937 3
    1663 1992   .16850606 1
    1663 1993    .1633135 1
    1663 1994   .17193583 1
    1663 1995   .16928685 1
    1663 1996   .19391987 1
    1663 1997    .1750646 1
    1663 1998   .17023782 1
    1678 1992   .06116251 3
    1678 1993   .05108807 3
    1678 1994   .04647045 3
    1678 1995   .04226407 3
    1678 1996   .07594678 3
    1678 1997   .08104512 3
    1678 1998 -.029105654 3
    1722 1993   .08783213 1
    1722 1994   .08761986 1
    1722 1995   .12433536 1
    1722 1996   .08750617 1
    1722 1997   .07014403 1
    1722 1998   .05553664 1
    end

  • #2
    Originally posted by John Schawrz View Post
    I have a panel of firm observations across years and industries. I want to detrend the performance variable (ROA) to remove year and industry effects so i can use the detrended variable on the left hand side of another model that does not work well with controls, thus requiring ex-ante detrending.
    What does "does not work well with controls" mean? You cannot include right-hand side (RHS) variables? Then what do you intend to achieve with the second model if that is the case. The issue with your logic is that the outcome variable will be detrended, but the RHS variables in the second model will not. If you want to detrend and then estimate, you need to remove the trend from all included variables. Also note that the standard errors need to be corrected in the case of generated regressors.

    Code:
    webuse grunfeld, clear
    *PARTIAL OUT FEs IN INVEST
    qui regress invest i.company i.year
    predict res1, res
    *PARTIAL OUT FEs IN KSTOCK
    qui regress kstock i.company i.year
    predict res2, res
    *ESTIMATE: SEs NOT CORRECTED
    regress res1 res2
    
    *XTREG WITH FEs
    xtset company year
    xtreg invest kstock i.year, fe
    See Frisch and Waugh's Econometrica paper for some discussion on these issues.


    Res.:

    Code:
    . *ESTIMATE: SEs NOT CORRECTED
    
    .
    . regress res1 res2
    
          Source |       SS           df       MS      Number of obs   =       200
    -------------+----------------------------------   F(1, 198)       =    295.52
           Model |  967447.422         1  967447.422   Prob > F        =    0.0000
        Residual |  648201.345       198  3273.74417   R-squared       =    0.5988
    -------------+----------------------------------   Adj R-squared   =    0.5968
           Total |  1615648.77       199  8118.83802   Root MSE        =    57.217
    
    ------------------------------------------------------------------------------
            res1 |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
           res2 |   .4138018   .0240714    17.19   0.000     .3663326     .461271
           _cons |  -1.95e-07   4.045828    -0.00   1.000    -7.978443    7.978443
    ------------------------------------------------------------------------------
    
    .
    .
    .
    . *XTREG WITH FEs
    
    .
    . xtset company year
           panel variable:  company (strongly balanced)
            time variable:  year, 1935 to 1954
                    delta:  1 year
    
    .
    . xtreg invest kstock i.year, fe
    
    Fixed-effects (within) regression               Number of obs     =        200
    Group variable: company                         Number of groups  =         10
    
    R-sq:                                           Obs per group:
         within  = 0.7112                                         min =         20
         between = 0.4120                                         avg =       20.0
         overall = 0.4624                                         max =         20
    
                                                    F(20,170)         =      20.93
    corr(u_i, Xb)  = 0.1853                         Prob > F          =     0.0000
    
    ------------------------------------------------------------------------------
          invest |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
          kstock |   .4138018   .0259782    15.93   0.000     .3625204    .4650833
                 |
            year |
           1936  |   23.94048   27.61676     0.87   0.387    -30.57546    78.45642
           1937  |    32.9483   27.63513     1.19   0.235    -21.60391    87.50051
           1938  |  -27.09347   27.68756    -0.98   0.329    -81.74918    27.56224
    Last edited by Andrew Musau; 28 Aug 2022, 12:25.

    Comment


    • #3
      Thank you for your help. The methodology in question is a variance decomposition that uses event-based studies to decompose variance on the left hand side. The standard implementation does not use controls, hence the need to detrend upfront. In my case, I will use the residuals in a robustness analysis, not the benchmark specification since I am aware of the issues with using generated regressors.

      Comment


      • #4
        Bump.

        Comment

        Working...
        X