Announcement

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

  • Comparing coefficients of two equal FE regressions from two subsamples

    Hello everyone,

    I have a question concerning how to compare/test the output of the same FE model I ran on two seperate non-overlapping samples.

    This is the code I used (I apologize for the formatting):

    xtreg Yt Yt-1 GDP $Controls i.year if CountryGroupA==1 , fe robust cluster nonest
    xtreg Yt Yt-1 GDP $Controls i.year if CountryGroupB==0 , fe robust cluster nonest

    I now want to find out whether the coefficients of e.g. GDP are significantly different from each other depending on whether a country belongs to Group A or to Group B.

    My thoughts: I think I cannot use the "test" command when comparing coeffiecients of two different regressions? I found the "suest" command to combine both regressions, but it was stopped saying it does not work with these models.

    I would appreciate your help.

    Thank you
    Niklas

  • #2
    Interact your variables with the group indicators instead of running two regressions. For example splitting firms in the Grunfeld data set into two groups

    Code:
    webuse grunfeld
    xtreg invest mvalue kstock if inrange(company, 1, 5), fe robust nonest
    xtreg invest mvalue kstock if inrange(company, 6, 10), fe robust nonest
    simply create a group indicator and run one regression

    Code:
    gen group= cond(inrange(company, 6, 10), 1, 0)
    xtreg invest c.mvalue#i.group c.kstock#i.group, fe robust nonest
    test  1.group#c.mvalue = 0.group#c.mvalue

    Code:
    . webuse grunfeld
    
    .
    . xtreg invest mvalue kstock if inrange(company, 1, 5), fe robust nonest
    
    Fixed-effects (within) regression               Number of obs      =       100
    Group variable: company                         Number of groups   =         5
    
    R-sq:  within  = 0.7817                         Obs per group: min =        20
           between = 0.7465                                        avg =      20.0
           overall = 0.7566                                        max =        20
    
                                                    F(2,4)             =     31.64
    corr(u_i, Xb)  = -0.1184                        Prob > F           =    0.0035
    
                                    (Std. Err. adjusted for 5 clusters in company)
    ------------------------------------------------------------------------------
                 |               Robust
          invest |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
          mvalue |   .1149211    .015433     7.45   0.002     .0720723    .1577699
          kstock |   .3211845   .0516658     6.22   0.003     .1777373    .4646317
           _cons |  -82.41736   42.34032    -1.95   0.123    -199.9729    35.13823
    -------------+----------------------------------------------------------------
         sigma_u |  124.04416
         sigma_e |  71.914089
             rho |  .74844403   (fraction of variance due to u_i)
    ------------------------------------------------------------------------------
    
    .
    . xtreg invest mvalue kstock if inrange(company, 6, 10), fe robust nonest
    
    Fixed-effects (within) regression               Number of obs      =       100
    Group variable: company                         Number of groups   =         5
    
    R-sq:  within  = 0.7874                         Obs per group: min =        20
           between = 0.6820                                        avg =      20.0
           overall = 0.7205                                        max =        20
    
                                                    F(2,4)             =     42.82
    corr(u_i, Xb)  = -0.3768                        Prob > F           =    0.0020
    
                                    (Std. Err. adjusted for 5 clusters in company)
    ------------------------------------------------------------------------------
                 |               Robust
          invest |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
          mvalue |   .0826851   .0281736     2.93   0.043     .0044627    .1609076
          kstock |   .1144632   .0141124     8.11   0.001      .075281    .1536454
           _cons |  -7.544902   9.142118    -0.83   0.456    -32.92749    17.83769
    -------------+----------------------------------------------------------------
         sigma_u |  13.207854
         sigma_e |  9.6545682
             rho |  .65175463   (fraction of variance due to u_i)
    ------------------------------------------------------------------------------
    
    . gen group= cond(inrange(company, 6, 10), 1, 0)
    
    .
    . xtreg invest c.mvalue#i.group c.kstock#i.group, fe robust nonest
    
    Fixed-effects (within) regression               Number of obs      =       200
    Group variable: company                         Number of groups   =        10
    
    R-sq:  within  = 0.7818                         Obs per group: min =        20
           between = 0.8192                                        avg =      20.0
           overall = 0.8058                                        max =        20
    
                                                    F(4,9)             =     41.89
    corr(u_i, Xb)  = -0.3599                        Prob > F           =    0.0000
    
                                     (Std. Err. adjusted for 10 clusters in company)
    --------------------------------------------------------------------------------
                   |               Robust
            invest |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    ---------------+----------------------------------------------------------------
    group#c.mvalue |
                0  |   .1149211   .0145496     7.90   0.000     .0820076    .1478346
                1  |   .0826851    .026561     3.11   0.012     .0226001    .1427702
                   |
    group#c.kstock |
                0  |   .3211845   .0487084     6.59   0.000     .2109984    .4313706
                1  |   .1144632   .0133046     8.60   0.000     .0843661    .1445602
                   |
             _cons |  -44.98113   20.41833    -2.20   0.055     -91.1706    1.208344
    ---------------+----------------------------------------------------------------
           sigma_u |  92.050903
           sigma_e |  51.307148
               rho |  .76296842   (fraction of variance due to u_i)
    --------------------------------------------------------------------------------
    
    .
    . test  1.group#c.mvalue = 0.group#c.mvalue
    
     ( 1)  - 0b.group#c.mvalue + 1.group#c.mvalue = 0
    
           F(  1,     9) =    1.13
                Prob > F =    0.3149
    
    .

    Comment


    • #3
      Hi Andrew,

      I appreciate your help and great advice - this is a nice workaround and works perfectly well for me.

      Best
      Niklas

      Comment


      • #4
        Dear Stata Members
        I have a similar question regarding the comparison of two betas based on a panel regression run on two sub-samples. I will report what I did and what Stata gives me.

        Code:
        Group 1
         xtreg tcred_ta_w epu  inven_ta_w casheq_ta_w  size_w lever_w nw_ta_w ncfo_ta_w sgrowth_w pbitnet_ta_w fcfvol age  i.rd_
        > dum i.divid_dum gdpgrowthannual realinterestrate i.year if list_unlist==1, fe vce (robust)
        note: 2017.year omitted because of collinearity
        note: 2018.year omitted because of collinearity
        note: 2019.year omitted because of collinearity
        
        Fixed-effects (within) regression               Number of obs     =     28,774
        Group variable: nic2                            Number of groups  =         65
        
        R-sq:                                           Obs per group:
             within  = 0.2234                                         min =          1
             between = 0.1180                                         avg =      442.7
             overall = 0.1977                                         max =      2,914
        
                                                        F(26,64)          =     163.91
        corr(u_i, Xb)  = -0.0836                        Prob > F          =     0.0000
        
                                              (Std. Err. adjusted for 65 clusters in nic2)
        ----------------------------------------------------------------------------------
                         |               Robust
              tcred_ta_w |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
        -----------------+----------------------------------------------------------------
                     epu |   .2252673   .0338396     6.66   0.000     .1576648    .2928697
              inven_ta_w |    -.24196   .0248056    -9.75   0.000    -.2915149   -.1924051
             casheq_ta_w |  -.2015028   .0238661    -8.44   0.000    -.2491809   -.1538247
                  size_w |  -.0164433   .0024225    -6.79   0.000    -.0212828   -.0116037
                 lever_w |   .3055079   .0333247     9.17   0.000     .2389341    .3720817
                 nw_ta_w |   .2346225   .0292002     8.03   0.000     .1762884    .2929566
               ncfo_ta_w |  -.2358359   .0243167    -9.70   0.000    -.2844141   -.1872578
               sgrowth_w |  -.0090284   .0012813    -7.05   0.000    -.0115881   -.0064687
            pbitnet_ta_w |   .3928499   .0271214    14.48   0.000     .3386686    .4470313
                  fcfvol |  -.0122149   .0259074    -0.47   0.639    -.0639709     .039541
                     age |   .0009343   .0033111     0.28   0.779    -.0056804    .0075489
                1.rd_dum |   .0034209   .0045119     0.76   0.451    -.0055927    .0124345
             1.divid_dum |   .0083402   .0037004     2.25   0.028     .0009478    .0157326
         gdpgrowthannual |  -.0372284   .0059391    -6.27   0.000    -.0490931   -.0253637
        realinterestrate |  -.0082682   .0020398    -4.05   0.000    -.0123432   -.0041932
                         |
                    year |
                   2006  |   .0765973   .0120629     6.35   0.000     .0524989    .1006957
                   2007  |   .0526013   .0100591     5.23   0.000     .0325059    .0726968
                   2008  |  -.1960804   .0303197    -6.47   0.000     -.256651   -.1355098
                   2009  |  -.1569621   .0233269    -6.73   0.000    -.2035629   -.1103613
                   2010  |  -.1155092   .0203877    -5.67   0.000    -.1562383   -.0747801
                   2011  |  -.2220929   .0360443    -6.16   0.000    -.2940997   -.1500861
                   2012  |  -.3033478    .047364    -6.40   0.000    -.3979683   -.2087274
                   2013  |  -.2345404   .0364181    -6.44   0.000     -.307294   -.1617869
                   2014  |  -.0857905    .014132    -6.07   0.000    -.1140225   -.0575586
                   2015  |  -.0098949   .0048006    -2.06   0.043    -.0194852   -.0003046
                   2016  |   .0669242   .0110206     6.07   0.000     .0449081    .0889402
                   2017  |          0  (omitted)
                   2018  |          0  (omitted)
                   2019  |          0  (omitted)
                         |
                   _cons |  -.6012961    .090398    -6.65   0.000    -.7818868   -.4207054
        -----------------+----------------------------------------------------------------
                 sigma_u |  .07389828
                 sigma_e |  .12178319
                     rho |  .26911731   (fraction of variance due to u_i)
        ----------------------------------------------------------------------------------

        Group 2

        Code:
        xtreg tcred_ta_w epu  inven_ta_w casheq_ta_w  size_w lever_w nw_ta_w ncfo_ta_w sgrowth_w pbitnet_ta_w fcfvol age  i.rd_
        > dum i.divid_dum gdpgrowthannual realinterestrate i.year if list_unlist==0, fe vce (robust)
        note: 2017.year omitted because of collinearity
        note: 2018.year omitted because of collinearity
        note: 2019.year omitted because of collinearity
        
        Fixed-effects (within) regression               Number of obs     =     43,948
        Group variable: nic2                            Number of groups  =         68
        
        R-sq:                                           Obs per group:
             within  = 0.2496                                         min =          3
             between = 0.0839                                         avg =      646.3
             overall = 0.2071                                         max =      5,584
        
                                                        F(26,67)          =      87.73
        corr(u_i, Xb)  = -0.1909                        Prob > F          =     0.0000
        
                                              (Std. Err. adjusted for 68 clusters in nic2)
        ----------------------------------------------------------------------------------
                         |               Robust
              tcred_ta_w |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
        -----------------+----------------------------------------------------------------
                     epu |   .2119473   .0279135     7.59   0.000     .1562318    .2676628
              inven_ta_w |  -.2745237   .0323172    -8.49   0.000    -.3390291   -.2100182
             casheq_ta_w |  -.2264514   .0214088   -10.58   0.000    -.2691836   -.1837193
                  size_w |  -.0139524   .0015688    -8.89   0.000    -.0170838    -.010821
                 lever_w |   .3299843   .0391981     8.42   0.000     .2517446    .4082241
                 nw_ta_w |   .2898123   .0323789     8.95   0.000     .2251838    .3544409
               ncfo_ta_w |  -.2190603   .0215958   -10.14   0.000    -.2621656    -.175955
               sgrowth_w |  -.0094373   .0017281    -5.46   0.000    -.0128865   -.0059881
            pbitnet_ta_w |   .4389431    .027455    15.99   0.000     .3841427    .4937434
                  fcfvol |    .016645   .0207728     0.80   0.426    -.0248177    .0581078
                     age |   .0079483   .0042714     1.86   0.067    -.0005774     .016474
                1.rd_dum |   .0075492   .0033114     2.28   0.026     .0009396    .0141587
             1.divid_dum |   .0136682   .0036223     3.77   0.000      .006438    .0208984
         gdpgrowthannual |  -.0378726   .0048605    -7.79   0.000    -.0475742   -.0281711
        realinterestrate |  -.0084873   .0012112    -7.01   0.000    -.0109049   -.0060696
                         |
                    year |
                   2006  |   .0630323   .0116017     5.43   0.000     .0398753    .0861894
                   2007  |   .0440735   .0100091     4.40   0.000     .0240952    .0640517
                   2008  |  -.1970872   .0232165    -8.49   0.000    -.2434275   -.1507469
                   2009  |  -.1475824    .019033    -7.75   0.000    -.1855724   -.1095925
                   2010  |  -.1074139    .013801    -7.78   0.000    -.1349608   -.0798671
                   2011  |  -.2139954    .027356    -7.82   0.000    -.2685981   -.1593926
                   2012  |  -.2838494   .0366622    -7.74   0.000    -.3570274   -.2106714
                   2013  |  -.2175805   .0298691    -7.28   0.000    -.2771995   -.1579615
                   2014  |  -.0706236   .0118452    -5.96   0.000    -.0942668   -.0469804
                   2015  |   .0001644   .0038238     0.04   0.966    -.0074679    .0077966
                   2016  |   .0690992   .0080798     8.55   0.000     .0529719    .0852264
                   2017  |          0  (omitted)
                   2018  |          0  (omitted)
                   2019  |          0  (omitted)
                         |
                   _cons |  -.6161327   .0815826    -7.55   0.000    -.7789723   -.4532931
        -----------------+----------------------------------------------------------------
                 sigma_u |  .09028067
                 sigma_e |  .13847706
                     rho |  .29826728   (fraction of variance due to u_i)
        ----------------------------------------------------------------------------------
        1. How to compare coefficients of "epu" in these two groups? In his excellent advice, Andrew Musau has shown way but I dont know how to use it my case (espeically, using the group code, where I cant use inrange)
        2. How do we interpret the differences between two beta groups (.225 versus .211 for epu)
        I ran the interaction model and got the following result

        Code:
        xtreg tcred_ta_w c.epu##i.list_unlist  inven_ta_w casheq_ta_w  size_w lever_w nw_ta_w ncfo_ta_w sgrowth_w pbitnet_ta_w
        > fcfvol age  i.rd_dum i.divid_dum gdpgrowthannual realinterestrate i.year, fe vce (robust)
        note: 2017.year omitted because of collinearity
        note: 2018.year omitted because of collinearity
        note: 2019.year omitted because of collinearity
        
        Fixed-effects (within) regression               Number of obs     =     72,722
        Group variable: nic2                            Number of groups  =         70
        
        R-sq:                                           Obs per group:
             within  = 0.2397                                         min =          2
             between = 0.0358                                         avg =    1,038.9
             overall = 0.2026                                         max =      8,498
        
                                                        F(28,69)          =     125.61
        corr(u_i, Xb)  = -0.1586                        Prob > F          =     0.0000
        
                                               (Std. Err. adjusted for 70 clusters in nic2)
        -----------------------------------------------------------------------------------
                          |               Robust
               tcred_ta_w |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
        ------------------+----------------------------------------------------------------
                      epu |   .2058954   .0241682     8.52   0.000     .1576813    .2541096
            1.list_unlist |   .0300042   .0118069     2.54   0.013     .0064501    .0535582
                          |
        list_unlist#c.epu |
                       1  |   .016645   .0207728    0.80  0.426    -.0248177    .0581078
                          |
               inven_ta_w |  -.2633999    .027978    -9.41   0.000    -.3192145   -.2075853
              casheq_ta_w |  -.2188511   .0177446   -12.33   0.000    -.2542505   -.1834516
                   size_w |  -.0152317     .00176    -8.65   0.000    -.0187429   -.0117205
                  lever_w |   .3226436   .0351841     9.17   0.000     .2524532     .392834
                  nw_ta_w |   .2704687   .0285815     9.46   0.000     .2134501    .3274873
                ncfo_ta_w |  -.2252778   .0225122   -10.01   0.000    -.2701885   -.1803671
                sgrowth_w |  -.0094953   .0014551    -6.53   0.000    -.0123981   -.0065925
             pbitnet_ta_w |   .4264954   .0248943    17.13   0.000     .3768326    .4761583
                   fcfvol |   .0024955   .0199061     0.13   0.901    -.0372161    .0422071
                      age |   .0061563   .0032881     1.87   0.065    -.0004033    .0127159
                 1.rd_dum |   .0039935   .0029435     1.36   0.179    -.0018786    .0098656
              1.divid_dum |   .0093533   .0026055     3.59   0.001     .0041554    .0145511
          gdpgrowthannual |  -.0357376   .0040725    -8.78   0.000    -.0438621   -.0276132
         realinterestrate |  -.0079972    .001297    -6.17   0.000    -.0105847   -.0054096
                          |
                     year |
                    2006  |   .0638036   .0088966     7.17   0.000     .0460553     .081552
                    2007  |   .0432944   .0071833     6.03   0.000     .0289641    .0576246
                    2008  |  -.1888478   .0206492    -9.15   0.000    -.2300417   -.1476538
                    2009  |  -.1425464   .0173257    -8.23   0.000    -.1771101   -.1079826
                    2010  |  -.1059748   .0141047    -7.51   0.000     -.134113   -.0778366
                    2011  |  -.2059803   .0245177    -8.40   0.000    -.2548918   -.1570688
                    2012  |  -.2748454   .0327403    -8.39   0.000    -.3401604   -.2095303
                    2013  |  -.2107369   .0258176    -8.16   0.000    -.2622416   -.1592322
                    2014  |   -.071158    .010355    -6.87   0.000    -.0918157   -.0505004
                    2015  |  -.0023375   .0032021    -0.73   0.468    -.0087255    .0040506
                    2016  |   .0648445   .0073951     8.77   0.000     .0500918    .0795973
                    2017  |          0  (omitted)
                    2018  |          0  (omitted)
                    2019  |          0  (omitted)
                          |
                    _cons |  -.5817242   .0701526    -8.29   0.000    -.7216748   -.4417735
        ------------------+----------------------------------------------------------------
                  sigma_u |  .08693686
                  sigma_e |  .13269454
                      rho |  .30032819   (fraction of variance due to u_i)
        -----------------------------------------------------------------------------------

        3. Is the insignificance of the coeffecient of list_unlist#c.epu consistent with sub-sample analysis , indicating both coefficients are economically similar?
        Last edited by lal mohan kumar; 11 Apr 2021, 00:20.

        Comment


        • #5
          You have year dummies which means that you need to be careful implementing this procedure. Please post a data example.

          Comment


          • #6
            Andrew Musau, Thank you for taking the trouble to help me. As you correctly pointed, the year dummies issue was not known to me till I tried to do a example. However, I shall post a data example as you suggested.

            *1*Input Data using ssc

            Code:
            input int co_code byte(list_unlist nic2) int year float(nsales totexp selldisexp epu)
            363 1 82 2012  1449.9  1445.8    1.4 5.20827
              3 0 46 2012   431.6   329.6    1.1 5.20827
             11 1  8 2012  2626.2    2644  325.1 5.20827
             66 0 86 2012   405.9   361.6   28.7 5.20827
            337 0 59 2012   182.2    97.4     .1 5.20827
            365 1 30 2012 23842.9 22228.5  479.3 5.20827
            372 0 55 2012   714.2   749.1   53.5 5.20827
            457 0 58 2012  8106.5    7972  983.8 5.20827
            381 0 29 2012  2561.1  2369.2   77.1 5.20827
            372 0 55 2013   928.7     973   61.1 5.14044
            365 1 30 2013 20940.2 21611.8  420.5 5.14044
            363 1 82 2013   961.2  1111.6    5.8 5.14044
              3 0 46 2013   362.3   319.7    1.5 5.14044
            337 0 59 2013   211.7     118    1.4 5.14044
            457 0 58 2013  8476.3  8659.1 1108.2 5.14044
            381 0 29 2013  2667.8  2542.6   72.2 5.14044
             11 1  8 2013  2753.6  2904.8    374 5.14044
            365 1 30 2014 16188.1 21576.3 1604.2 4.76683
             11 1  8 2014  2888.8  3146.9  429.1 4.76683
             66 0 86 2014   403.9   448.5    6.1 4.76683
              3 0 46 2014     269   223.1    3.6 4.76683
            372 0 55 2014  1089.9  1112.6   72.8 4.76683
            381 0 29 2014  3246.7    3343  135.5 4.76683
            457 0 58 2014  9033.2  9025.5 1172.7 4.76683
            363 1 82 2014   734.6   948.7    7.8 4.76683
            363 1 82 2015   710.1   932.1    5.9 4.59869
            372 0 55 2015  1023.7  1035.7   67.4 4.59869
            381 0 29 2015  4048.3  4246.1  149.5 4.59869
             66 0 86 2015   448.1   460.3    5.2 4.59869
              3 0 46 2015   275.6     281    7.4 4.59869
            457 0 58 2015  9245.8  9074.1 1095.5 4.59869
            365 1 30 2015  3901.2   12084  548.2 4.59869
             11 1  8 2015  3116.7  3378.2  458.2 4.59869
             11 1  8 2016  3338.3  3442.4    448 4.24885
              3 0 46 2016   239.6   245.3    3.3 4.24885
            365 1 30 2016   343.1 33761.1  233.5 4.24885
             66 0 86 2016   515.7   504.3   21.7 4.24885
            381 0 29 2016  4179.3  4501.7  133.6 4.24885
            372 0 55 2016   938.9   981.1   65.7 4.24885
            457 0 58 2016  9521.5    9264 1087.7 4.24885
            363 1 82 2016   780.9   910.3    4.3 4.24885
            381 0 29 2017  4428.1  4328.6   72.5 4.33206
             11 1  8 2017  3569.9  3567.4  465.1 4.33206
            372 0 55 2017   962.6   980.1   58.6 4.33206
            363 1 82 2017   631.9   870.3      1 4.33206
            457 0 58 2017  8936.3  8830.3 1162.7 4.33206
             66 0 86 2017   451.9     438   21.7 4.33206
            372 0 55 2018   992.7  1049.5   13.9 4.13127
              3 0 46 2018   225.3   199.3    1.3 4.13127
            363 1 82 2018   263.8     676    1.1 4.13127
             11 1  8 2018  3845.7  3770.4  519.7 4.13127
             66 0 86 2018   430.7   420.7   18.3 4.13127
            381 0 24 2018  4725.3  4587.1   79.3 4.13127
             66 0 86 2019   652.5   553.3      5 4.03485
            381 0 24 2019  5990.1  5797.8  102.4 4.03485
            363 1 82 2019   244.1   574.6     .7 4.03485
            372 0 55 2019  1124.3  1062.9   19.4 4.03485
             11 1  8 2019  4360.9  4190.5  563.6 4.03485
              3 0 46 2019    90.9   116.9     .6 4.03485
            end
            Let me give some details on data. "list_unlist" is the dichotomous variable based on which I would like to split the sample. It corresponds to the listing status of a firm. "epu" is the logged value of the policy uncertainty index which is my variable of interest.

            *2* set the panel
            Code:
            xtset co_code year
            *3* Interacting the dichotomous indep variable (list_unlist) with epu (variable of interest)

            Code:
            *Model 1
             xtreg nsales c.epu##i.list_unlist totexp i.year, fe vce (robust)
            note: 1.list_unlist omitted because of collinearity
            note: 2019.year omitted because of collinearity
            
            Fixed-effects (within) regression               Number of obs     =         59
            Group variable: co_code                         Number of groups  =          9
            
            R-sq:                                           Obs per group:
                 within  = 0.2243                                         min =          2
                 between = 0.0866                                         avg =        6.6
                 overall = 0.0359                                         max =          8
            
                                                            F(8,8)            =          .
            corr(u_i, Xb)  = -0.9231                        Prob > F          =          .
            
                                                 (Std. Err. adjusted for 9 clusters in co_code)
            -----------------------------------------------------------------------------------
                              |               Robust
                       nsales |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
            ------------------+----------------------------------------------------------------
                          epu |  -1286.336    826.964    -1.56   0.158    -3193.319    620.6463
                1.list_unlist |          0  (omitted)
                              |
            list_unlist#c.epu |
                           1  |   4866.071   4820.913     1.01   0.342    -6250.973    15983.12
                              |
                       totexp |  -.1270702   .0610505    -2.08   0.071    -.2678528    .0137125
                              |
                         year |
                        2013  |  -300.2165   269.6369    -1.11   0.298    -922.0003    321.5672
                        2014  |  -505.1094   374.0232    -1.35   0.214    -1367.608    357.3897
                        2015  |  -1932.525   1901.131    -1.02   0.339    -6316.541    2451.491
                        2016  |  -1756.853   1459.892    -1.20   0.263     -5123.37    1609.664
                        2017  |  -538.8106   441.5805    -1.22   0.257    -1557.097    479.4758
                        2018  |  -395.9874   207.9833    -1.90   0.093    -875.5978    83.62288
                        2019  |          0  (omitted)
                              |
                        _cons |   2488.608   7015.075     0.35   0.732    -13688.18     18665.4
            ------------------+----------------------------------------------------------------
                      sigma_u |  10466.108
                      sigma_e |  2911.1689
                          rho |  .92818749   (fraction of variance due to u_i)
            -----------------------------------------------------------------------------------
            *4* Comparing the betas of 2 sub-samples run with firm fixed effects and year dummies

            Code:
            *Model 2 // Unlisted only
            xtreg nsales epu totexp i.year if list_unlist==0, fe vce (robust)
            note: 2019.year omitted because of collinearity
            
            Fixed-effects (within) regression               Number of obs     =         38
            Group variable: co_code                         Number of groups  =          6
            
            R-sq:                                           Obs per group:
                 within  = 0.9678                                         min =          2
                 between = 0.9999                                         avg =        6.3
                 overall = 0.9990                                         max =          8
            
                                                            F(5,5)            =          .
            corr(u_i, Xb)  = 0.8897                         Prob > F          =          .
            
                                            (Std. Err. adjusted for 6 clusters in co_code)
            ------------------------------------------------------------------------------
                         |               Robust
                  nsales |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
            -------------+----------------------------------------------------------------
                     epu |  -27.96775   71.78574    -0.39   0.713    -212.4989    156.5634
                  totexp |   .9886634   .0307205    32.18   0.000     .9096939    1.067633
                         |
                    year |
                   2013  |  -85.42669   67.44708    -1.27   0.261    -258.8049    87.95155
                   2014  |  -107.2635   58.81224    -1.82   0.128    -258.4452    43.91816
                   2015  |  -98.96452   85.06759    -1.16   0.297    -317.6377    119.7087
                   2016  |  -116.9838    128.671    -0.91   0.405     -447.743    213.7755
                   2017  |  -44.69972   41.06695    -1.09   0.326    -150.2657    60.86622
                   2018  |  -53.29005   41.59167    -1.28   0.256    -160.2048    53.62473
                   2019  |          0  (omitted)
                         |
                   _cons |   246.6458   433.9358     0.57   0.594    -868.8217    1362.113
            -------------+----------------------------------------------------------------
                 sigma_u |   74.05201
                 sigma_e |  119.62627
                     rho |  .27703647   (fraction of variance due to u_i)
            ------------------------------------------------------------------------------

            Code:
            *Model 3 // Listed only
            
            xtreg nsales epu totexp i.year if list_unlist==1, fe vce (robust)
            note: 2019.year omitted because of collinearity
            
            Fixed-effects (within) regression               Number of obs     =         21
            Group variable: co_code                         Number of groups  =          3
            
            R-sq:                                           Obs per group:
                 within  = 0.3474                                         min =          5
                 between = 0.9905                                         avg =        7.0
                 overall = 0.0137                                         max =          8
            
                                                            F(2,2)            =          .
            corr(u_i, Xb)  = -0.6053                        Prob > F          =          .
            
                                            (Std. Err. adjusted for 3 clusters in co_code)
            ------------------------------------------------------------------------------
                         |               Robust
                  nsales |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
            -------------+----------------------------------------------------------------
                     epu |   2747.531   4193.131     0.66   0.580    -15294.06    20789.12
                  totexp |  -.2335277    .047409    -4.93   0.039    -.4375124   -.0295431
                         |
                    year |
                   2013  |  -955.3542   987.6896    -0.97   0.435     -5205.04    3294.331
                   2014  |  -1539.947    1550.84    -0.99   0.425    -8212.674    5132.779
                   2015  |  -5828.003   7251.056    -0.80   0.506    -37026.78    25370.77
                   2016  |  -4264.672   5214.279    -0.82   0.499     -26699.9    18170.56
                   2017  |  -1056.421   1213.588    -0.87   0.476    -6278.069    4165.226
                   2018  |   -549.879   438.6975    -1.25   0.337    -2437.442    1337.684
                   2019  |          0  (omitted)
                         |
                   _cons |  -4461.183   17064.25    -0.26   0.818    -77882.71    68960.35
            -------------+----------------------------------------------------------------
                 sigma_u |  9267.4201
                 sigma_e |  5341.9396
                     rho |  .75060329   (fraction of variance due to u_i)
            ------------------------------------------------------------------------------
            My doubts
            *Qn1 Is it logical to compare two betas (Model 2 versus Model 3)?, If yes, how to do it, especially when you have fixed effects and year dummies (Though betas in model 2 and model 3 are insignificant)
            *Qn1 How do we interpret the difference between two betas (in plain language)?
            * Qn3 Unlike in the example, my original data have some 10000 unlisted firms and 2000 listed firms during the period 2003-2019. Does the "n" or other firm-level differences (say listed firms have better access to funds unlike unlisted ones) between those in the listed category and unlisted category affect the results, even if I put control variables and firm-fixed effects
            *Qn4 In research articles, I have seen authors using a matching procedure and then using mode1 (interaction) or model 2 /3 (subsamples). Is it required in the case of comparing betas of two-sub sample regression?

            As an aside, I tried also the codes based on the post "https://www.statalist.org/forums/forum/general-stata-discussion/general/1383761-comparing-fixed-effects-coefficients-between-two-groups?p=1383782#post1383782"
            but , when I tried this

            Code:
             xtreg nsales i.list_unlist##( c.epu c.totexp i.year), fe robust
            note: 1.list_unlist omitted because of collinearity
            note: 2019.year omitted because of collinearity
            note: 1.list_unlist#2019.year omitted because of collinearity
            
            * I assume interacting i.list_unlist##i.year is the correct way
            
            Fixed-effects (within) regression               Number of obs     =         59
            Group variable: co_code                         Number of groups  =          9
            
            R-sq:                                           Obs per group:
                 within  = 0.3621                                         min =          2
                 between = 0.1605                                         avg =        6.6
                 overall = 0.1472                                         max =          8
            
                                                            F(7,8)            =          .
            corr(u_i, Xb)  = -0.5752                        Prob > F          =          .
            
                                                    (Std. Err. adjusted for 9 clusters in co_code)
            --------------------------------------------------------------------------------------
                                 |               Robust
                          nsales |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
            ---------------------+----------------------------------------------------------------
                   1.list_unlist |          0  (omitted)
                             epu |  -27.96775   72.31216    -0.39   0.709    -194.7199    138.7844
                          totexp |   .9886634   .0309458    31.95   0.000     .9173023    1.060025
                                 |
                            year |
                           2013  |  -85.42669   67.94168    -1.26   0.244    -242.1005    71.24711
                           2014  |  -107.2635   59.24352    -1.81   0.108    -243.8793    29.35229
                           2015  |  -98.96452   85.69141    -1.15   0.281    -296.5693    98.64021
                           2016  |  -116.9838   129.6145    -0.90   0.393    -415.8754    181.9079
                           2017  |  -44.69972    41.3681    -1.08   0.311    -140.0947    50.69528
                           2018  |  -53.29005   41.89666    -1.27   0.239    -149.9039    43.32383
                           2019  |          0  (omitted)
                                 |
               list_unlist#c.epu |
                              1  |   2775.498   3306.267     0.84   0.426    -4848.768    10399.76
                                 |
            list_unlist#c.totexp |
                              1  |  -1.222191   .0485219   -25.19   0.000    -1.334083   -1.110299
                                 |
                list_unlist#year |
                         1 2013  |  -869.9275   781.5617    -1.11   0.298    -2672.212     932.357
                         1 2014  |  -1432.684   1223.973    -1.17   0.275    -4255.172    1389.804
                         1 2015  |  -5729.039   5716.703    -1.00   0.346    -18911.78    7453.702
                         1 2016  |  -4147.688   4112.498    -1.01   0.343    -13631.12    5335.749
                         1 2017  |  -1011.722   957.5744    -1.06   0.322    -3219.892    1196.449
                         1 2018  |   -496.589   348.3571    -1.43   0.192    -1299.902     306.724
                         1 2019  |          0  (omitted)
                                 |
                           _cons |  -1429.022   4796.225    -0.30   0.773    -12489.14    9631.092
            ---------------------+----------------------------------------------------------------
                         sigma_u |  4904.1651
                         sigma_e |  2898.8164
                             rho |  .74107525   (fraction of variance due to u_i)
            --------------------------------------------------------------------------------------
            
            . test  1.list_unlist#epu 1.1.list_unlist#totexp 1.list_unlist#1.year
            1.list_unlist#1.year not found
            I know I have asked too much, but if you or any members can help me in this it will be very helpful to me

            Comment


            • #7
              With your data example, the variable "epu" is collinear with the fixed effects, so we cannot obtain any useful results. In xtreg, fe, you need to change the base level(s) of the FE indicator(s) and check whether the coefficients of any of your variables change to determine if they are collinear with the fixed effects. Otherwise, install reghdfe from SSC which will instantaneously reveal if any such collinearity exists. Here is what I get with your data:

              Code:
              . reghdfe nsales epu totexp if list_unlist==0, a(co_code year) vce(robust)
              note: epu is probably collinear with the fixed effects (all partialled-out value
              > s are close to zero; tol = 1.0e-09)
              (MWFE estimator converged in 6 iterations)
              note: epu omitted because of collinearity
              
              HDFE Linear regression                            Number of obs   =         38
              Absorbing 2 HDFE groups                           F(   1,     24) =     361.28
                                                                Prob > F        =     0.0000
                                                                R-squared       =     0.9991
                                                                Adj R-squared   =     0.9986
                                                                Within R-sq.    =     0.9521
                                                                Root MSE        =   119.6263
              
              ------------------------------------------------------------------------------
                           |               Robust
                    nsales |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
              -------------+----------------------------------------------------------------
                       epu |          0  (omitted)
                    totexp |   .9886634    .052015    19.01   0.000     .8813097    1.096017
                     _cons |   53.75194   131.0188     0.41   0.685    -216.6577    324.1615
              ------------------------------------------------------------------------------
              
              Absorbed degrees of freedom:
              -----------------------------------------------------+
               Absorbed FE | Categories  - Redundant  = Num. Coefs |
              -------------+---------------------------------------|
                   co_code |         6           0           6     |
                      year |         8           1           7     |
              -----------------------------------------------------+
              That said, this should be due to the limited sample from dataex. In your full sample, I do not think that this is the case, but you should check. Using the example in #1 and including year dummies, it appears that Stata omits a year dummy from each group, which is what we want. You can choose which dummies to omit, but since the dummy coefficients are of no use to us (as these are nuisance parameters), all we need to confirm is that a dummy in each group is omitted. You can proceed after confirming that the coefficient estimates from the separate and joint regressions are the same.

              Code:
              webuse grunfeld
              xtreg invest mvalue kstock i.year if inrange(company, 1, 5), fe robust nonest
              xtreg invest mvalue kstock i.year if inrange(company, 6, 10), fe robust nonest
              gen group= cond(inrange(company, 6, 10), 1, 0)
              xtreg invest i.group#(c.mvalue c.kstock i.year), fe robust nonest

              *Qn1 Is it logical to compare two betas (Model 2 versus Model 3)?, If yes, how to do it, especially when you have fixed effects and year dummies (Though betas in model 2 and model 3 are insignificant)

              You are the researcher, so you make this call. Cross-equation tests of hypotheses are done often, and that is one of the reasons for the existence of the command suest.



              How do we interpret the difference between two betas (in plain language)?

              Comparing "variable A" in group 1 versus group 2: There is (or there is not) a statistical difference in the estimated coefficient of variable A between the two groups. So if the variable is the level of investment and one group is manufacturing firms and another group is firms in the service industry, a difference indicates that the estimated effect of investment on the dependent variable is greater for manufacturing firms compared to firms in the service industry, for example.


              Unlike in the example, my original data have some 10000 unlisted firms and 2000 listed firms during the period 2003-2019. Does the "n" or other firm-level differences (say listed firms have better access to funds unlike unlisted ones) between those in the listed category and unlisted category affect the results, even if I put control variables and firm-fixed effects

              Differences in sample sizes between groups do not inhibit cross-equation hypothesis testing. These sample sizes are perfectly fine.


              In research articles, I have seen authors using a matching procedure and then using mode1 (interaction) or model 2 /3 (subsamples). Is it required in the case of comparing betas of two-sub sample regression?

              Matching is used if one suspects selection bias (non-random sampling), not as a way to successfully implement the test as stated in the previous point. There should be a discussion of why the authors used matched samples.

              Comment


              • #8
                Andrew Musau Thanks for the detailed comments. Actually, your explanation related to multicollinearity unboxes some other doubts in my mind. As you said, "epu" is collinear with the fixed effects". The variable epu is constant for all firms during a particular year (like a macro variable that is constant across all firms for a given year). Similarly, I have 2 other macro variables (GDP, Inflation etc), If that is the case, which one should we NOT use, firm fixed effects or year fixed effects?

                Code:
                *Model 1 Panel Regression without year dummies
                Code:
                xtreg casheq_ta_w epu  ///
                > tcred_ta_w inven_ta_w ///
                > size_w lever_w nw_ta_w ///
                > ncfo_ta_w sgrowth_w pbitnet_ta_w fcfvol age ///
                > i.rd_dum i.divid_dum ///
                > gdpgrowthannual realinterestrate, ///
                > fe vce (robust)
                
                Fixed-effects (within) regression               Number of obs     =     43,849
                Group variable: id                              Number of groups  =      9,215
                
                R-sq:                                           Obs per group:
                     within  = 0.0888                                         min =          1
                     between = 0.0566                                         avg =        4.8
                     overall = 0.0595                                         max =         15
                
                                                                F(15,9214)        =      49.77
                corr(u_i, Xb)  = -0.1738                        Prob > F          =     0.0000
                
                                                     (Std. Err. adjusted for 9,215 clusters in id)
                ----------------------------------------------------------------------------------
                                 |               Robust
                     casheq_ta_w |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
                -----------------+----------------------------------------------------------------
                             epu |   .0020123   .0011565     1.74   0.082    -.0002547    .0042793
                      tcred_ta_w |  -.1029334   .0071142   -14.47   0.000    -.1168788   -.0889881
                      inven_ta_w |  -.1528584   .0090783   -16.84   0.000    -.1706539    -.135063
                          size_w |   .0036773   .0017013     2.16   0.031     .0003423    .0070122
                         lever_w |    .038957   .0070198     5.55   0.000     .0251967    .0527173
                         nw_ta_w |   .1058181   .0089393    11.84   0.000     .0882952    .1233411
                       ncfo_ta_w |   .0541335   .0042804    12.65   0.000      .045743    .0625241
                       sgrowth_w |   .0001374   .0003459     0.40   0.691    -.0005406    .0008155
                    pbitnet_ta_w |   .0353684   .0075052     4.71   0.000     .0206565    .0500804
                          fcfvol |   .0206033   .0083799     2.46   0.014     .0041767    .0370298
                             age |   .0011005   .0032243     0.34   0.733    -.0052199    .0074209
                        1.rd_dum |  -.0046955   .0020678    -2.27   0.023    -.0087488   -.0006421
                     1.divid_dum |   .0003651   .0017673     0.21   0.836    -.0030992    .0038294
                gdpgrowthannual |   -.000142   .0001997    -0.71   0.477    -.0005336    .0002495
                realinterestrate |   .0000301   .0001483     0.20   0.839    -.0002605    .0003208
                           _cons |   .0052747   .0127428     0.41   0.679     -.019704    .0302535
                -----------------+----------------------------------------------------------------
                         sigma_u |   .0883477
                         sigma_e |   .0512859
                             rho |  .74795376   (fraction of variance due to u_i)
                 
                *Model 2 Panel Regression with year dummies
                 xtreg casheq_ta_w epu  ///
                > tcred_ta_w inven_ta_w ///
                > size_w lever_w nw_ta_w ///
                > ncfo_ta_w sgrowth_w pbitnet_ta_w fcfvol age ///
                > i.rd_dum i.divid_dum  ///
                > gdpgrowthannual realinterestrate i.year, ///
                > fe vce (robust)
                note: 2017.year omitted because of collinearity
                note: 2018.year omitted because of collinearity
                note: 2019.year omitted because of collinearity
                
                Fixed-effects (within) regression               Number of obs     =     43,849
                Group variable: id                              Number of groups  =      9,215
                
                R-sq:                                           Obs per group:
                     within  = 0.0915                                         min =          1
                     between = 0.0549                                         avg =        4.8
                     overall = 0.0580                                         max =         15
                
                                                                F(26,9214)        =      30.76
                corr(u_i, Xb)  = -0.1777                        Prob > F          =     0.0000
                
                                                     (Std. Err. adjusted for 9,215 clusters in id)
                ----------------------------------------------------------------------------------
                                 |               Robust
                     casheq_ta_w |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
                -----------------+----------------------------------------------------------------
                             epu |   .0289869   .0266816     1.09   0.277    -.0233148    .0812887
                      tcred_ta_w |  -.1051429   .0071329   -14.74   0.000     -.119125   -.0911608
                      inven_ta_w |  -.1555197    .009126   -17.04   0.000    -.1734087   -.1376308
                          size_w |   .0025004   .0019821     1.26   0.207     -.001385    .0063857
                         lever_w |   .0393737    .007046     5.59   0.000      .025562    .0531854
                         nw_ta_w |   .1040635   .0088536    11.75   0.000     .0867085    .1214186
                       ncfo_ta_w |   .0537861   .0042986    12.51   0.000       .04536    .0622123
                       sgrowth_w |   .0000889   .0003426     0.26   0.795    -.0005828    .0007605
                    pbitnet_ta_w |   .0389794   .0075905     5.14   0.000     .0241004    .0538584
                          fcfvol |   .0223561   .0083866     2.67   0.008     .0059164    .0387958
                             age |  -.0057241   .0043989    -1.30   0.193    -.0143469    .0028987
                        1.rd_dum |  -.0049203   .0020754    -2.37   0.018    -.0089886    -.000852
                     1.divid_dum |   .0010818   .0017588     0.62   0.539    -.0023658    .0045294
                 gdpgrowthannual |  -.0038561   .0048812    -0.79   0.430    -.0134244    .0057122
                realinterestrate |  -.0006379   .0012242    -0.52   0.602    -.0030376    .0017618
                                 |
                            year |
                           2006  |   .0092299   .0101424     0.91   0.363    -.0106516    .0291113
                           2007  |   .0029203   .0086488     0.34   0.736    -.0140332    .0198738
                           2008  |  -.0253356   .0229513    -1.10   0.270    -.0703252    .0196541
                           2009  |  -.0283594    .016418    -1.73   0.084    -.0605424    .0038236
                           2010  |  -.0166177   .0118901    -1.40   0.162    -.0399251    .0066896
                           2011  |  -.0213888   .0263177    -0.81   0.416    -.0729773    .0301997
                           2012  |  -.0328793   .0360859    -0.91   0.362    -.1036157    .0378572
                           2013  |  -.0277781   .0279171    -1.00   0.320    -.0825018    .0269455
                           2014  |  -.0131532   .0095195    -1.38   0.167    -.0318136    .0055071
                           2015  |   -.004309   .0020219    -2.13   0.033    -.0082724   -.0003457
                           2016  |    .006714   .0086744     0.77   0.439    -.0102897    .0237178
                           2017  |          0  (omitted)
                           2018  |          0  (omitted)
                           2019  |          0  (omitted)
                                 |
                           _cons |  -.0489242   .0615444    -0.79   0.427    -.1695648    .0717163
                -----------------+----------------------------------------------------------------
                         sigma_u |  .08846673
                         sigma_e |  .05121681
                             rho |  .74896828   (fraction of variance due to u_i)
                ----------------------------------------------------------------------------------
                
                . testparm i.year
                
                 ( 1)  2006.year = 0
                 ( 2)  2007.year = 0
                 ( 3)  2008.year = 0
                 ( 4)  2009.year = 0
                 ( 5)  2010.year = 0
                 ( 6)  2011.year = 0
                 ( 7)  2012.year = 0
                 ( 8)  2013.year = 0
                 ( 9)  2014.year = 0
                 (10)  2015.year = 0
                 (11)  2016.year = 0
                
                       F( 11,  9214) =    6.43
                            Prob > F =    0.0000
                
                *Model 3 With reghfde
                reghdfe casheq_ta_w epu  ///
                > tcred_ta_w inven_ta_w ///
                > size_w lever_w nw_ta_w ///
                > ncfo_ta_w sgrowth_w pbitnet_ta_w fcfvol age ///
                > i.rd_dum i.divid_dum  ///
                > gdpgrowthannual realinterestrate , a(co_code year ) vce(robust)
                (dropped 1502 singleton observations)
                note: epu is probably collinear with the fixed effects (all partialled-out values are close to zero; tol = 1.0e-09)
                note: gdpgrowthannual is probably collinear with the fixed effects (all partialled-out values are close to zero; tol = 1.
                > 0e-09)
                note: realinterestrate is probably collinear with the fixed effects (all partialled-out values are close to zero; tol = 1
                > .0e-09)
                (MWFE estimator converged in 9 iterations)
                note: epu omitted because of collinearity
                note: gdpgrowthannual omitted because of collinearity
                note: realinterestrate omitted because of collinearity
                
                HDFE Linear regression                            Number of obs   =     42,347
                Absorbing 2 HDFE groups                           F(  12,  34608) =     113.60
                                                                  Prob > F        =     0.0000
                                                                  R-squared       =     0.7490
                                                                  Adj R-squared   =     0.6928
                                                                  Within R-sq.    =     0.0889
                                                                  Root MSE        =     0.0512
                
                ----------------------------------------------------------------------------------
                                 |               Robust
                     casheq_ta_w |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
                -----------------+----------------------------------------------------------------
                             epu |          0  (omitted)
                      tcred_ta_w |  -.1051429   .0049939   -21.05   0.000    -.1149311   -.0953546
                      inven_ta_w |  -.1555197   .0062935   -24.71   0.000    -.1678553   -.1431842
                          size_w |   .0025004   .0013038     1.92   0.055    -.0000552    .0050559
                         lever_w |   .0393737   .0049088     8.02   0.000     .0297522    .0489952
                         nw_ta_w |   .1040635   .0059825    17.39   0.000     .0923376    .1157895
                       ncfo_ta_w |   .0537861   .0040273    13.36   0.000     .0458926    .0616797
                       sgrowth_w |   .0000889   .0003335     0.27   0.790    -.0005648    .0007425
                    pbitnet_ta_w |   .0389794   .0064667     6.03   0.000     .0263044    .0516544
                          fcfvol |   .0223561   .0067236     3.33   0.001     .0091776    .0355346
                             age |  -.0057241   .0029642    -1.93   0.053     -.011534    .0000858
                        1.rd_dum |  -.0049203   .0017066    -2.88   0.004    -.0082653   -.0015753
                     1.divid_dum |   .0010818   .0014255     0.76   0.448    -.0017123    .0038758
                 gdpgrowthannual |          0  (omitted)
                realinterestrate |          0  (omitted)
                           _cons |   .0425035   .0129285     3.29   0.001     .0171632    .0678438
                ----------------------------------------------------------------------------------
                
                Absorbed degrees of freedom:
                -----------------------------------------------------+
                 Absorbed FE | Categories  - Redundant  = Num. Coefs |
                -------------+---------------------------------------|
                     co_code |      7713           0        7713     |
                        year |        15           1          14     |
                -----------------------------------------------------+
                .
                As I am not learned enough about choosing the right econometric model based on theory or readings, which one of the above is correct (at least from the point of view of empirics). For instance, had if I were not aware of "reghfde",I would have chosen model 2 as it says, time dummies are required (based on testparm) and concluded that EPU impacts the dependent variable positively (but not statistically significant-sorry for using the term).

                Now coming back to your well explained code
                webuse grunfeld xtreg invest mvalue kstock i.year if inrange(company, 1, 5), fe robust nonest xtreg invest mvalue kstock i.year if inrange(company, 6, 10), fe robust nonest gen group= cond(inrange(company, 6, 10), 1, 0) xtreg invest i.group#(c.mvalue c.kstock i.year), fe robust nonest
                , I have some issues.

                I cant use the inrange function as I dont have a ordered sequence of numbers for private firm (indicated by 0 in list_unlist category) and public firms. In that case how to use inrange function as well group function? Also, a particular firm may change its status in an year, for instance, in the year 2008, firm "1232" will be having 0 (not listed) status but in the year 2009 it will have status 1 (listed). Is there a way to modify the code in my context, for instance numbering all private firms from 1 to 20000 and rest as public.
                Am I making sense (sorry if my wordings are vague)?
                Last edited by lal mohan kumar; 12 Apr 2021, 06:12.

                Comment


                • #9
                  If you include firm and time fixed effects, then your variables must vary across firms and over time. So you have to consider a model that excludes the omitted variables if you are employing the two-way FE estimator.

                  As I am not learned enough about choosing the right econometric model based on theory or readings, which one of the above is correct (at least from the point of view of empirics). For instance, had if I were not aware of "reghfde",I would have chosen model 2 as it says, time dummies are required (based on testparm) and concluded that EPU impacts the dependent variable positively (but not statistically significant-sorry for using the term).

                  As your question is no longer about cross-equation tests of hypothesis, which is the topic of this thread, I would advise you to start a new thread and ask specifically about model choice. In this way, you will get a broader audience.

                  Comment


                  • #10
                    regarding indicator variable to compare coefficiants between groups, I would agree this is an excellent general approach. the indicator shoud probably be completely interacted (simple and interaction effects with ## instead of #):
                    Code:
                    gen group= cond(inrange(company, 6, 10), 1, 0)
                    xtreg invest c.mvalue##i.group c.kstock##i.group, fe robust nonest

                    Comment


                    • #11
                      Thanks Andrew Musau @ George Hoffman. I don't know whether posting the question on appropriateness of model in the forum again is appreciated or not. I shall give a try

                      Comment


                      • #12
                        I don't know whether posting the question on appropriateness of model in the forum again is appreciated or not.

                        You can and if you sample a couple of posts, you will discover that many people just do that.

                        Comment


                        • #13
                          Thanks Andrew Musau. Before I close this post, is there a way to "number all firms (both listed and unlisted) from 1 to n in such a way that, certain range will be applicable for unlisted firms (say 1 to 20000) and remaining will be applicable for listed firms (20001 to 25000). If I could this, I think I could use the code you mentioned. Based on my post #6
                          i tried
                          Code:
                          bys co_code: gen n1=_n if list_unlist==0
                          , but that is wrong way I think.

                          Comment


                          • #14
                            Do you mean observations or firms? If observations

                            Code:
                            sort list_unlist
                            gen wanted=_n
                            If firms:

                            Code:
                            sort list_unlist co_code
                            gen wanted= sum(co_code!=co_code[_n-1])

                            Comment


                            • #15
                              Thanks a lot Andrew Musau. That works perfectly. My codes nowhere reached in this logic. What does the second code say in terms of plain language? Summing from.................

                              Comment

                              Working...
                              X