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 on April 23, and its replacement, 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 <>
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, 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 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.


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

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index