Statalist


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

Re: st: testing PH in a Cox model


From   rgutierrez@stata.com (Roberto G. Gutierrez, StataCorp)
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: testing PH in a Cox model
Date   Mon, 23 Mar 2009 13:20:59 -0500

Ricardo Ovaldia <ovaldia@yahoo.com> writes:

> I am confused about the behavior of -cox,tvc()- when testing the PH
> assumption in Cox regression.

> I assumed that -tcv()- was simply creating an interaction term between the
> covariate and time (_t, by default). Which is how I understood the
> assumption was ben tested.  However, when I do this manualy I get very
> different results.

> Here is an example using the cancer data:

> sysuse cancer, clear
> stset  studytime, f( died)
> gen d=0
> replace d=1 if drug>1
> gen dt=d*_t
> stcox  d, tvc(d) nolog
> stcox  dt, nolog

> What I am doing wrong?

Ricardo is correct that option -tvc()- works by creating time interactions.
The problem, however, is that his generated variable -dt- is not "time
varying", but instead equal to d*_t with _t held fixed at the time the record
ended and the subject exited the study.

To reproduce what -tvc()- does you need to produce true time-varying
covariates, and the only way to do that is to have multiple records per
subject.  Even though we want a covariate to vary continuously with time, we
only need to evaluate at times when observations actually fail.  That's all
that -stcox- cares about anyway.

-ststplit- has the option -at(failures)- for doing just that.

   . sysuse cancer, clear
   . gen id = _n
   . stset studytime, f(died) id(id)
   . stsplit, at(failures)
   . gen d = 0
   . replace d = 1 if drug > 1
   . gen dt = d*_t
   . stcox d, tvc(d) nolog
   . stcox d dt, nolog

--Bobby
rgutierrez@stata.com
*
*   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   |   What's new   |   Site index