Announcement

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

  • Creating dyads from household data

    Dear all,
    I am struggling with a maybe simple operation.
    I have some household data, and I would like to create some dyads variables that link each parent to each children within that household.

    My information are:
    - a_hidp = id of household
    - pno = id of position within the family
    - pidp = id of person (cross-wave, always the same)
    - a_sex = sex of respondent
    - dv_age = age of respondent
    - a_hgbiom = pno of biological mother (it corresponds to the pno of mother if within the household)
    - a_hgbiof = pno of biological father (it corresponds to the pno of father if within the household)

    Here the example:
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input long a_hidp byte a_pno long pidp byte a_sex int a_dvage byte(a_hgbiom a_hgbiof)
    68006123 1 68006127 2 39 0 0
    68006123 3 68006135 2 17 1 0
    end
    label values a_hidp a_hidp
    label values a_pno a_pno
    label values a_sex a_sex
    label def a_sex 2 "female", modify
    label values a_dvage a_dvage
    label values a_hgbiom a_hgbiom
    label values a_hgbiof a_hgbiof
    Do you know a viable way to do this? I provided the simplest example (only two people in a household, mother and daughter), but of course there are other issues.
    Any suggestion will be very appreciated.

    Thanks a lot, best, G.


  • #2
    I can't quite tell from your description how one tells if a person is the mother, father, etc. (Presumably this is contained in your "pno" variable, but I can't guess what it might mean or what its coding is.) So, what I can offer you is a start in the form of a way to form a file containing all possible pairs of respondents within household, and a minimal attempt at using some of the other data.
    ,
    Code:
    // Save a copy of the original data file reframed as a file of "others," i.e., persons 
    // other than self in the same household.
    preserve
    rename (a_pno pidp a_sex a_dvage a_hgbiom a_hgbiof) =_other
    tempfile other
    save `other'
    restore
    // Use the other file to make a file of all possible pairs, dropping self-self pairs
    joinby a_hidp using `other'
    drop if (pidp == pidp_other
    //  Now, according to whatever criteria you know but we don't, recast a variable as a
    // "mother" variables and a "father" variable.  I am going to imagine that persons coded
    // as 2 and 3 on the pno variable are mothers and fathers.
    gen mother_age = a_dvage if (pno ==2)
    gen father_age = a_dvage if (pno ==3)

    Comment


    • #3
      Dear MIke,
      yes, a_pno is the code that tells if a person is the mother, father, etc, but in a quite nasty way. Indeed, there is not a unique correspondance (f.i.: 2=mother; 3=father, as you hypothesized), but it is just the progressive number of the member interviewed within the same family (in other word, the order in which one is interviewed). The way to identify the pairs (father-son, mother-son, father-son_2, etc) is to find the correspondance between a_pno and a_hgbiom (for mother) and a_hgbiom (for father).

      Anyway, your trick seems to work perfectly to me. Eventually I will write some update in this post.

      For now, I thank you a lot.
      Best, G.

      Comment


      • #4
        Note that I omitted a ")" a the end of the -drop if...- command. If the a_hgbiom is just the sequential order in which the mother happened to be interviewed, I can't see how that links to the respondent. Perhaps some comparison of age and sex of the "other" person would mark this person as the mother? If you can explain with a simple numerical example how you would (in a non-Stata way) determine who is a mother, we should be able to figure out how to help you do that in a Stata-ish way.

        Comment


        • #5
          Dear MIke,
          yes, I noticed the missing ), thanks for having pointed this.

          Well, actually the a_pno is the sequential order in which each member of the household has been interviews (f.i. if the father was the first, then the first son, then the mather, we have: a_pno == 1 for the father, == 2 for the first son; == 3 for the mother).

          You identify the parent-children relation because each son\daughter has on the variable a_hgbiom the a_pno of the mother (in the example above, the member with a_pno == 2 has a_hgbiom == 3) and on the variable a_hgbiof the a_pno of the father (in the example above, the member with a_pno == 2 has a_hgbiof == 1).

          Your procedure seems work to me, anyway.
          If I run into some other issue I would like to share with you and with the Stata community at large.

          Thanks again, best, G.

          Comment

          Working...
          X