Announcement

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

  • DHS data -Generating the leave-out mean share of a cohort

    Hello,

    I am trying to run an instrumental variable estimation of child marriage on educational attainment using DHS data. As one of my instruments I want to use the leave-out mean of the past incidence of marriage in the previous decade by measuring the share of women that are currently aged 30-40 that got married at the ages of 12 through to 17 at PSU level. I used the following command:

    *v511 is age at first marriage
    *v012 is respondents current age
    *V001 is the PSU

    *Previous Decade PSU leave out mean share women that married at 12 years
    gen byte age12=v511==12 if v012>=30&v012<=40
    egen pasttotal12=total(pastage12), by(v001)
    egen pastcount12= count(pastage12), by(v001)
    gen pastlom12=(pasttotal12-pastage12)/(pastcount12-1)
    list v001 age12 pasttotal12 pastcount12 pastlom12, sepby(v001)

    The issue with this command is that it creates missing values for the sample(those ages 20-29) that I want to estimate on. Is there any other command I can use that will give me leave out mean share of past incidence of marriage at PSU level without generating missing values for my sample.

  • #2
    Assuming that the variable is constant within PSU:

    Code:
    bys v001 (pastlom12): replace pastlom12= pastlom12[1]
    Missing values are sorted last. Therefore, if there is a nonmissing value in a cohort, all missing values will be replaced with it.

    Comment


    • #3
      Hi Andrew, thanks for this! The variable isn't constant because I calculate the mean to not include the data for the corresponding observation. Here is an example of my output of the same command i used above

      Code:
      . list v001 pastage12 pasttotal12 pastcount12 pastlom12, sepby(v001)      
      
            +--------------------------------------------------+
            | v001   pasta~12   pastt~12   pastc~12   pastl~12 |
            |--------------------------------------------------|
         1. |    1          0          0          2          0 |
         2. |    1          .          0          2          . |
         3. |    1          .          0          2          . |
         4. |    1          .          0          2          . |
         5. |    1          .          0          2          . |
         6. |    1          .          0          2          . |
         7. |    1          0          0          2          0 |
         8. |    1          .          0          2          . |
         9. |    1          .          0          2          . |
        10. |    1          .          0          2          . |
        11. |    1          .          0          2          . |
        12. |    1          .          0          2          . |
        13. |    1          .          0          2          . |
      ......
          
            |--------------------------------------------------|
       142. |   15          .          1          6          . |
       143. |   15          0          1          6         .2 |
       144. |   15          .          1          6          . |
       145. |   15          .          1          6          . |
       146. |   15          .          1          6          . |
       147. |   15          .          1          6          . |
       148. |   15          .          1          6          . |
       149. |   15          0          1          6         .2 |
       150. |   15          1          1          6          0 |
       151. |   15          0          1          6         .2 |
       152. |   15          .          1          6          . |
       153. |   15          .          1          6          . |
       154. |   15          0          1          6         .2 |
       155. |   15          0          1          6         .2 |
      When I use the code you suggested it changes all the mean values to 0 in PSU 15:

      Code:
       bys v001 (pastlom12): replace pastlom12= pastlom12[1]
      (3,218 real changes made)
      
      . list v001 pastage12 pasttotal12 pastcount12 pastlom12, sepby(v001)      
      
            +--------------------------------------------------+
            | v001   pasta~12   pastt~12   pastc~12   pastl~12 |
            |--------------------------------------------------|
         1. |    1          0          0          2          0 |
         2. |    1          0          0          2          0 |
         3. |    1          .          0          2          0 |
         4. |    1          .          0          2          0 |
         5. |    1          .          0          2          0 |
         6. |    1          .          0          2          0 |
         7. |    1          .          0          2          0 |
         8. |    1          .          0          2          0 |
         9. |    1          .          0          2          0 |
        10. |    1          .          0          2          0 |
        11. |    1          .          0          2          0 |
        12. |    1          .          0          2          0 |
        13. |    1          .          0          2          0 |
      ......
            |--------------------------------------------------|
       142. |   15          1          1          6          0 |
       143. |   15          0          1          6          0 |
       144. |   15          0          1          6          0 |
       145. |   15          0          1          6          0 |
       146. |   15          0          1          6          0 |
       147. |   15          0          1          6          0 |
       148. |   15          .          1          6          0 |
       149. |   15          .          1          6          0 |
       150. |   15          .          1          6          0 |
       151. |   15          .          1          6          0 |
       152. |   15          .          1          6          0 |
       153. |   15          .          1          6          0 |
       154. |   15          .          1          6          0 |
       155. |   15          .          1          6          0 |

      Comment


      • #4
        Sorry, I misunderstood your question. If you are creating the variable for the subsample of individuals aged 30-40 years, then what values should it take for individuals outside this age range? If you want the value corresponding to pastage12=0, then

        Code:
        bys v001 (pastage12): replace pastlom12= pastlom12[1]
        Last edited by Andrew Musau; 08 Jan 2024, 12:01.

        Comment


        • #5
          Thank so much!

          Comment

          Working...
          X