Announcement

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

  • Duration Variable for Survival Analysis in the UCDP Peace Agreement Dateset

    Deal All!

    its my first time doing a survival analysis and I want to apply it on the durability on Peace Agreements. Does anyone know how to create the duration variable (Time to Event variable), that is, counting the years from signing till failure of the agreement?

    Thanks!

    hajo

  • #2
    Hajo:
    welcome to the list.
    I would take a look at -st- entries in Stata .pdf manual, to start with.
    The mandatory textbook for those dealing with survival analysis in Stata is: http://www.stata.com/bookstore/survi...-introduction/
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Dear Carlo,
      I always have the feeling that the explanations in the stata pdf etc beginn one step after my problem: before declaring the data to be survival data I have to create this time-to-event variable, which is difficult for me. I have two time variables: "pa_date" as date of signing of the agreement and "duration" as date for the end of the agreement. "DyVi05" is my failure variable coded as 1 if violence occurs within 5 years between the same parties; 0 otherwise. CID is my conflict ID. So far I got this, but not sure if right....:

      sort CID Year
      bysort CID: replace DyVi05=. if DyVi05==1
      replace DyVi05=. if CID==10 & Year>=1995
      sort CID
      by CID: replace DyVi05=1 if DyVi05[_n-1]==0 & DyVi05==.
      by CID: gen dur_fail = _n (this is my time-to-event variable)
      replace dur_fail =. if DyVi05==.
      drop if DyVi05==.

      Thanks for any help!
      Hajo

      Comment


      • #4
        Hajo:
        please act on the FAQ about posting your code within CODE delimiters. Thanks.
        You can find inspiration in the following Stata dataset:
        Code:
        use http://www.stata-press.com/data/r14/drugtr.dta
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Carlo gave excellent advice.

          As a side note, since you said you are just starting to delve into survival analysis, maybe a nice start-up could be watching Stata's You-Tube-Channel series on the matter, presented by Chuck Huber.
          Best regards,

          Marcos

          Comment

          Working...
          X