Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: stset with multiple failure times


From   Markus Gangl <[email protected]>
To   [email protected]
Subject   Re: st: stset with multiple failure times
Date   Wed, 29 Oct 2008 10:47:49 -0500

Jacob,

there is a simple solution to your problem: you do not need the id() option. You already have a spell dataset, i.e. single-record data for the purposes of stset. Not using the id() option in stset also does not preclude you from accounting for clustering and/or requesting shared frailties in your subsequent analysis (cf. the examples in Cleves et al., An Introduction to Survival Analysis Using Stata, lookup multiple failures in the index).

You'd get a variation on the above from using exit(time lastdate) together with id(), where lastdate is the last time of follow-up for the subject. The difference would be that with the id() option, you'd still construct a single time axis per individual, whereas my first suggestion would code duration from the onset of risk separately for each spell (which I believe is what you wanted). Hosmer/Lemeshow discuss the subtle differences between these two approaches to coding multiple spell/recurrent events data in chapter 9 of their textbook.

Hope this helps,
Markus


statalist-digest wrote:
statalist-digest     Wednesday, October 29 2008     Volume 04 : Number 3228
Date: Tue, 28 Oct 2008 15:20:16 -0400 (EDT)
From: Jacob Wegelin <[email protected]>
Subject: st: stset with multiple failure times

My data contain multiple records per subject.

Subjects are at risk once a year, starting the first of June, for a period of approximately 32 hours (i.e., they are at risk less than two days in any given year).

Some subjects were at risk repeatedly over twenty years--that is, in the first two days of June, several different years between 1986 and 2007.

What is the correct way to invoke -stset- in such a situation?

The output below shows that I am not doing it right. In spite of my use of the "origin" and "id" options, -stset- assigns the same value for _origin to each subject; issues the warning, "3485  obs. begin on or after (first) failure"; and drops those observations from analysis.  This can be seen in the partial listing below, in that most of the _t and _t0 values for each subject are missing.

Before attempting formal analysis with a shared frailty model, I would like to generate a Kaplan-Meier curve that summarizes the information about time to event across all subjects and all 20 years.  Thus I would like the time axis of the plot to range from zero to about 33 hours.  I do not want the time axis to reflect the stretch of time from 1986 to 2007, but rather just the period of *elapsed* time, less than two days, when subject are at risk.

But the -sts- command below produces a time axis that stretches over 20 years, uninformative.

I apologize for the basic error that I must be making. Thanks to whoever can set me straight.

Details below.


. des finTime FinYes June1thisYear

               storage  display     value
variable name   type   format      label      variable label
- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
finTime         float  %9.0g                  Time failed or censored, a Stata date variable (unit=days)
FinYes          float  %9.0g                  0: not finished; 1: finished
June1thisYear   float  %dM_d,_CY              When subject starts to be at risk this year

. local onehour=1/24

. stset finTime, id(nNAME) failure(FinYes) origin(time June1thisYear) scale(`onehour')

                 id:  nNAME
      failure event:  FinYes != 0 & FinYes < .
obs. time interval:  (finTime[_n-1], finTime]
  exit on or before:  failure
     t for analysis:  (time-origin)/.0416667
             origin:  time June1thisYear

- ------------------------------------------------------------------------------
      8282  total obs.
      3485  obs. begin on or after (first) failure
- ------------------------------------------------------------------------------
      4797  obs. remaining, representing
      3956  subjects
      2933  failures in single failure-per-subject data
  1.71e+07  total analysis time at risk, at risk from t =         0
                              earliest observed entry t =         0
                                   last observed exit t =  184111.8

. . list Year finTime FinYes nNAME June1thisYear _* if nNAME < 5

       +----------------------------------------------------------------------------------------------+
       | Year    finTime   FinYes   nNAME   June1thisY~r   _st   _d   _origin          _t         _t0 |
       |----------------------------------------------------------------------------------------------|
    1. | 1986   9649.137        1       1   June 1, 1986     1    1      9648   27.281228           0 |
    2. | 1987   10014.33        0       1   June 1, 1987     0    .      9648           .           . |
    3. | 1988   10380.33        0       1   June 1, 1988     0    .      9648           .           . |
    4. | 1989   10745.23        1       1   June 1, 1989     0    .      9648           .           . |
    5. | 1990   11110.12        1       1   June 1, 1990     0    .      9648           .           . |
       |----------------------------------------------------------------------------------------------|
    6. | 1992   11841.33        0       1   June 1, 1992     0    .      9648           .           . |
    7. | 1993   12206.33        0       1   June 1, 1993     0    .      9648           .           . |
    8. | 1994   12571.23        1       1   June 1, 1994     0    .      9648           .           . |
    9. | 1995   12936.33        0       1   June 1, 1995     0    .      9648           .           . |
   10. | 1996   13302.33        0       1   June 1, 1996     0    .      9648           .           . |
       |----------------------------------------------------------------------------------------------|
   11. | 1997   13667.33        0       1   June 1, 1997     0    .      9648           .           . |
   12. | 1998   14032.33        0       1   June 1, 1998     0    .      9648           .           . |
   13. | 1999   14397.33        0       1   June 1, 1999     0    .      9648           .           . |
   14. | 2000   14763.33        0       1   June 1, 2000     0    .      9648           .           . |
   15. | 2001   15128.33        0       1   June 1, 2001     0    .      9648           .           . |
       |----------------------------------------------------------------------------------------------|
   16. | 2002   15493.33        0       1   June 1, 2002     0    .      9648           .           . |
   17. | 2003   15858.33        0       1   June 1, 2003     0    .      9648           .           . |
   18. | 2005   16589.33        0       1   June 1, 2005     0    .      9648           .           . |
   19. | 2006   16954.33        0       1   June 1, 2006     0    .      9648           .           . |
   20. | 2007   17319.33        0       1   June 1, 2007     0    .      9648           .           . |
       |----------------------------------------------------------------------------------------------|
   21. | 1994   12571.33        0       2   June 1, 1994     1    0     12570   31.945287           0 |
   22. | 1997   13666.98        1       2   June 1, 1997     1    1     12570   26327.463   31.945287 |
   23. | 1998   14031.98        1       2   June 1, 1998     0    .     12570           .           . |
   24. | 2001   15127.98        1       2   June 1, 2001     0    .     12570           .           . |
   25. | 2005    16588.9        1       3   June 1, 2005     1    1     16588   21.656233           0 |
       |----------------------------------------------------------------------------------------------|
   26. | 2006   16953.91        1       3   June 1, 2006     0    .     16588           .           . |
   27. | 2007   17318.88        1       3   June 1, 2007     0    .     16588           .           . |
   28. | 2005   16589.22        1       4   June 1, 2005     1    1     16588   29.390601           0 |
       +----------------------------------------------------------------------------------------------+

. sts

          failure _d:  FinYes
    analysis time _t:  (finTime-origin)/.0416667
              origin:  time June1thisYear
                  id:  nNAME


Jacob A. Wegelin
Assistant Professor
Department of Biostatistics
Virginia Commonwealth University
730 East Broad Street Room 3006
P. O. Box 980032
Richmond VA 23298-0032
U.S.A. E-mail: [email protected] URL: http://www.people.vcu.edu/~jwegelin
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

------------------------------


--
Markus Gangl
Professor of Sociology
University of Wisconsin-Madison, Dept. of Sociology
1180 Observatory Drive		Phone	+1.608.262.9856
Madison, WI 53706-1393		Fax	+1.608.262.8400
United States			Email	[email protected]

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index