Announcement

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

  • T-Test with two sum groups in Quintiles

    Hi there,
    I have portfolios divided into quintiles
    I need to conduct t-test to check the differences in mean value of portfolios (Q1+Q2) and mean value of portflios (Q4+Q5) but I cannot. Could you guys help me please?
    The picture is an example.
    Thank you in advance!
    Click image for larger version

Name:	t-test help.jpg
Views:	1
Size:	1.23 MB
ID:	1642722

    This study investigates the motivation and performance consequence of intentional style drift in an exclusively in-house fund management industry in C…
    Last edited by Hoa Phan; 29 Dec 2021, 02:28.

  • #2
    Hoa:
    assuming that -ttest- is actually the way to go here, you may want to consider the following toy example:
    Code:
    . use "C:\Program Files\Stata17\ado\base\a\auto.dta"
    (1978 automobile data)
    
    . xtile quint_price= price , nq(5)
    
    . ttest price if quint_price<=2, by(foreign) unequal
    
    Two-sample t test with unequal variances
    ------------------------------------------------------------------------------
       Group |     Obs        Mean    Std. err.   Std. dev.   [95% conf. interval]
    ---------+--------------------------------------------------------------------
    Domestic |      23    4115.217    75.90388    364.0222    3957.802    4272.632
     Foreign |       7    4117.143     129.361    342.2569    3800.608    4433.678
    ---------+--------------------------------------------------------------------
    Combined |      30    4115.667     64.4885     353.218    3983.773     4247.56
    ---------+--------------------------------------------------------------------
        diff |           -1.925466    149.9855               -333.9568    330.1059
    ------------------------------------------------------------------------------
        diff = mean(Domestic) - mean(Foreign)                         t =  -0.0128
    H0: diff = 0                     Satterthwaite's degrees of freedom =  10.5031
    
        Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
     Pr(T < t) = 0.4950         Pr(|T| > |t|) = 0.9900          Pr(T > t) = 0.5050
    
    . ttest price if quint_price>=4, by(foreign) unequal
    
    Two-sample t test with unequal variances
    ------------------------------------------------------------------------------
       Group |     Obs        Mean    Std. err.   Std. dev.   [95% conf. interval]
    ---------+--------------------------------------------------------------------
    Domestic |      17    9441.176     839.605     3461.78    7661.293    11221.06
     Foreign |      12    8039.167     724.526    2509.832    6444.496    9633.838
    ---------+--------------------------------------------------------------------
    Combined |      29    8861.034    581.8073    3133.128    7669.256    10052.81
    ---------+--------------------------------------------------------------------
        diff |             1402.01    1108.997               -873.6304     3677.65
    ------------------------------------------------------------------------------
        diff = mean(Domestic) - mean(Foreign)                         t =   1.2642
    H0: diff = 0                     Satterthwaite's degrees of freedom =  26.9579
    
        Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
     Pr(T < t) = 0.8915         Pr(|T| > |t|) = 0.2170          Pr(T > t) = 0.1085
    
    .
    Kind regards,
    Carlo
    (StataNow 18.5)

    Comment


    • #3
      Code:
      . sysuse auto, clear
      (1978 automobile data)
      
      . xtile price5bin = price, nq(5)
      
      . tab price5bin
      
      5 quantiles |
         of price |      Freq.     Percent        Cum.
      ------------+-----------------------------------
                1 |         15       20.27       20.27
                2 |         15       20.27       40.54
                3 |         15       20.27       60.81
                4 |         15       20.27       81.08
                5 |         14       18.92      100.00
      ------------+-----------------------------------
            Total |         74      100.00
      
      . gen tocompare = cond(inlist(price5bin, 4, 5), 3, cond(inlist(price5bin, 1, 2), 1, 2))
      
      . tab price5bin tocompare
      
               5 |
       quantiles |            tocompare
        of price |         1          2          3 |     Total
      -----------+---------------------------------+----------
               1 |        15          0          0 |        15 
               2 |        15          0          0 |        15 
               3 |         0         15          0 |        15 
               4 |         0          0         15 |        15 
               5 |         0          0         14 |        14 
      -----------+---------------------------------+----------
           Total |        30         15         29 |        74 
      
      . ttest mpg if inlist(tocompare, 1, 3), by(tocompare)
      
      Two-sample t test with equal variances
      ------------------------------------------------------------------------------
         Group |     Obs        Mean    Std. err.   Std. dev.   [95% conf. interval]
      ---------+--------------------------------------------------------------------
             1 |      30    24.56667    .9549428    5.230437    22.61359    26.51974
             3 |      29     18.2069    .7821584    4.212052    16.60472    19.80908
      ---------+--------------------------------------------------------------------
      Combined |      59    21.44068    .7424946    5.703209    19.95441    22.92694
      ---------+--------------------------------------------------------------------
          diff |             6.35977    1.238925                3.878866    8.840674
      ------------------------------------------------------------------------------
          diff = mean(1) - mean(3)                                      t =   5.1333
      H0: diff = 0                                     Degrees of freedom =       57
      
          Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
       Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

      Comment


      • #4
        Originally posted by Carlo Lazzaro View Post
        Hoa:
        assuming that -ttest- is actually the way to go here, you may want to consider the following toy example:
        Code:
        . use "C:\Program Files\Stata17\ado\base\a\auto.dta"
        (1978 automobile data)
        
        . xtile quint_price= price , nq(5)
        
        . ttest price if quint_price<=2, by(foreign) unequal
        
        Two-sample t test with unequal variances
        ------------------------------------------------------------------------------
        Group | Obs Mean Std. err. Std. dev. [95% conf. interval]
        ---------+--------------------------------------------------------------------
        Domestic | 23 4115.217 75.90388 364.0222 3957.802 4272.632
        Foreign | 7 4117.143 129.361 342.2569 3800.608 4433.678
        ---------+--------------------------------------------------------------------
        Combined | 30 4115.667 64.4885 353.218 3983.773 4247.56
        ---------+--------------------------------------------------------------------
        diff | -1.925466 149.9855 -333.9568 330.1059
        ------------------------------------------------------------------------------
        diff = mean(Domestic) - mean(Foreign) t = -0.0128
        H0: diff = 0 Satterthwaite's degrees of freedom = 10.5031
        
        Ha: diff < 0 Ha: diff != 0 Ha: diff > 0
        Pr(T < t) = 0.4950 Pr(|T| > |t|) = 0.9900 Pr(T > t) = 0.5050
        
        . ttest price if quint_price>=4, by(foreign) unequal
        
        Two-sample t test with unequal variances
        ------------------------------------------------------------------------------
        Group | Obs Mean Std. err. Std. dev. [95% conf. interval]
        ---------+--------------------------------------------------------------------
        Domestic | 17 9441.176 839.605 3461.78 7661.293 11221.06
        Foreign | 12 8039.167 724.526 2509.832 6444.496 9633.838
        ---------+--------------------------------------------------------------------
        Combined | 29 8861.034 581.8073 3133.128 7669.256 10052.81
        ---------+--------------------------------------------------------------------
        diff | 1402.01 1108.997 -873.6304 3677.65
        ------------------------------------------------------------------------------
        diff = mean(Domestic) - mean(Foreign) t = 1.2642
        H0: diff = 0 Satterthwaite's degrees of freedom = 26.9579
        
        Ha: diff < 0 Ha: diff != 0 Ha: diff > 0
        Pr(T < t) = 0.8915 Pr(|T| > |t|) = 0.2170 Pr(T > t) = 0.1085
        
        .
        Yes, it works. Thank all you guys. I will close this dicussion here!

        Comment

        Working...
        X