Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Cox-Model - Predicted time of failure


From   May Boggess <[email protected]>
To   [email protected]
Subject   Re: st: Cox-Model - Predicted time of failure
Date   09 Jul 2004 11:47:00 -0500

On Friday, Virgilio asked:

> How can I get the predicted time of failure using the Cox Model.
> I would really appreciate any help.
> 

The suggestion put forward by Roy, to compute the area under the
survival curve, is also what I would say. Here is some code for a very
simple example:

 clear
 set obs 3
 gen t=_n
 gen f=1
 stset t, f(f)
 sts list
 stcox, estimate basesurv(s)
 sts graph
 sort _t

 local N1=_N+1
 set obs `N1'
 replace _t=0 in `N1'
 replace s=1 in `N1'
 sort _t 
 twoway line s _t, connect(stairstep) yscale(r(0 1))

 gen box=s*(_t[_n+1]-_t) 
 egen area = sum(box)
 list  area in 1

In the case where the survivor function eventually reaches zero, as in
my easy example, the area under the curve is finite. But if the last
time in the dataset is a censored time, then the survivor function
remains positive for all t. So, in that case, it isn't clear to me what
you can say about the area. If you run the above code anyway, the area
you get is as if the last time is a failure.

In my last example, I have avoided this problem by making certian the
survival function goes to zero. I am estimating the expected survival
time for a subject of mean age:

 clear
 sysuse cancer
 replace di=1 if st==39 
 stset st, f(di)
 sum age
 replace age=age-r(mean)
 stcox age,  basesurv(s)
 stcurve, surv 
 sort _t
 
 local N1=_N+1
 set obs `N1'
 replace _t=0 in `N1'
 replace s=1 in `N1'
 sort _t
 twoway line s _t, connect(stairstep)

 gen box=s*(_t[_n+1]-_t)
 egen area = sum(box)
 list  area in 1

--May
 [email protected]



*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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