Announcement

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

  • Survival Analysis

    I have panel data of multiple visits of patients. In my analysis, I want to look at the loss of retention over time with a survival analysis. Retention is defined as 2 visit dates that were at least 90 days apart in the measurement year. Therefore I cannot just use the last visit date as the date they fell out of care as many may have had one visit after initiating treatment, and then not returned for a year only to start treatment again. Below is a brief look into some of the data:
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input double id float(visit_date art_start_date)
    25 21091 21091
    25 21091 21091
    25 21091 21091
    25 21091 21091
    25 21091 21091
    25 21091 21091
    25 21104 21091
    25 21104 21091
    25 21104 21091
    25 21122 21091
    25 21122 21091
    25 21122 21091
    25 21235 21091
    25 21325 21091
    25 21325 21091
    25 21325 21091
    25 21355 21091
    25 21355 21091
    25 21355 21091
    25 21388 21091
    25 21629 21091
    25 21629 21091
    25 21629 21091
    25 21839 21091
    25 21839 21091
    25 21875 21091
    25 21875 21091
    25 21941 21091
    25 21941 21091
    25 21941 21091
    end
    format %td visit_date
    format %td art_start_date
    The first variable is the ID, the second is the various visit date and the last is the date they started the treatment. How could I code a variable with the last visit date where they did not fulfil the definition on 2 visits in a year (a year after starting treatment, not starting January 1st) more than 90 days apart. Thanks in advance for your time and help!

  • #2
    Salome_Joelle:
    do you mean something along the following lines?:
    Code:
    . bysort id: g interval= visit_date- art_start_date
    
    . bysort id: g wanted_dummy=1 if interval-interval[_n-1]>=90 & _n!=1
    (26 missing values generated)
    
    . list
    
         +--------------------------------------------------+
         | id   visit_d~e   art_sta~e   interval   wanted~y |
         |--------------------------------------------------|
      1. | 25   29sep2017   29sep2017          0          . |
      2. | 25   29sep2017   29sep2017          0          . |
      3. | 25   29sep2017   29sep2017          0          . |
      4. | 25   29sep2017   29sep2017          0          . |
      5. | 25   29sep2017   29sep2017          0          . |
         |--------------------------------------------------|
      6. | 25   29sep2017   29sep2017          0          . |
      7. | 25   12oct2017   29sep2017         13          . |
      8. | 25   12oct2017   29sep2017         13          . |
      9. | 25   12oct2017   29sep2017         13          . |
     10. | 25   30oct2017   29sep2017         31          . |
         |--------------------------------------------------|
     11. | 25   30oct2017   29sep2017         31          . |
     12. | 25   30oct2017   29sep2017         31          . |
     13. | 25   20feb2018   29sep2017        144          1 |
     14. | 25   21may2018   29sep2017        234          1 |
     15. | 25   21may2018   29sep2017        234          . |
         |--------------------------------------------------|
     16. | 25   21may2018   29sep2017        234          . |
     17. | 25   20jun2018   29sep2017        264          . |
     18. | 25   20jun2018   29sep2017        264          . |
     19. | 25   20jun2018   29sep2017        264          . |
     20. | 25   23jul2018   29sep2017        297          . |
         |--------------------------------------------------|
     21. | 25   21mar2019   29sep2017        538          1 |
     22. | 25   21mar2019   29sep2017        538          . |
     23. | 25   21mar2019   29sep2017        538          . |
     24. | 25   17oct2019   29sep2017        748          1 |
     25. | 25   17oct2019   29sep2017        748          . |
         |--------------------------------------------------|
     26. | 25   22nov2019   29sep2017        784          . |
     27. | 25   22nov2019   29sep2017        784          . |
     28. | 25   27jan2020   29sep2017        850          . |
     29. | 25   27jan2020   29sep2017        850          . |
     30. | 25   27jan2020   29sep2017        850          . |
         +--------------------------------------------------+
    
    .
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Thank you so much for the reply Carlo! I am looking for something slightly different....

      For example for ID 25, in the first year after starting treatment they are retained as they have at least two visits in the year that are more than 90 days apart. But in the second year, they only had one visit in the year, 536 days after initiation, as the next visit is 730 days after initiation and therefore in the third year after starting treatment. Therefore they would have fallen out of care with that visit, and that is the visit I would like recorded in the new variable.

      Comment


      • #4
        Salome_Joelle:
        sorry, but I don't follow you here.
        Your -dataex- excerpt reports many >1 visit on the same date that I cannot explain.
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Sorry, I am probably not doing the best job of explaining this. Yes, a patient may have multiple visits in one day as these can represent different types of visits. So a patient may be getting multiple tests (each one of which would be recorded as another visit) and pick up medication, which would be recorded as a pharmacy visit and also another visit on the same day. Therefore a patient can have one, or several "visits" in one day, depending on what they come to the clinic for.

          Comment

          Working...
          X