Announcement

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

  • How to run reghdfe with constraints?

    Hello

    Is there an efficient way to run a regression with constraints and fixed effects. The basic way would be

    Code:
    constraint define 1 lemp1 = lppent1
    cnsreg lsales lemp1 lppent1 i.gvkey, constraints(1)
    where gvkey is fixed effect. But if using large panel data and running many regressions this can take quite some time. Is there a work around to use constraints with reghdfe such that

    Code:
    constraint define 1 lemp1 = lppent1
    reghdfe lsales lemp1 lppent1 , ab(gvkey) constraints(1)
    I'm sure there's not, but thought I might ask

    Thanks!!
    Last edited by Tallon Trent Howie; 11 Nov 2022, 07:47.

  • #2
    No. Why would you want this?

    Comment


    • #3
      For convenience. Reghdfe works much better with fixed effects models. I have a large firm panel dataset using many many firm fixed effects, which will take some time to run.

      Comment


      • #4
        Yeah but this doesn't explain why you'd want constraints

        Comment


        • #5
          I don't show in my example, but I am estimating a model with distirbuted lags where I impose a constraint on the parameters such that the lagged coefficients converge to zero.

          Comment


          • #6
            Originally posted by Tallon Trent Howie View Post
            For convenience. Reghdfe works much better with fixed effects models. I have a large firm panel dataset using many many firm fixed effects, which will take some time to run.
            If you have only one fixed effects dimension, use xtdata to demean the data and then cnsreg. But from -help xtdata- note that:

            2. Using regress after xtdata, fe, produces standard errors that are too small, but only slightly.
            Code:
            webuse grunfeld, clear
            constraint define 1 mvalue = kstock
            cnsreg invest mvalue kstock i.company, constraints(1)
            xtset company
            xtdata, fe
            cnsreg invest mvalue kstock, constraints(1)
            Res.:

            Code:
            . cnsreg invest mvalue kstock i.company, constraints(1)
            
            Constrained linear regression                   Number of obs     =        200
                                                            F(  10,    189)   =     230.25
                                                            Prob > F          =     0.0000
                                                            Root MSE          =    61.2924
            
             ( 1)  mvalue - kstock = 0
            ------------------------------------------------------------------------------
                  invest |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
            -------------+----------------------------------------------------------------
                 mvalue |    .183188   .0090645    20.21   0.000     .1653073    .2010686
                  kstock |    .183188   .0090645    20.21   0.000     .1653073    .2010686
                         |
                 company |
                      2  |   299.9202   31.33057     9.57   0.000     238.1177    361.7228
                      3  |  -21.96814   30.80068    -0.71   0.477    -82.72542    38.78913
                      4  |   241.5989   42.46122     5.69   0.000     157.8401    325.3577
                      5  |   234.9042   43.23907     5.43   0.000      149.611    320.1974
                      6  |   264.0667   44.81864     5.89   0.000     175.6577    352.4758
                      7  |   267.1354   45.30484     5.90   0.000     177.7673    356.5035
                      8  |   208.9744   42.92889     4.87   0.000      124.293    293.6557
                      9  |   230.8704   43.94287     5.25   0.000     144.1889    317.5519
                     10  |   293.6779   48.50604     6.05   0.000     197.9952    389.3607
                         |
                   _cons |  -304.6737    47.1958    -6.46   0.000    -397.7719   -211.5755
            ------------------------------------------------------------------------------
            
            .
            . xtdata, fe
            
            .
            . cnsreg invest mvalue kstock, constraints(1)
            
            Constrained linear regression                   Number of obs     =        200
                                                            F(   1,    198)   =     427.87
                                                            Prob > F          =     0.0000
                                                            Root MSE          =    59.8832
            
             ( 1)  mvalue - kstock = 0
            ------------------------------------------------------------------------------
                  invest |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
            -------------+----------------------------------------------------------------
                 mvalue |    .183188   .0088561    20.68   0.000     .1657235    .2006524
                  kstock |    .183188   .0088561    20.68   0.000     .1657235    .2006524
                   _cons |  -102.7557   12.74774    -8.06   0.000    -127.8945   -77.61695
            ------------------------------------------------------------------------------
            
            .

            Comment


            • #7
              Thanks Andrew! I think this will work just fine. I am most concerned about prediction so I think the standard errors will be less of a concern, thanks for the heads up.

              Comment

              Working...
              X