Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: Predicting survival at some specific times


From   Steven Samuels <sjsamuels@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Predicting survival at some specific times
Date   Sat, 6 Aug 2011 23:22:20 -0400

On Aug 5, 2011, at 12:06 PM, nakhtardanesh@cogeco.ca wrote:

> Hello,
> I would appreciate if someone could kindly let me know how to predict survival (probability) at some specific times for
> each subject after using streg and stcox commands.  For instance, how can I predict 2-year survival after using streg
> (stcox) on a group patients with breast cancer?


Here is code inspired by Bobby Gutierrez's post at http://www.stata.com/statalist/archive/2010-12/msg00647.html. The -stcox- prediction assumes that you have observations at the time you want to predict for. To create and name predictions for several times, you'll need to use -foreach- loops.

Steve

*************CODE BEGINS*************
/* streg  with prediction at t = 20 */
scalar tt = 20
sysuse cancer, clear
gen id =_n
streg age, dist(weibull)
gen t_old = _t
replace _t=tt
predict s1, surv
label var s1 "streg prediction"
replace _t = t_old

/* stcox, assumes an observation at t= 20! */

stcox age
predict xb, xb
predict s, basesurv
gen stt = s if t==tt
sum stt, meanonly
replace stt = r(mean)
gen s2 = stt^exp(xb)
label var s2 "stcox prediction"
sort age
di "Survival computed at t = " tt
list age id  s1 s2
**************CODE ENDS**************


*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index