# Re: st: R: Kaplan Meier graph in longitudinal data

 From "E. Paul Wileyto" To statalist@hsphsun2.harvard.edu Subject Re: st: R: Kaplan Meier graph in longitudinal data Date Tue, 12 May 2009 09:05:09 -0400

Let's take a step back because the first thing you should be asking is how to structure the risk set... Then ask how to graph it.
```
```
You appear to have structured your risk set as in the Andersen-Gill model, where time of the first event is entry time for being at risk for the second event, and so on. If your events in the series are identical, you may wish to graph cumulative hazard, and not survival. That is one of the options in sts graph.
```
```
If your time to event is conditional on being at risk for "that event" in the series, and time starts from zero, you may want to draw separate survival curves for event 1, event 2, and so on. This would be true for gap time models, where the clock is reset to 0, and for marginal models where time to each event is measured from original time of entry.
```
Paul

Deepa Aggarwal wrote:
```
```Dear Carlo,

Thanks for the quick response.

I tried the following command.
stcox age, cluster(id)

But what to do after that. I looked at the reference book but I am lost.

Many thanks,
Deepa

On Tue, May 12, 2009 at 3:36 AM, Carlo Lazzaro
<carlo.lazzaro@tiscalinet.it> wrote:
```
```Dear Deepa,
provided that the proportional risk assumption holds, a possible solution
would be to switch to the semiparamentric Cox regression model, with the
option -cluster(patient)- (please, see -help stcox-). In this way, you would
correctly assume that patients are independent, whereas receuurences within
the same patient aren't.
This topic (like many others) is covered in Cleves MA, Gould WG, Gutierrez
R. An Introduction To Survival Analysis Using Stata. Revised edition.
College Station: StataPress, 2006: 148-152.

Another possible (but trickier option) would be considering a Markov model
(please, see Sonnenberg FA, Beck JR. Markov models in medical decision
making: a practical guide. Medical Decision Making 1993;13:322-339.

HTH and Kind Regards,
Carlo
-----Messaggio originale-----
Da: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Per conto di Deepa Aggarwal
Inviato: lunedì 11 maggio 2009 19.52
A: statalist@hsphsun2.harvard.edu
Oggetto: st: Kaplan Meier graph in longitudinal data

Hi All,

I have the following longitudinal data :

id     d_entry           d_censor         status          age       x2
1      20jan2008     22jan 2008        0               62          0
1      22jan 2008    24jan 2008        0               62          0
1      24jan 2008    26jan 2008        0               62          1
1      26jan 2008    28jan 2008        1                62          0
2      13jan 2008    18jan 2008        0               70           0
2     18jan 2008    20jan 2008        0               70           1
2      20jan 2008    24jan 2008        0               70           0
2     24jan 2008    26jan 2008        1                70          1

Here id is patient id number, d_entry is the date of entry,  d_censor
is the date of censoring, status is the censoring variable, age is
fixed for each id, x2 changes with time for each id.

First I stset the above mentioned data by using the following command:
stset d_censor, id(id) failure (status==1) origin (time d_entry)

Now I want to get a Kaplan meier graph . I know if there is one event per
id, then sts graph can be used.
But in recurrent event models, what command should be used?

Deepa

--
Deepa

*
*   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/

*
*   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/

```
```

```
```
--
E. Paul Wileyto, Ph.D.
Assistant Professor of Biostatistics
Tobacco Use Research Center
School of Medicine, U. of Pennsylvania
3535 Market Street, Suite 4100

215-746-7147
Fax: 215-746-7140
```
epw@mail.med.upenn.edu
```*
*   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/
```