Announcement

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

  • Comparing regression coefficients of different independent variables in separate regressions

    Dear all,

    Suppose I have the following dataset

    Code:
    input dv iv1 iv2 firmid year
    1 8 1 155 2001
    3 9 1 155 2002
    5 10 1 155 2003
    8 15 1 155 2004
    9 18 1 166 2001
    12 16 1 166 2002
    11 14 1 166 2003
    15 12 1 166 2004
    14 5 0 177 2001
    14 7 0 177 2002
    15 3 0 177 2003
    17 5 0 177 2004
    18 2 0 177 2005
    19 4 0 177 2006
    12 8 0 177 2007
    3 6 1 188 2001
    5 8 1 188 2002
    2 9 1 188 2003
    1 8 1 188 2004
    6 12 1 199 2001
    7 9 1 199 2002
    4 10 1 199 2003
    56 11 1 199 2004
    23 8 1 199 2005
    10 3 0 199 2006
    11 3 0 200 2001
    12 4 0 200 2002
    54 1 0 200 2003
    6 2 0 200 2004
    5 5 0 200 2005
    end
    I'd like to compare regression coefficients of two different independent variables (iv1 and iv2) in two separate regressions. For example:

    Code:
    reghdfe dv iv1, absorb(firmid year) vce(cluster firmid)
    reghdfe dv iv2, absorb(firmid year) vce(cluster firmid)
    I'd like to use reghdfe command instead of reg as I need to control for firm fixed effects. I'm aware that I can't use suest in this case as it doesn't capture reghdfe regression output.

    Could anyone please help me find a way to go around this problem?

    Thank you very much for your help,

    Vinh


  • #2
    reghdfe is from SSC, as you are asked to explain (see FAQ #12). For two dependent variables and the same independent variable, see
    https://www.statalist.org/forums/for...erent-outcomes

    Code:
    input dv iv1 iv2 firmid year
    1 8 1 155 2001
    3 9 1 155 2002
    5 10 1 155 2003
    8 15 1 155 2004
    9 18 1 166 2001
    12 16 1 166 2002
    11 14 1 166 2003
    15 12 1 166 2004
    14 5 0 177 2001
    14 7 0 177 2002
    15 3 0 177 2003
    17 5 0 177 2004
    18 2 0 177 2005
    19 4 0 177 2006
    12 8 0 177 2007
    3 6 1 188 2001
    5 8 1 188 2002
    2 9 1 188 2003
    1 8 1 188 2004
    6 12 1 199 2001
    7 9 1 199 2002
    4 10 1 199 2003
    56 11 1 199 2004
    23 8 1 199 2005
    10 3 0 199 2006
    11 3 0 200 2001
    12 4 0 200 2002
    54 1 0 200 2003
    6 2 0 200 2004
    5 5 0 200 2005
    end
    
    reghdfe dv iv1, absorb(firmid year) vce(cluster firmid)
    reghdfe dv iv2, absorb(firmid year) vce(cluster firmid)
    reshape long iv, i(firmid year) j(which)
    gen group= 1.which
    reghdfe dv group#(c.iv), a(firmid#group year#group) cluster(firmid)
    Res.:

    Code:
    . reghdfe dv iv1, absorb(firmid year) vce(cluster firmid)
    (dropped 1 singleton observations)
    (MWFE estimator converged in 4 iterations)
    
    HDFE Linear regression                            Number of obs   =         29
    Absorbing 2 HDFE groups                           F(   1,      5) =       0.21
    Statistics robust to heteroskedasticity           Prob > F        =     0.6650
                                                      R-squared       =     0.3091
                                                      Adj R-squared   =    -0.2091
                                                      Within R-sq.    =     0.0039
    Number of clusters (firmid)  =          6         Root MSE        =    14.3803
    
                                     (Std. Err. adjusted for 6 clusters in firmid)
    ------------------------------------------------------------------------------
                 |               Robust
              dv |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             iv1 |  -.3603447   .7838261    -0.46   0.665    -2.375234    1.654544
           _cons |   15.44132   6.135466     2.52   0.053    -.3303987    31.21304
    ------------------------------------------------------------------------------
    
    Absorbed degrees of freedom:
    -----------------------------------------------------+
     Absorbed FE | Categories  - Redundant  = Num. Coefs |
    -------------+---------------------------------------|
          firmid |         6           6           0    *|
            year |         6           0           6     |
    -----------------------------------------------------+
    * = FE nested within cluster; treated as redundant for DoF computation
    
    . 
    . reghdfe dv iv2, absorb(firmid year) vce(cluster firmid)
    (dropped 1 singleton observations)
    (MWFE estimator converged in 4 iterations)
    warning: missing F statistic; dropped variables due to collinearity or too few clusters
    
    HDFE Linear regression                            Number of obs   =         29
    Absorbing 2 HDFE groups                           F(   1,      5) =          .
    Statistics robust to heteroskedasticity           Prob > F        =          .
                                                      R-squared       =     0.3202
                                                      Adj R-squared   =    -0.1897
                                                      Within R-sq.    =     0.0199
    Number of clusters (firmid)  =          6         Root MSE        =    14.2644
    
                                     (Std. Err. adjusted for 6 clusters in firmid)
    ------------------------------------------------------------------------------
                 |               Robust
              dv |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             iv2 |       12.6   3.47e-15  3.6e+15   0.000         12.6        12.6
           _cons |   5.234483   2.09e-15  2.5e+15   0.000     5.234483    5.234483
    ------------------------------------------------------------------------------
    
    Absorbed degrees of freedom:
    -----------------------------------------------------+
     Absorbed FE | Categories  - Redundant  = Num. Coefs |
    -------------+---------------------------------------|
          firmid |         6           6           0    *|
            year |         6           0           6     |
    -----------------------------------------------------+
    * = FE nested within cluster; treated as redundant for DoF computation
    
    . 
    
    . 
    . reghdfe dv group#(c.iv), a(firmid#group year#group) cluster(firmid)
    (dropped 2 singleton observations)
    (MWFE estimator converged in 4 iterations)
    warning: missing F statistic; dropped variables due to collinearity or too few clusters
    
    HDFE Linear regression                            Number of obs   =         58
    Absorbing 2 HDFE groups                           F(   2,      5) =          .
    Statistics robust to heteroskedasticity           Prob > F        =          .
                                                      R-squared       =     0.3146
                                                      Adj R-squared   =    -0.2208
                                                      Within R-sq.    =     0.0119
    Number of clusters (firmid)  =          6         Root MSE        =    14.3225
    
                                     (Std. Err. adjusted for 6 clusters in firmid)
    ------------------------------------------------------------------------------
                 |               Robust
              dv |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
      group#c.iv |
              0  |       12.6   6.80e-15  1.9e+15   0.000         12.6        12.6
              1  |  -.3603447   .7907935    -0.46   0.668    -2.393144    1.672455
                 |
           _cons |    10.3379   3.095002     3.34   0.021     2.381944    18.29386
    ------------------------------------------------------------------------------
    
    Absorbed degrees of freedom:
    --------------------------------------------------------+
        Absorbed FE | Categories  - Redundant  = Num. Coefs |
    ----------------+---------------------------------------|
       firmid#group |        12          12           0    *|
         year#group |        12           0          12     |
    --------------------------------------------------------+
    * = FE nested within cluster; treated as redundant for DoF computation

    Comment


    • #3
      Many thanks, Andrew. Your code works perfectly.

      Cheers,

      Vinh

      Comment

      Working...
      X