Bookmark and Share

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


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

Re: st: RE: Survival analysis - individual survival functions


From   Steven Samuels <[email protected]>
To   [email protected]
Subject   Re: st: RE: Survival analysis - individual survival functions
Date   Thu, 16 Dec 2010 17:12:30 -0500

Very nice, Bobby!

Steve
[email protected]

On Dec 16, 2010, at 4:45 PM, Roberto G. Gutierrez, StataCorp wrote:

Paul Seed <[email protected]> asks:

Following a parametric survival regression, I can use -predict- with the -surv- option to get the survival function; but I only do not seem to have
any choice over when it is calculated for.

The help file promises me values for S(t|t_0), and I would like to set both t and t_0 myself. But they seem to be set automatically, at the time of
entry and exit of the subject.

Is there a simple way of doing this? If not, is there any chance of it
being included in a future version of Stata?

Paul has received some good advice on alternatives to doing this directly, but doing it directly is possible by manipulating the variables that - predict-
uses to calculate S(t|t_0).  Of course, when you do this you have to be
careful to put everything back in place when you are done.

To illustrate, we fit a Weibull model on the cancer data that ships with
Stata, and we use one covariate, -age-

   . sysuse cancer, clear
   . streg age, dist(weibull)

The time variables that -predict- uses to predict the survival function are stored in variables _t and _t0, as established by -stset-. We proceed by making back up versions of these variables. We'll also back up -age- since we
want to set this at a fixed value for the predictions, too.

   . gen age_old = age
   . gen t_old = _t
   . gen t0_old = _t0

Once backed up, we are free to manipulate these. We begin by resetting _t to
an evenly-spaced grid from 0 to 20

   . drop _t
   . range _t 0 20

Then we replace _t0 to be zero everywhere (it probably already is as this is a simple dataset, but we do it anyway), and we set -age- to be 75 so that the
corresponding survival prediction is for someone aged 75

   . replace _t0 = 0
   . replace age = 75

We can now predict S(t|_t0) for -age == 75- and at the time values as manually
set:

   . predict s, surv
   . list _t0 _t s

Of course, remember to put everything back in place

   . replace age = age_old
   . replace _t = t_old
   . replace _t0 = t0_old

--Bobby
[email protected]
*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index