Announcement

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

  • t-tests under heteroskedasticity

    Hi everyone,
    I am trying to analyse how the variable "score" varies over time. I have used the following regression:
    xtset country_num year
    xtreg score second_period third_period, fe vce(robust)
    where second_period and third_period are dummy variables capturing two different periods in my time span.
    If I'm not mistaken, specifying the option vce(robust) means the model employs Arellano’s estimator, which corrects for both heteroskedasticity and within-group serial correlation. I also conducted a test for heteroskedasticity through the xttest3 command and rejected homoskedasticity.
    I would now like to test if the dummy for the second period is statistically different from the dummy for the third period. I think I should use the following code: test second_period = third_period. However, to perform a t-test I need homoskedasticity.
    How can I test if the two dummies are different in the presence of heteroskedasticity and serial correlation?
    Thanks in advance!





  • #2
    Alfonso:
    if you detect heteroskedasticity and/or autocorrelation after -xtreg- you can invoke either -robust- or -vce(cluster clusterid)- options, as they do the very same job.
    As far as I know, Arellano-Bond estimator deals with dynamic panels.
    That said, -test- embodies the standard error mode, as you can see from the following toy-example:
    Code:
    . use "https://www.stata-press.com/data/r16/nlswork.dta"
    (National Longitudinal Survey.  Young Women 14-26 years of age in 1968)
    
    . xtreg ln_wage c.age##c.age, vce(cluster idcode)
    
    Random-effects GLS regression                   Number of obs     =     28,510
    Group variable: idcode                          Number of groups  =      4,710
    
    R-sq:                                           Obs per group:
         within  = 0.1087                                         min =          1
         between = 0.1015                                         avg =        6.1
         overall = 0.0870                                         max =         15
    
                                                    Wald chi2(2)      =    1258.33
    corr(u_i, X)   = 0 (assumed)                    Prob > chi2       =     0.0000
    
                                 (Std. Err. adjusted for 4,710 clusters in idcode)
    ------------------------------------------------------------------------------
                 |               Robust
         ln_wage |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             age |   .0590339   .0041049    14.38   0.000     .0509884    .0670795
                 |
     c.age#c.age |  -.0006758   .0000688    -9.83   0.000    -.0008107    -.000541
                 |
           _cons |   .5479714   .0587198     9.33   0.000     .4328826    .6630601
    -------------+----------------------------------------------------------------
         sigma_u |   .3654049
         sigma_e |  .30245467
             rho |  .59342665   (fraction of variance due to u_i)
    ------------------------------------------------------------------------------
    
    . test age=c.age#c.age
    
     ( 1)  age - c.age#c.age = 0
    
               chi2(  1) =  204.73
             Prob > chi2 =    0.0000
    
    . xtreg ln_wage c.age##c.age
    
    Random-effects GLS regression                   Number of obs     =     28,510
    Group variable: idcode                          Number of groups  =      4,710
    
    R-sq:                                           Obs per group:
         within  = 0.1087                                         min =          1
         between = 0.1015                                         avg =        6.1
         overall = 0.0870                                         max =         15
    
                                                    Wald chi2(2)      =    3388.51
    corr(u_i, X)   = 0 (assumed)                    Prob > chi2       =     0.0000
    
    ------------------------------------------------------------------------------
         ln_wage |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             age |   .0590339   .0027172    21.73   0.000     .0537083    .0643596
                 |
     c.age#c.age |  -.0006758   .0000451   -15.00   0.000    -.0007641   -.0005876
                 |
           _cons |   .5479714   .0397476    13.79   0.000     .4700675    .6258752
    -------------+----------------------------------------------------------------
         sigma_u |   .3654049
         sigma_e |  .30245467
             rho |  .59342665   (fraction of variance due to u_i)
    ------------------------------------------------------------------------------
    
    . test age=c.age#c.age
    
     ( 1)  age - c.age#c.age = 0
    
               chi2(  1) =  467.37
             Prob > chi2 =    0.0000
    
    .
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Originally posted by Alfonso Castelli View Post
      I think I should use the following code: test second_period = third_period. However, to perform a t-test I need homoskedasticity.
      As Carlo implied, you can go ahead with -test- after your estimation command. You can use a paired t-test, too. (See below.) I'm not sure where you got the notion about requiring homoskedasticity in that context.

      .ÿ
      .ÿversionÿ17.0

      .ÿ
      .ÿclearÿ*

      .ÿ
      .ÿsetÿseedÿ`=strreverse("1618963")'

      .ÿ
      .ÿprogramÿdefineÿsimem,ÿrclass
      ÿÿ1.ÿÿÿÿÿÿÿÿÿversionÿ17.0
      ÿÿ2.ÿÿÿÿÿÿÿÿÿsyntaxÿ,ÿ[Delta(realÿ0)]
      ÿÿ3.ÿ
      .ÿÿÿÿÿÿÿÿÿdropÿ_all
      ÿÿ4.ÿÿÿÿÿÿÿÿÿdrawnormÿout1ÿout2ÿout3,ÿdoubleÿsd(1ÿ2ÿ4)ÿmeans(0ÿ0ÿ`delta')ÿ///
      >ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿcorr(1ÿ0.5ÿ0.25ÿ\ÿ0.5ÿ1ÿ0.5ÿ\ÿ0.25ÿ0.5ÿ1)ÿn(24)
      ÿÿ5.ÿÿÿÿÿÿÿÿÿgenerateÿbyteÿpidÿ=ÿ_n
      ÿÿ6.ÿ
      .ÿÿÿÿÿÿÿÿÿttestÿout2ÿ=ÿout3
      ÿÿ7.ÿÿÿÿÿÿÿÿÿtempnameÿtt
      ÿÿ8.ÿÿÿÿÿÿÿÿÿscalarÿdefineÿ`tt'ÿ=ÿr(p)ÿ<ÿ0.05
      ÿÿ9.ÿ
      .ÿÿÿÿÿÿÿÿÿreshapeÿlongÿout,ÿi(pid)ÿj(tim)
      ÿ10.ÿ
      .ÿÿÿÿÿÿÿÿÿxtregÿoutÿi.tim,ÿi(pid)ÿfe
      ÿ11.ÿÿÿÿÿÿÿÿÿtestÿ2.timÿ=ÿ3.tim
      ÿ12.ÿÿÿÿÿÿÿÿÿtempnameÿna
      ÿ13.ÿÿÿÿÿÿÿÿÿscalarÿdefineÿ`na'ÿ=ÿr(p)ÿ<ÿ0.05
      ÿ14.ÿ
      .ÿÿÿÿÿÿÿÿÿxtregÿoutÿi.tim,ÿi(pid)ÿfeÿvce(robust)
      ÿ15.ÿÿÿÿÿÿÿÿÿtestÿ2.timÿ=ÿ3.tim
      ÿ16.ÿÿÿÿÿÿÿÿÿreturnÿscalarÿroÿ=ÿr(p)ÿ<ÿ0.05
      ÿ17.ÿÿÿÿÿÿÿÿÿreturnÿscalarÿttÿ=ÿ`tt'
      ÿ18.ÿÿÿÿÿÿÿÿÿreturnÿscalarÿnaÿ=ÿ`na'
      ÿ19.ÿend

      .ÿ
      .ÿprogramÿdefineÿsumem
      ÿÿ1.ÿÿÿÿÿÿÿÿÿversionÿ17.0
      ÿÿ2.ÿÿÿÿÿÿÿÿÿsyntaxÿ[anything(name=delta)]
      ÿÿ3.ÿ
      .ÿÿÿÿÿÿÿÿÿlocalÿdeltaÿ=ÿcond(mi("`delta'"),ÿ"",ÿ"d(`delta')")
      ÿÿ4.ÿÿÿÿÿÿÿÿÿquietlyÿsimulateÿttÿ=ÿr(tt)ÿnaÿ=ÿr(na)ÿroÿ=ÿr(ro),ÿreps(5000):ÿsimemÿ,ÿ`delta'
      ÿÿ5.ÿÿÿÿÿÿÿÿÿ
      .ÿÿÿÿÿÿÿÿÿsummarizeÿna,ÿmeanonly
      ÿÿ6.ÿÿÿÿÿÿÿÿÿdisplayÿinÿsmclÿasÿtextÿ"Conventionalÿfixed-effectsÿregression"ÿ_column(60)ÿasÿresultÿ%04.2fÿr(mean)
      ÿÿ7.ÿÿÿÿÿÿÿÿÿ
      .ÿÿÿÿÿÿÿÿÿsummarizeÿro,ÿmeanonlyÿ
      ÿÿ8.ÿÿÿÿÿÿÿÿÿdisplayÿinÿsmclÿasÿtextÿ"Clusterÿrobustÿstandardÿerrorÿfixed-effectsÿregression"ÿ_column(60)ÿasÿresultÿ%04.2fÿr(mean)
      ÿÿ9.ÿ
      .ÿÿÿÿÿÿÿÿÿsummarizeÿtt,ÿmeanonly
      ÿ10.ÿÿÿÿÿÿÿÿÿdisplayÿinÿsmclÿasÿtextÿ"Pairedÿt-test"ÿ_column(60)ÿasÿresultÿ%04.2fÿr(mean)
      ÿ11.ÿend

      .ÿ
      .ÿ//ÿTestÿsize
      .ÿsumem
      Conventionalÿfixed-effectsÿregressionÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ0.08
      Clusterÿrobustÿstandardÿerrorÿfixed-effectsÿregressionÿÿÿÿÿ0.05
      Pairedÿt-testÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ0.05

      .ÿ
      .ÿ//ÿRelativeÿpower
      .ÿsumemÿ2
      Conventionalÿfixed-effectsÿregressionÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ0.84
      Clusterÿrobustÿstandardÿerrorÿfixed-effectsÿregressionÿÿÿÿÿ0.77
      Pairedÿt-testÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ0.78

      .ÿ
      .ÿexit

      endÿofÿdo-file


      .

      Comment

      Working...
      X