Announcement

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

  • Comparing groups of twin

    Greetings all,

    My aim is to run code that generates three numbers: 1. the number of twin pairs that both smoke, 2. the number of twin pairs that both do not smoke, 3. the number of twin pairs where one twin smokes but the other doesn't. I tried to do some type of equivalence using TWINPAIR and ID hand also xtset owever was not able to do so. I wonder given the data below how I could generate these three numbers. Thank you kindly.
    ID TWINPAIR EDUCATION SMOKING STRESS
    1 1 HS 0 4
    2 1 COL 1 8
    3 2 <HS 1 3
    4 2 <HS 0 8

  • #2
    Code:
    bysort TWINPAIR: gen byte smokepair = SMOKING[1]  + SMOKING[2] if _n ==1 //
    tab smokepair

    Comment


    • #3
      I understand the question in #1 differently. Mike Lacy's code creates a single new variable the contains the number of twins in the pair that smoke (0, 1, 2). That may well be what is wanted. But my reading of the question is that Leon Edelman actually wants three separate dichotomous variables, one each for neither smokes, one smokes, or both smoke. You could get that by building on the code in #2, adding:

      Code:
      gen both_smoke = 2.smokepair
      gen neither_smokes = 0.smokepair
      gen one_smokes = 1.smokepair
      All of that said, for most later analyses, the single variable coded 0/1/2 will prove more convenient. So even if Leon Edelman wants what I offer here instead of what Mike Lacy offers, he probably should want Mike Lacy's version.

      Comment

      Working...
      X