Announcement

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

  • matching husband-wife and father-daughter observations and generating new variables

    Dear Statlisters

    I am working on household survey data. Here I have variables on responses by household head on women's freedom of mobility and women's own perception about her freedom of mobility (response given by women within household of age 15 years and older). I want to create household-level variables. For which first, I need to create two variables, separately for wife and daughter in a household. Secondly I want to match wife's variable with her husband and daughter's variable with her father within a household which I think I can create as a product of wife's response with household head and daughter's response with household head.
    Below is the sample data and the code I have used to create these variables.

    Code:
    clear
    
    input double hhid float pid age gender rel_head head_response women_response 
    
    101000 1 48 2 1 0 .
    101000 2 39 1 2 0 1
    101000 3 12 1 3 0 .
    101000 4 16 1 3 0 1
    101000 5 6  1 3 0 .
    102000 1 50 2 1 1 .
    102000 2 40 1 2 1 0
    102000 3 15 1 3 1 1
    102000 4 10 2 3 1 .
    103000 1 45 2 1 1 . 
    103000 2 36 1 2 1 1
    103000 3 10 1 3 1 .
    104000 1 60 2 1 0 . 
    104000 2 52 1 2 0 0 
    104000 3 27 2 3 0 . 
    104000 4 24 2 3 0 .
    104000 5 22 1 3 0 0
    104000 6 18 1 3 0 0 
    105000 1 42 2 1 1 . 
    105000 2 32 1 2 1 1
    105000 3 10 1 3 1 .
    105000 4 12 1 3 1 .
    105000 5 6  2 3 1 .
    
    end
    
    label def gender 1 "Female" 2 "Male"
    label val gender gender
    label var rel_head "Relationship to Head"
    label def rel_head 1 "Head" 2 "Spouse" 3 "Son/Daughter"
    label val rel_head rel_head
    labe var head_response "Household Head Response on women's mobility"
    label def head_response 0 "Disagree" 1 "Agree"
    label var women_response "Women response on her own mobility"
    labe def women_response 0 "Disagree" 1 "Agree"
    label val head_response head_response
    label val women_response women_response
    
    gen wife_response=women_response if rel_head==2
    gen daughter_response=women_response if rel_head==3
    
    bys hhid: egen husband_wife_resp=max(wife_response * head_response)
    bys hhid: egen father_daughter_resp=max(daughter_response * head_response)
    I just want to make sure whether this code is correct or maybe is there another way of doing it?
    Thanks in advance.

  • #2
    If I understand right, you want the new variables to be equal to 0 if the wife/daughter have different answers to the husband/father, and 1 if their answers are the same. Your code won't produce the desired result if they both say disagree because both 0s will multiply to 0. I think this will do it, though:

    Code:
    bys hhid: egen husband_wife_resp=max(women_response == head_response & (rel_head==2))
    bys hhid: egen father_daughter_resp=max(women_response == head_response & (rel_head==3 & gender==1))

    Comment


    • #3
      Thank you for your reply. What I want is that women's perception of their freedom of mobility does not really matter unless their husband/father agrees that they should have freedom of mobility. So even if women 'agree(1)' but head 'disagree(0)', the household as a whole would be considered as strict on women's mobility as. Therefore, I want to multiply 'head responses' with women resposnes. Then, I want to separately check this for wife and daughter.
      As you said above, this would give '0' if both head and women agree(1), whereas I want to have '1' in such household.
      I hope I have made my point clear.

      Comment


      • #4
        Sorry, misunderstanding on my part. Your code seems fine to me.

        Comment


        • #5
          Thank you

          Comment

          Working...
          X