Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

Re: st: sts graph: different results with -atrisk- vs -risktable- option

 From Phil Clayton To statalist@hsphsun2.harvard.edu Subject Re: st: sts graph: different results with -atrisk- vs -risktable- option Date Fri, 15 Apr 2011 19:45:10 +1000

```Alex,

I've just tried this with my own data and I agree with you - the -atrisk- option doesn't appear to take into account the multiple-record structure of your data. As you can see from your example, -risktable- is getting it right.

I would suggest bringing this up with StataCorp.

Phil

On 12/04/2011, at 10:49 PM, Alex Gamma wrote:

> Dear Statasticians,
>
> I have multiple-record survival-time data and -stset- them as shown further
> below. There are 30 records for each of 591 subjects.
>
> My question: why do I get different numbers at risk with -sts
> graph-'s -risktable- vs -atrisk- options?
>
> With -sts graph, risktable name(risktable, replace)-, I get numbers at risk
> 192, 169, 102, 0 for analysis time 0, 10, 20, 30 years, respectively.
>
> With -sts graph, atrisk name(atrisk, replace)-, I get numbers at risk
> 960, 382, 361, 338, 166, 328, 524, 232, 536 for the beginnings of each
> interval.
>
> I'm aware that the time points for which the numbers at risk are calculated
> are not the same for the two options,
> but what worries me is that -atrisk- produces numbers that are much higher
> than the number of subjects in the analysis. In fact, for the first time
> point, the number reported by -atrisk- (960) is exactly the 5-fold of that
> reported by risktable- (192). The latter number is the right one, since it
> corresponds to the total number of subjects in the analysis, as shown in the
> results of -stset-.
>
> I've searched the statalist archives, the Stata FAQ, the Stata manual entry
> for sts graph, and googled "Stata risktable atrisk", but I found nothing
> that addressed this discrepancy.
>
> Further below, I'm also including the results of -sts list-. Maybe
> they help diagnose the problem.
>
> Best regards,
> Alex
>
>
> . stset year, id(intnr) failure(de43fail==0) origin(de4==3)
> enter(year==1979) if(!missing(de43nosx3yv))
>
>               id:  intnr
>    failure event:  de43fail == 0
> obs. time interval:  (year[_n-1], year]
> enter on or after:  year==1979
> exit on or before:  failure
>   t for analysis:  (time-origin)
>           origin:  de4==3
>               if:  !missing(de43nosx3yv)
>
> ------------------------------------------------------------------------------
>   17730  total obs.
>   11814  ignored per request (if(), etc.)
>    1744  obs. end on or before origin()
>     165  obs. begin on or after (first) failure
> ------------------------------------------------------------------------------
>    4007  obs. remaining, representing
>     192  subjects
>      67  failures in single failure-per-subject data
>    4007  total analysis time at risk, at risk from t =         0
>                            earliest observed entry t =         0
>                                 last observed exit t =        29
>
>
>
>
> . sts list
>
>        failure _d:  de43fail == 0
>  analysis time _t:  (year-origin)
>            origin:  de4==3
> enter on or after:  year==1979
>                id:  intnr
>
>          Beg.          Net    Survivor
> Time    Total   Fail   Lost   Function
> ------------------------------------------
>    5      192      1      0     0.9948
>    7      191      1      0     0.9896
>    9      190      4     17     0.9688
>   11      169      3      0     0.9516
>   12      166      2      0     0.9401
>   14      164      1      0     0.9344
>   15      163     10     22     0.8770
>   18      131      1      0     0.8703
>   20      130      9     20     0.8101
>   22      101     12     18     0.7138
>   27       71     14     17     0.5731
>   29       40      9     31     0.4441
> ------------------------------------------
>
>
>
> --
> Alex Gamma Ph.D.
> University Hospital of Psychiatry
> Research Department
> Lenggstr. 31
> 8032 Zurich
> Switzerland
>
> Tel: +4144 384 2621
> Fax: +4144 384 2446
> e-mail: alex.gamma@uzh.ch
>
> --
> Alex Gamma Ph.D.
> University Hospital of Psychiatry
> Research Department
> Lenggstr. 31
> 8032 Zurich
> Switzerland
>
> Tel: +4144 384 2621
> Fax: +4144 384 2446
> e-mail: alex.gamma@uzh.ch
> *
> *   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/
```