Announcement

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

  • Compare subset to full sample

    Given the data structure below, how could I compare the mean of group==1 to the entire dataset (as opposed to comparing only to group==0)? Basically, I'm curious what the most efficient method would be to do ttest score, by(group) but with the full dataset as one of the groups.


    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input byte(group score)
    1 2
    1 3
    1 2
    1 4
    1 5
    1 2
    0 3
    0 4
    0 5
    0 3
    0 2
    0 9
    0 1
    0 2
    0 4
    0 3
    0 2
    0 2
    0 2
    0 1
    0 2
    0 1
    end

  • #2
    You could go

    Code:
    tab group, su(score)
    which would show group means and overall mean

    EDIT: Too hasty an answer. Please see answer from Maarten Buis at #3
    Last edited by Nick Cox; 12 Feb 2024, 09:33.

    Comment


    • #3
      what you want is sometimes called effect coding. In Stata you can do this in two steps:

      Code:
      //step 1
      reg score i.group
      
      //step 2
      contrast gw.group
      ---------------------------------
      Maarten L. Buis
      University of Konstanz
      Department of history and sociology
      box 40
      78457 Konstanz
      Germany
      http://www.maartenbuis.nl
      ---------------------------------

      Comment

      Working...
      X