Announcement

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

  • Putting Observations (Subjects) into Unique Pairs

    Hi,

    I'm working with experimental data where subjects need to be put into pairs. I am struggling to come up with a way to (i) assign the pairs and (ii) give each pair a unique number.

    My data includes 58 females and 58 males.
    There are 3 treatment groups that subjects can be sorted into. So the variable treatment should equal 1, 2, or 3.
    29 females need to randomly be assigned to treatment 3, and 29 males need to randomly be assigned to treatment 3. I've already done this. Assigning subjects to treatment 1 and treatment 2 is a bit more complex.

    I have a dummy variable called removedecision that determines how subjects in treatment 3 should be paired with the remaining 58 subjects.
    • If removedecision==0 for a male (female) subject in treatment 3, then they need to be paired with a random female (male) subject in treatment 1.
    • If removedecision==1 for a male (female) subject in treatment 3, then they need to be paired with a random female (male) subject in treatment 2.
    This means that the number of female subjects I need in treatment 1 and 2 depends on the removedecisionfor male subjects in treatment 3. Likewise, the number of male subjects I need in treatment 1 and 2 depends on the removedecision for female subjects in treatment 3.

    This is where I need help. Is there a code I can write to do this?

    Once that is done, I need to give a unique pair number to each male/female pair. I want to create a variable called pairnumberthat starts at 1 and ends at 58 and helps me identify each of the pairs I've created.

    Any help with this would be much appreciated. Thanks!

  • #2
    Your description is still not clear enough (at least for me) to get any effective suggestion.
    Please read https://www.statalist.org/forums/help#stata, particularly section 12.2, and use -dataex- to give out here an example of your data. In addition, your trying code so far would be also helpful to clarify what you are seeking for.

    Upon your additional information, it is practically expected that appropriate solutions would be timely suggested to you.

    Comment

    Working...
    X