Announcement

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

  • Subsetting twice with independent group t-tests

    I'm looking to use an independent group t-test to compare the difference between students' grade estimates and their assigned grades (variable: gradempre) in one course against that of another course (variable: CourseID).

    I've tried using:
    ttest gradempre if CourseID==1, by(gradempre if CourseID==2)

    to no avail. Of course I could assign the two courses' gradempre values as different variables...but I'm looking to do this kind of kind of comparison a number of times (and it feels like a good thing to know how to do!).

    Any advice is much appreciated! Thank you.

    System info:
    Stata 15.1 for Windows (running Win10)

  • #2
    Mike:
    are you looking for something like the following toy-example?
    Code:
    . sysuse auto.dta
    (1978 Automobile Data)
    
    . ttest price, unequal by(foreign)
    
    Two-sample t test with unequal variances
    ------------------------------------------------------------------------------
       Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
    ---------+--------------------------------------------------------------------
    Domestic |      52    6072.423    429.4911    3097.104    5210.184    6934.662
     Foreign |      22    6384.682    558.9942    2621.915     5222.19    7547.174
    ---------+--------------------------------------------------------------------
    combined |      74    6165.257    342.8719    2949.496    5481.914      6848.6
    ---------+--------------------------------------------------------------------
        diff |           -312.2587    704.9376               -1730.856    1106.339
    ------------------------------------------------------------------------------
        diff = mean(Domestic) - mean(Foreign)                         t =  -0.4430
    Ho: diff = 0                     Satterthwaite's degrees of freedom =  46.4471
    
        Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
     Pr(T < t) = 0.3299         Pr(|T| > |t|) = 0.6599          Pr(T > t) = 0.6701
    
    .
    Kind regards,
    Carlo
    (StataNow 19.0)

    Comment


    • #3
      Hi Carlo, thanks for the reply.

      That looks similar to what I'm looking for, but I'm still having trouble applying it to my case, where there are many CourseIDs. Is there a way to apply that kind of command to situations where there were additional possible inputs in the foreign/domestic variable?

      Comment


      • #4
        Mike:
        why not considering -regress-, that allows you to add more predictors (possibly interacted one another)?
        Kind regards,
        Carlo
        (StataNow 19.0)

        Comment

        Working...
        X