Announcement

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

  • groupwise xtreg fe estimation with robust errors

    Hi,
    I have recently started using Stata for analysis and currently using Stata 16.

    I have a panel dataset with N=73 and T= 40 .
    I am trying to run an xtreg with fixed effects estimator and robust standard errors. Below is a small sample from my dataset.


    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float BEMEclass str58 conm float company int time float(LnBEME_t DOL_t DFL_t Size_t Dtime)
    1 "PRIME HOSPITALITY CORP"       49 19791  -1.8245335 -1.1581018  -1.1047124  3.917138 1
    1 "WRATHER CORP"                 72 19791   -.8752389  -.7245747   .05811504 3.5747864 1
    2 "HOLIDAY CORP"                 25 19791    .1195223  -.3968062   -.6217715  6.209769 1
    2 "HILTON WORLDWIDE HOLDINGS"    24 19791    -.740373  .06960483    .2070304  6.505733 1
    2 "LA QUINTA INNS INC"           41 19791   -.5981131   -.775349  -.55409545  3.951555 1
    2 "UNITED INNS INC"              69 19791  .036893275 -.06610228 .0005845402  3.896206 1
    . "INTEGRA A HOTEL & REST"       34 19791           .          .           .         . 1
    2 "STARWOOD HOTELS&RESORTS WRLD" 61 19791   .05225944  -.2438383    .8940904  3.253161 1
    3 "SONESTA INTL HOTELS  -CL A"   58 19791     .607038   .6507948    .2281304 2.0617862 1
    . "INTEGRA A HOTEL & REST"       34 19792           .          .           .         . 1
    3 "SONESTA INTL HOTELS  -CL A"   58 19792    .4997963   .7421679    .5022304 2.2415597 1
    2 "HILTON WORLDWIDE HOLDINGS"    24 19792   -.7580439  .09438264    .2898394  6.611725 1
    2 "STARWOOD HOTELS&RESORTS WRLD" 61 19792 -.069438085  -.1728168    .9605785  3.462637 1
    1 "PRIME HOSPITALITY CORP"       49 19792  -1.4942898 -1.1155328  -1.0496894 3.6879525 1
    2 "LA QUINTA INNS INC"           41 19792  -.57335716  -.4596104   .09961627  4.029958 1
    2 "UNITED INNS INC"              69 19792   .05421631 -.05443614    .0904639   3.92888 1
    1 "WRATHER CORP"                 72 19792   -.9886482 -.28205767   .29344016  3.703078 1
    2 "HOLIDAY CORP"                 25 19792   .03862377  -.3432194  -.02962402  6.325035 1
    1 "WRATHER CORP"                 72 19793   -.9851251  -.2139741    .2554611 3.7035215 1
    . "INTEGRA A HOTEL & REST"       34 19793           .          .           .         . 1
    2 "STARWOOD HOTELS&RESORTS WRLD" 61 19793  -.13669619 -.28015187    .8684896   3.53726 1
    1 "PRIME HOSPITALITY CORP"       49 19793  -1.3247973 -1.0956434  -1.2319292  3.633464 1
    2 "HILTON WORLDWIDE HOLDINGS"    24 19793   -.7674752  .06290034    .3157985   6.68789 1
    2 "LA QUINTA INNS INC"           41 19793   -.6475502  -.3386415    .1960283  4.166412 1
    2 "HOLIDAY CORP"                 25 19793 -.017402153  -.2983353 -.011736955  6.448889 1
    2 "UNITED INNS INC"              69 19793  -.17868084 -.04132706   .20555335  4.177835 1
    3 "SONESTA INTL HOTELS  -CL A"   58 19793    .3476222   .7199947   .18339583  2.424404 1
    3 "SONESTA INTL HOTELS  -CL A"   58 19794   .49936935   .7884633    .3314063 2.2671385 1
    . "INTEGRA A HOTEL & REST"       34 19794           . -.02301322    .4371954         . 1
    2 "UNITED INNS INC"              69 19794   -.2555085 -.06454376   -.1651368  4.166851 1
    end
    Some explanations about the variables:
    The 'BEMEclass' is a grouping variable based on the variable 'LnBEME_t'. There are 3 classes.
    'company' is the numerical variable for company name 'conm'
    'time' represents the year and quarter
    'Dtime' is a dummy variable for US business cycle.

    My dependent variable is 'LnBEME_t'
    Independent variable is 'DOL_t'
    Control variables are 'DFL_t' 'Size_t' and 'Dtime'

    I am conducting a class effect analysis and hence would like to run the following model by my grouping variable 'BEMEclass':

    Code:
    by BEMEclass: xtreg LnBEME_t DOL_t DFL_t Size_t Dtime, fe vce (robust)
    but Stata returned the following error :
    Code:
    the by prefix may not be used with vce() option
    Stata returned a similar error when I tried to run the model using an 'if' statement:
    Code:
     xtreg LnBEME_t DOL_t DFL_t Size_t Dtime, fe vce (robust) if BEMEclass ==1
    Error message from Stata -
    Code:
    option if not allowed
    r(198);
    Could you please help me to understand what I am doing wrong and how I can correct my code?

    When I do the regressions by group, I would also like to compare the slopes for my 3 groups to check whether they are statistically different from one another (My hypothesis says that 'The relationship between LnBEME_t and DOL_t are different in different classes'). Would you be able to guide me how I could achieve this?

    Appreciate you help and thank you in advance for your guidance!

  • #2
    Stata, in fact, does not allow the vce() option of -xtreg-, however, specified, when run with -by:-. I'm not certain I know why that is, but I have some ideas that I will not lay out here. Suffice it to say, when Stata goes out of its way to now allow some combination of things, in my experience, there has always been a good reason why that combination of things is inadmissible. So it is probably not a good idea to find a work around for something that you probably shouldn't do in the first place. I'd just omit the -vce(robust)- and proceed.

    That said, the problem you are having with the other command using the -if- option is a generic one: the -if- clause must precede the comma; you have it following the comma, where it is not supposed to be.

    Comment


    • #3
      Thank you so much Clyde! I was able to get the analysis by group.

      I would also like to compare the slopes for my 3 groups to check whether they are statistically different from one another (My hypothesis says that 'The relationship between LnBEME_t and DOL_t are different in different classes'). Would you be able to guide me how I could achieve this?

      Appreciate your kind help.

      Comment


      • #4
        Code:
        xtreg LnBEME_t i.BEME_class##c.(DOL_t DFL_t Size_t Dtime), fe
        is the starting point. Note: I'm assuming here that DOL_t, DFL_t, Size_t and Dtime are all continuous variables. If, for example, Dtime is discrete, then you would change the code to:

        Code:
        xtreg LnBEME_t i.BEME_class##(c.DOL_t c.DFL_t c.Size_t i.Dtime), fe
        You can test the hypothesis that you mention with:
        Code:
        test 1.BEME_class#DOL_t 2.BEME_class#DOL_t 3.BEME_class#DOL_t
        But you probably shouldn't. The American Statistical Association has recommended abandoning the use of significance testing and recommends instead estimating group differences and their confidence intervals or standard errors. See https://www.tandfonline.com/doi/full...5.2019.1583913. So to do it the up-to-date way:

        Code:
        margins BEME_class, dydx(DOL_t) noestimcheck
        will give you the marginal effect of DOL_t in each group along with its standard error and confidence intervals. (It will also give you p-values for the test that each such marginal effect is 0, but those are probably of little or no interest even to those who still want to do null hypothesis testing.)

        Comment


        • #5
          Thank you once again Clyde!

          Comment

          Working...
          X