Announcement

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

  • Event history

    Dear Stata community,

    I am trying to generate a duration variable based on this example dataset. I am interested in finding out when people move out of parental home these days. I assume that the process time starts at age 16 and ends at age 35, because events happening before or after those ages are considered to be out of the ordinary. However, I am not sure how to restrict my analysis to those aged 35 or above. Also, when I run tab duration command, it's giving me negative values - why?

    Here are my commands:

    * Missings for yrbrn: .a (7777) Refusal*, .b (8888) Don't know*, .c (9999) No answer*
    mvdecode yrbrn, mv (7777 8888 9999)
    * Missings for lvpntyr: (1111) Never lived with a parent*, .a (7777) Refusal*, .b (8888) Don't know*, .c (9999) No answer*
    mvdecode lvpntyr, mv (1111 7777 8888 9999)

    gen age = yrbrn + 16

    gen duration =.
    replace duration = lvpntyr - age if lvpntyr!=0 // duration for those who have moved out
    replace duration = inwyye - age if lvpntyr==0 // duration for those who have not moved out
    Attached Files

  • #2
    age is not an age, it is year.

    age at departure would be lvpntyr-yrbrn. you'd restrict on that I think (16-35).

    Comment


    • #3
      Originally posted by George Ford View Post
      age is not an age, it is year.

      age at departure would be lvpntyr-yrbrn. you'd restrict on that I think (16-35).
      Thank you for your reply, George. However, as I outlined earlier, I do not assume that people move out the year they are born. Hence, I restrict my analysis to those who are at least 16 years of age: lvpntyr - (yrbrn + 16) or lvpntyr - age (see my gen command above). My two questions remain: how do I restrict this to those who are not older than 35 years of age? And why do I get negative values after running tab command?

      Look forward to your reply!

      Comment


      • #4
        g age_depart = lvpntyr - yrbrn

        now you know at what age they leave. the 5% tails are 16 and 30, so you're age grouping seems sensible.

        duration would be age_depart-16, if that's what you're after, but there will be some negative numbers as the minimum is 1 year.

        you could restrict on age_depart or duration depending on what you're after.

        G

        Comment


        • #5
          you're going to get negative numbers, in part due to missing lvpntyr (with value 0) and people leave before 16. I think my approach is much cleaner and you can interpret the values directly.

          to restrict,

          summ duration if age_depart>=16 & age_depart<=35
          summ duration if inrange(age_depart,16 , 35)

          Comment

          Working...
          X