Announcement

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

  • names of interacting variables

    Hello all,

    I am estimating a regression model with interactions as below:

    eststo: reghdfe y i.x1##i.x2##c.x3, ab() cl()

    This model would include as regressors x1,x2,x3, x1*x2, x1*x3, x2*x3 and x1*x2*x3 (7 variables).

    I am trying to export the results into a Latex table, but I don't want all the variables to be included.

    How can I see how Stata names all these interaction variables so that I can choose the ones I want?

    Thank you

    Costas

  • #2
    Costas:
    you can inspect the name of the coefficienst via -mat list e(b)-:
    Code:
    . use "https://www.stata-press.com/data/r18/nlswork.dta"
    (National Longitudinal Survey of Young Women, 14-24 years old in 1968)
    
    . reghdfe ln_wage c.age##c.age i.year, abs(idcode) vce(cluster idcode)
    (dropped 551 singleton observations)
    (MWFE estimator converged in 1 iterations)
    
    HDFE Linear regression                            Number of obs   =     27,959
    Absorbing 1 HDFE group                            F(  16,   4158) =      79.11
    Statistics robust to heteroskedasticity           Prob > F        =     0.0000
                                                      R-squared       =     0.6593
                                                      Adj R-squared   =     0.5995
                                                      Within R-sq.    =     0.1162
    Number of clusters (idcode)  =      4,159         Root MSE        =     0.3013
    
                                 (Std. err. adjusted for 4,159 clusters in idcode)
    ------------------------------------------------------------------------------
                 |               Robust
         ln_wage | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
             age |   .0728746   .0136873     5.32   0.000     .0460402    .0997089
                 |
     c.age#c.age |  -.0010113   .0001076    -9.39   0.000    -.0012224   -.0008003
                 |
            year |
             69  |   .0647054   .0155252     4.17   0.000     .0342677    .0951432
             70  |   .0284423   .0264645     1.07   0.283    -.0234422    .0803268
             71  |   .0579959   .0384118     1.51   0.131    -.0173118    .1333037
             72  |   .0510671   .0502685     1.02   0.310    -.0474861    .1496203
             73  |   .0424104   .0624936     0.68   0.497    -.0801104    .1649313
             75  |   .0151376   .0862297     0.18   0.861    -.1539187    .1841939
             77  |   .0340933   .1106863     0.31   0.758    -.1829111    .2510976
             78  |   .0537334   .1232256     0.44   0.663    -.1878546    .2953214
             80  |   .0369475   .1473754     0.25   0.802    -.2519871    .3258822
             82  |   .0391687   .1715655     0.23   0.819    -.2971914    .3755288
             83  |    .058766   .1836122     0.32   0.749    -.3012121    .4187442
             85  |   .1042758    .208024     0.50   0.616    -.3035625     .512114
             87  |   .1242272   .2327373     0.53   0.594    -.3320624    .5805167
             88  |   .1904977   .2486132     0.77   0.444    -.2969171    .6779125
                 |
           _cons |   .3956251   .2469216     1.60   0.109    -.0884733    .8797234
    ------------------------------------------------------------------------------
    
    Absorbed degrees of freedom:
    -----------------------------------------------------+
     Absorbed FE | Categories  - Redundant  = Num. Coefs |
    -------------+---------------------------------------|
          idcode |      4159        4159           0    *|
    -----------------------------------------------------+
    * = FE nested within cluster; treated as redundant for DoF computation
    
    . mat list e(b)
    
    e(b)[1,18]
                         c.age#        68b.         69.         70.         71.         72.         73.         75.         77.         78.         80.         82.         83.
               age       c.age        year        year        year        year        year        year        year        year        year        year        year        year
    y1   .07287457  -.00101134           0   .06470541   .02844226   .05799593   .05106711   .04241042    .0151376   .03409325   .05373339   .03694753   .03916873   .05876604
    
                85.         87.         88.            
              year        year        year       _cons
    y1    .1042758   .12422716   .19049771   .39562505
    
    .
    Kind regards,
    Carlo
    (StataNow 18.5)

    Comment


    • #3
      Thank you for this.
      However, it does not seem to work.
      For example, say that I want to test post estimation if the coefficient on the interaction c.age#c.age is equal to 1.
      If I use test c.age#c.age=1, Stata gives me an error saying that c.age#c.age is an invalid name.
      Thanks again.
      Costas

      Comment


      • #4
        Code:
        test _b[c.age#c.age]=1
        See

        Code:
        help _variables

        Comment


        • #5
          Reading #1, Carlo's response was appropriate. You then changed this to a question about the test command. I suggest that you provide a reproducible example where referring to the coefficient on the interaction term failed.

          Comment


          • #6
            I'm rather confused and don't think we are being shown what is actually going on; here is a simple example:
            Code:
            . sysuse auto
            (1978 automobile data)
            r; t=0.03 10:25:59
            
            . reghdfe price c.weight##c.weight
            (MWFE estimator converged in 1 iterations)
            
            HDFE Linear regression                            Number of obs   =         74
            Absorbing 1 HDFE group                            F(   2,     71) =      23.09
                                                              Prob > F        =     0.0000
                                                              R-squared       =     0.3941
                                                              Adj R-squared   =     0.3770
                                                              Within R-sq.    =     0.3941
                                                              Root MSE        =  2327.9681
            
            ------------------------------------------------------------------------------
                   price | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
            -------------+----------------------------------------------------------------
                  weight |  -7.273097   2.691747    -2.70   0.009    -12.64029   -1.905906
                         |
                c.weight#|
                c.weight |   .0015142   .0004337     3.49   0.001     .0006494     .002379
                         |
                   _cons |    13418.8   3997.822     3.36   0.001     5447.372    21390.23
            ------------------------------------------------------------------------------
            r; t=0.20 10:26:16
            
            . test c.weight#c.weight=1
            
             ( 1)  c.weight#c.weight = 1
            
                   F(  1,    71) = 5.3e+06
                        Prob > F =    0.0000

            Comment

            Working...
            X