Announcement

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

  • Ttest order when assessing difference

    Hi,

    I have a question that I was hoping someone could help with regarding the order in which Stata completes a test when looking at differences.

    My data set has got a field for 'pre' or 'post' (see data table below).

    Pre is coded as zero (0) and post is coded as one (1).

    Question: With the test, will stata take the pre values as they are coded as 0 and subtract the post values?
    ie a negative number indicates that the post values are higher?


    This is my code:
    **T tests of Volume, trades, num of bids and asks, messages, bid ask spread, bid ask volume FOR ANNOUNCEMENT days
    ** Price sensitive vs non price sensitive
    ** Revised_Pre and Post Colo_30 min window.dta
    putexcel set Ttest_Annoucement_days_PS_NPS, replace
    local counter5 = 4
    forvalue i = 1/2 {
    foreach ttest_var of varlist Volume No__Trades No__Bids No__Asks Count_of_Messages {
    ttest `ttest_var' if PriceSensitive2==`i', by(Pre_or_Post_Colo) unequal
    putexcel A`counter5' = `r(t)'
    putexcel B`counter5' = `r(p)'
    local counter5 = `counter5' + 1
    }
    }
    encode


    The data looks as follows (scroll to the right to see the Pre_or_Post_Colocation field, in red font):
    Click image for larger version

Name:	Data example Stata.PNG
Views:	1
Size:	12.0 KB
ID:	1626962


    Output for the Volume Var tttest
    Two-sample t test with unequal variances
    ------------------------------------------------------------------------------
    Group | Obs Mean Std. err. Std. dev. [95% conf. interval]
    ---------+--------------------------------------------------------------------
    0 | 198,188 22274.75 429.8264 191351.5 21432.3 23117.2
    1 | 320,645 16575.2 177.341 100420.3 16227.61 16922.78
    ---------+--------------------------------------------------------------------
    Combined | 518,833 18752.36 197.4449 142219.7 18365.37 19139.34
    ---------+--------------------------------------------------------------------
    diff | 5699.552 464.9737 4788.216 6610.888
    ------------------------------------------------------------------------------
    diff = mean(0) - mean(1) t = 12.2578
    H0: diff = 0 Satterthwaite's degrees of freedom = 266629

    Ha: diff < 0 Ha: diff != 0 Ha: diff > 0
    Pr(T < t) = 1.0000 Pr(|T| > |t|) = 0.0000 Pr(T > t) = 0.0000

    Thanks
    Imtiaz
    Last edited by Imtiaz Bhayat; 09 Sep 2021, 21:21.

  • #2
    Isn't the order of subtraction of means spelled out for you in the table (or also by a quick manual check)?

    Comment


    • #3
      Hi - I was hoping for something more definitive that helps me understand how Stata does the test ie, will it automatically subtract the group tagged as zero's from the group tagged as one's, or will it simply choose the first item in the list and if that was one, subtract items listed as group one from group zero.

      Comment


      • #4
        The default is that -test- subtracts the mean of the group coded as 1 from that of the group coded as 0. This is stated above as:

        Code:
        diff = mean(0) - mean(1)
        However, the reverse option naturally reverses this difference. This is also in the documentation which you can read for yourself by -help ttest-.

        Comment


        • #5
          Excellent, thanks Leonardo.

          I have read that help section so many times but somehow I didn't fully appreciate what the relevant sentence was trying to tell me ie 'By default, the mean of the group corresponding to the largest value in the variable in by() is subtracted from the mean of the group with the smallest value in by()'

          Comment

          Working...
          X