Announcement

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

  • Cumulative event duration with repeated events as a function of follow up time

    Dear STATAlist

    I have a dataset with a starting date (different for each id), and different events which can occur repeatedly. What I am interested in, is the cumulative time duration of each event as a function of follow up time. In the end, this would result in a graph which shows follow up time on the x-axis, and cumulative time duration of each type of event (in this case being hospitalized) over the entire population on the y-axis.

    Example based on code below

    For event1, ID 8 has the first occurence of the event 16 days after F/U start., with only one day of duration (start and end at same day). So up to day = 15 the cumulative event duration for the entire population would be zero, after this 1. This would remain 1 until after 27 days ID 5 experiences an event with duration of 2 days. So at t = 27 cumulative event duration would be 2, and at t=28 would be 3, and so on.

    In this case I present 2 types of events (event1_x and event2_x), there are more. I would like to calculate and visualize cumulative event durations at specific time points (365 days, 730 days etc) and present this in a graph a) separately for each event and b) cumulative over multiple events.

    Thank you

    Kevin Damman

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input double id long(date_fu_start date_start_event1_1 date_end_event1_1 date_start_event1_2 date_end_event1_2 date_start_event2_1 date_end_event2_1 date_start_event2_2 date_end_event2_2)
     1 21024 21722 21728 21954 21957 22057 22064     .     .
     2 19323     .     .     .     .     .     .     .     .
     3 19340     . 19340 20927 20927     .     .     .     .
     4 19558     .     .     .     . 19649 19668 19866 19870
     5 19852 19879 19880 20231 20235     .     .     .     .
     6 19890     .     .     .     .     .     .     .     .
     7 20303 20509 20509     .     . 20328 20359 20425 20425
     8 20493 20509 20509     .     .     .     .     .     .
     9 20521     .     .     .     . 21051 21115     .     .
    10 21767     .     .     .     .     .     .     .     .
    end
    format %tdD_m_Y date_fu_start
    format %tdD_m_Y date_start_event1_1
    format %tdD_m_Y date_end_event1_1
    format %tdD_m_Y date_start_event1_2
    format %tdD_m_Y date_end_event1_2
    format %tdD_m_Y date_start_event2_1
    format %tdD_m_Y date_end_event2_1
    format %tdD_m_Y date_start_event2_2
    format %tdD_m_Y date_end_event2_2

  • #2
    Hi Kevin Damman,
    I saw your question in a previous thread posted by me (https://www.statalist.org/forums/for...uence-analysis) and thought maybe I can be more helpful in explaining what I intended to do using the method and the data structure in the previous thread. If in this way I can help you with your question somehow, that would be great.

    The variable that looked like: 1110011... was part of the data cleansing process for doing the sequence analysis. It is a method originally used in doing DNA sequence analysis and then in sociology to analyze career changes or different stages in life, but in Golay et al, 2019 (Golay, P., et al., "Identifying patterns in psychiatric hospital stays with statistical methods: towards a typology of post-deinstitutionalization hospitalization trajectories". Social Psychiatry and Psychiatric Epidemiology, 2019. ) they used it to visualize repeated hospitalizations for psychiatric patients over a set time period. You could also read Han et al, 2020 (Han X, Jiang F, Zhou H, Needleman J, Guo M, Chen Y, Liu Y, Tang Y: Hospitalization Pattern, Inpatient Service Utilization and Quality of Care in Patients With Alcohol Use Disorder: A Sequence Analysis of Discharge Medical Records. ALCOHOL ALCOHOLISM 2020, 55(2):179-186.) which used this method too. Please check out the visualizations in these papers and see if it was what you intended to do.

    STATA has a package for sequence analysis -sq- which was used in this paper (An Der Heiden W, Häfner H: Investigating the long-term course of schizophrenia by sequence analysis. PSYCHIAT RES 2015, 228(3):551-559.). You can also do it in R (in which case you would need a variable that looked like: 1110011...)


    Regards,
    Ginny Han

    Comment

    Working...
    X