Announcement

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

  • Main effects of two independent variables across five groups

    Hi,

    I have unbalanced panel data for 160 companies from 5 different subgroups (g1,g2,g3,g4,g5) where group id is defined by business activity type, over 14 years for which I run the following baseline regression: (CVs: additional 7 control variables, l: lagged variable, X1 and X2: continuous independent variables, Y: continuous dependent variable)

    xtreg Y l.X1 l.X2 l.CVs i.year,r

    I want to check if the main effects of X1 and X2 on Y vary across 5 groups where all are lagged except for Y. For that reason, I ran the following sample regression;

    xtreg Y l.X1 l.X2 l.g2.l.g3.l.g4.l.g5 l.c.X1#l.i.g2 l.c.X1#l.i.g3 l.c.X1#l.i.g4 l.c.X1#l.i.g5 l.c.X2#l.i.g2 l.c.X2#l.i.g3 l.c.X2#l.i.g4 l.c.X2#l.i.g5 l.CVs i.year,r

    5 times in a row by omitting one different group at a time (g1 is omitted in the first one above).

    Is this the correct approach? How about dropping all g2,g3,g4,g5 observations and running the regression for g1 companies only (5 times in total keeping the observations of only one different group at a time)?

    My second model is baseline + interaction between X1 and X2:

    xtreg Y l.X1 l.X2 l.c.X1#l.c.X2 l.CVs i.year,r

    Should I rerun the aforementioned 5 regressions again (this time the interaction included) to observe the differences in the main effects of X1 and X2 across groups as in the following (g1 is omitted):

    xtreg Y l.X1 l.X2 l.c.X1#l.c.X2 l.g2.l.g3.l.g4.l.g5 l.c.X1#l.i.g2 l.c.X1#l.i.g3 l.c.X1#l.i.g4 l.c.X1#l.i.g5 l.c.X2#l.i.g2 l.c.X2#l.i.g3 l.c.X2#l.i.g4 l.c.X2#l.i.g5 l.c.X1#l.c.X2#l.i.g2 l.c.X1#l.c.X2#l.i.g3 l.c.X1#l.c.X2#l.i.g4 l.c.X1#l.c.X2#l.i.g5 l.CVs i.year,r

    Best,

    Lutfi
    Last edited by Lutfi Ozturker; 26 Nov 2022, 18:07.

  • #2
    Lutfi:
    1) I'm unclear with your lagging the levels of the categorical variable -group-;
    2) that said, I would go with a (hopefuly) more efficient code (-group- levels are not lagged):
    Code:
    xtreg Y group##(l.X1 l.X2) l.CVs i.year,r
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Thank you for your response.
      I want to compare all groups to each other, ant not only g1 to others.

      Comment


      • #4
        Thank you for your response.
        I want to compare all groups to each other, and not only g1 to others, concerning how the effects of X1 and X2 vary across groups.
        Last edited by Lutfi Ozturker; 27 Nov 2022, 06:32.

        Comment


        • #5
          Lutfi:
          why not considering -test- and/or -lincom-?
          Kind regards,
          Carlo
          (Stata 19.0)

          Comment


          • #6
            How can I use those two commands to observe how much the effects of X1 and X2 vary across five groups with respect to each group pair?

            Comment


            • #7
              Lutfi:
              you may want to consider something along the lines of the following toy-example:
              Code:
              . use "https://www.stata-press.com/data/r17/nlswork.dta"
              (National Longitudinal Survey of Young Women, 14-24 years old in 1968)
              
              . xtreg ln_wage i.msp##( age grade) i.year, re
              note: 1.msp#15.age identifies no observations in the sample.
              note: 1.msp#46.age identifies no observations in the sample.
              note: 0.msp#1.grade identifies no observations in the sample.
              note: 0.msp#3.grade identifies no observations in the sample.
              note: 1.msp#1.grade omitted because of collinearity.
              note: 1.msp#2.grade identifies no observations in the sample.
              note: 1.msp#3.grade omitted because of collinearity.
              
              Random-effects GLS regression                   Number of obs     =     28,492
              Group variable: idcode                          Number of groups  =      4,708
              
              R-squared:                                      Obs per group:
                   Within  = 0.1242                                         min =          1
                   Between = 0.3350                                         avg =        6.1
                   Overall = 0.2466                                         max =         15
              
                                                              Wald chi2(110)    =    5731.69
              corr(u_i, X) = 0 (assumed)                      Prob > chi2       =     0.0000
              
              ------------------------------------------------------------------------------
                   ln_wage | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
              -------------+----------------------------------------------------------------
                     1.msp |   -1.04785   .5040234    -2.08   0.038    -2.035718   -.0599826
                           |
                       age |
                       15  |  -1.102939   .4769387    -2.31   0.021    -2.037722   -.1681563
                       16  |  -.6953745   .3479223    -2.00   0.046     -1.37729   -.0134593
                       17  |  -.8418503   .3400993    -2.48   0.013    -1.508433   -.1752679
                       18  |  -.7942995   .3383599    -2.35   0.019    -1.457473   -.1311264
                       19  |  -.7220069   .3382743    -2.13   0.033    -1.385012   -.0590015
                       20  |  -.6669898   .3382914    -1.97   0.049    -1.330029   -.0039509
                       21  |   -.604027   .3382404    -1.79   0.074    -1.266966    .0589119
                       22  |  -.5908624   .3384113    -1.75   0.081    -1.254136    .0724115
                       23  |  -.5481243   .3383751    -1.62   0.105    -1.211327    .1150786
                       24  |  -.5495184   .3385839    -1.62   0.105    -1.213131    .1140938
                       25  |  -.5048543   .3387061    -1.49   0.136    -1.168706    .1589975
                       26  |  -.4758119   .3388327    -1.40   0.160    -1.139912     .188288
                       27  |   -.474799   .3389734    -1.40   0.161    -1.139175    .1895767
                       28  |  -.4744132   .3391195    -1.40   0.162    -1.139075    .1902488
                       29  |  -.4420676   .3392302    -1.30   0.193    -1.106947    .2228114
                       30  |  -.4374328    .339373    -1.29   0.197    -1.102592    .2277261
                       31  |  -.3823872   .3394644    -1.13   0.260    -1.047725    .2829507
                       32  |  -.3827113   .3396429    -1.13   0.260    -1.048399    .2829766
                       33  |  -.3691454   .3397273    -1.09   0.277    -1.034999    .2967078
                       34  |  -.3906918   .3398084    -1.15   0.250    -1.056704    .2753204
                       35  |  -.3371139   .3399948    -0.99   0.321    -1.003491    .3292637
                       36  |  -.3265068   .3401624    -0.96   0.337    -.9932128    .3401992
                       37  |  -.3574491    .340381    -1.05   0.294    -1.024584    .3096854
                       38  |  -.3468841   .3404889    -1.02   0.308     -1.01423    .3204618
                       39  |  -.3720927   .3407596    -1.09   0.275    -1.039969    .2957838
                       40  |  -.3659249    .341172    -1.07   0.283     -1.03461      .30276
                       41  |  -.3729356   .3413592    -1.09   0.275    -1.041987    .2961161
                       42  |  -.3891574   .3419878    -1.14   0.255    -1.059441    .2811263
                       43  |  -.3576391   .3423591    -1.04   0.296    -1.028651    .3133724
                       44  |  -.3669702   .3432982    -1.07   0.285    -1.039822    .3058818
                       45  |  -.3413222   .3465819    -0.98   0.325     -1.02061    .3379659
                       46  |  -.0706425   .4105768    -0.17   0.863    -.8753582    .7340731
                           |
                     grade |
                        1  |   .0808563   .4062492     0.20   0.842    -.7153774      .87709
                        2  |  -.0136497   .3055424    -0.04   0.964    -.6125018    .5852024
                        3  |  -.1482442   .4417667    -0.34   0.737    -1.014091    .7176027
                        4  |  -.0102682   .2241782    -0.05   0.963    -.4496493     .429113
                        5  |  -.1815514   .1922243    -0.94   0.345    -.5583041    .1952013
                        6  |  -.1725308   .1646249    -1.05   0.295    -.4951897    .1501281
                        7  |  -.0351668   .1563142    -0.22   0.822     -.341537    .2712033
                        8  |   .0704497   .1488175     0.47   0.636    -.2212271    .3621266
                        9  |   .0884253   .1484214     0.60   0.551    -.2024754     .379326
                       10  |    .114155   .1469537     0.78   0.437    -.1738689     .402179
                       11  |    .203019   .1466084     1.38   0.166    -.0843282    .4903662
                       12  |   .3382324   .1451101     2.33   0.020     .0538218     .622643
                       13  |   .4499315   .1465983     3.07   0.002      .162604     .737259
                       14  |   .5187561    .146608     3.54   0.000     .2314098    .8061025
                       15  |    .628118   .1480894     4.24   0.000     .3378681     .918368
                       16  |   .6529241   .1460889     4.47   0.000     .3665951    .9392531
                       17  |   .7839245   .1484361     5.28   0.000      .492995    1.074854
                       18  |   .8074054   .1479133     5.46   0.000     .5175007     1.09731
                           |
                   msp#age |
                     1 15  |          0  (empty)
                     1 16  |   .7798322   .4439681     1.76   0.079    -.0903292    1.649994
                     1 17  |   1.053382   .4316652     2.44   0.015      .207334    1.899431
                     1 18  |   1.128174   .4286053     2.63   0.008      .288123    1.968225
                     1 19  |   1.164591   .4277822     2.72   0.006     .3261532    2.003029
                     1 20  |   1.148693   .4276741     2.69   0.007      .310467    1.986919
                     1 21  |   1.116958   .4275498     2.61   0.009     .2789756     1.95494
                     1 22  |   1.120806   .4275732     2.62   0.009     .2827783    1.958834
                     1 23  |   1.107289   .4274509     2.59   0.010     .2695007    1.945077
                     1 24  |   1.134293   .4275853     2.65   0.008     .2962414    1.972345
                     1 25  |   1.103325   .4275725     2.58   0.010     .2652983    1.941352
                     1 26  |   1.096343   .4276025     2.56   0.010     .2582575    1.934429
                     1 27  |   1.096265   .4276414     2.56   0.010     .2581035    1.934427
                     1 28  |   1.119544   .4277253     2.62   0.009      .281218    1.957871
                     1 29  |   1.091849   .4276781     2.55   0.011     .2536154    1.930083
                     1 30  |   1.073105   .4277067     2.51   0.012     .2348157    1.911395
                     1 31  |   1.055775   .4276801     2.47   0.014     .2175372    1.894012
                     1 32  |   1.062633   .4277298     2.48   0.013     .2242982    1.900968
                     1 33  |   1.051426   .4276883     2.46   0.014     .2131719    1.889679
                     1 34  |   1.066836   .4276535     2.49   0.013     .2286508    1.905022
                     1 35  |   1.026258   .4276662     2.40   0.016     .1880479    1.864469
                     1 36  |   1.000385   .4277235     2.34   0.019      .162062    1.838707
                     1 37  |   1.035462   .4278036     2.42   0.016     .1969828    1.873942
                     1 38  |   1.031108   .4277978     2.41   0.016     .1926397    1.869576
                     1 39  |   1.053134   .4279244     2.46   0.014     .2144176    1.891851
                     1 40  |   1.043786   .4281727     2.44   0.015     .2045827    1.882989
                     1 41  |   1.046917   .4282628     2.44   0.015     .2075371    1.886296
                     1 42  |   1.052196   .4288036     2.45   0.014     .2117565    1.892636
                     1 43  |   1.011465   .4289812     2.36   0.018     .1706774    1.852253
                     1 44  |   1.034512   .4298496     2.41   0.016     .1920225    1.877002
                     1 45  |   1.002725   .4337693     2.31   0.021     .1525531    1.852898
                     1 46  |          0  (empty)
                           |
                 msp#grade |
                     0  1  |          0  (empty)
                     0  3  |          0  (empty)
                     1  1  |          0  (omitted)
                     1  2  |          0  (empty)
                     1  3  |          0  (omitted)
                     1  4  |   .1159895   .3962324     0.29   0.770    -.6606118    .8925908
                     1  5  |    .232803   .3069189     0.76   0.448     -.368747     .834353
                     1  6  |   .1349442   .2792367     0.48   0.629    -.4123497    .6822382
                     1  7  |  -.0220222   .2722826    -0.08   0.936    -.5556862    .5116418
                     1  8  |  -.0940153   .2693802    -0.35   0.727    -.6219907    .4339601
                     1  9  |  -.0577364   .2689964    -0.21   0.830    -.5849597    .4694869
                     1 10  |  -.0120498   .2683387    -0.04   0.964     -.537984    .5138844
                     1 11  |  -.0626298   .2682024    -0.23   0.815    -.5882969    .4630372
                     1 12  |  -.0606064   .2675438    -0.23   0.821    -.5849827    .4637698
                     1 13  |  -.0746568   .2682537    -0.28   0.781    -.6004243    .4511107
                     1 14  |  -.0735426   .2683459    -0.27   0.784     -.599491    .4524058
                     1 15  |  -.0800183   .2690106    -0.30   0.766    -.6072694    .4472329
                     1 16  |  -.0592572    .268033    -0.22   0.825    -.5845922    .4660778
                     1 17  |  -.0721933   .2693728    -0.27   0.789    -.6001542    .4557677
                     1 18  |  -.0383574   .2694544    -0.14   0.887    -.5664783    .4897635
                           |
                      year |
                       69  |   .0589561   .0123635     4.77   0.000     .0347242     .083188
                       70  |   .0172667   .0118382     1.46   0.145    -.0059357    .0404691
                       71  |   .0423343   .0122198     3.46   0.001     .0183839    .0662846
                       72  |   .0353994    .013107     2.70   0.007     .0097101    .0610886
                       73  |    .020743   .0137064     1.51   0.130    -.0061209     .047607
                       75  |  -.0079775    .015714    -0.51   0.612    -.0387764    .0228215
                       77  |   .0177593   .0182312     0.97   0.330    -.0179731    .0534918
                       78  |   .0409051   .0197592     2.07   0.038     .0021778    .0796324
                       80  |   .0248056   .0225275     1.10   0.271    -.0193475    .0689587
                       82  |   .0238837   .0251781     0.95   0.343    -.0254644    .0732317
                       83  |   .0433269   .0266102     1.63   0.103    -.0088281     .095482
                       85  |    .085267   .0293515     2.91   0.004     .0277392    .1427949
                       87  |   .1002928   .0321733     3.12   0.002     .0372343    .1633513
                       88  |   .1537568   .0341052     4.51   0.000     .0869118    .2206018
                           |
                     _cons |   1.706811   .3676466     4.64   0.000     .9862371    2.427385
              -------------+----------------------------------------------------------------
                   sigma_u |  .30073571
                   sigma_e |  .30027949
                       rho |  .50075908   (fraction of variance due to u_i)
              ------------------------------------------------------------------------------
              
              
              . test 1.msp#37.age = 1.msp#38.age
              
               ( 1)  1.msp#37.age - 1.msp#38.age = 0
              
                         chi2(  1) =    0.02
                       Prob > chi2 =    0.8890
              
              
              . lincom (1.msp#37.age + 1.msp#38.age)-1.msp#6.grade
              
               ( 1)  1.msp#37.age + 1.msp#38.age - 1.msp#6.grade = 0
              
              ------------------------------------------------------------------------------
                   ln_wage | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
              -------------+----------------------------------------------------------------
                       (1) |   1.931626    .899535     2.15   0.032       .16857    3.694682
              ------------------------------------------------------------------------------
              
              .
              Kind regards,
              Carlo
              (Stata 19.0)

              Comment

              Working...
              X