Feng Lu <[email protected]> asks:
> duration model with time-varying covariates, how do I realize it by stcox?
> Id time-varying variable year failure duration
> 1 1.1 2000 0 1
> 1 1.35 2001 1 2
> 2 1.14 2000 0 1
> 2 1.39 2001 0 2
> 2 1.61 2002 0 3
> 2 1.89 2003 0 4
> 3 1.03 2000 0 1
> 3 1.30 2001 0 2
> 3 1.68 2002 1 3
> I read the stata book and found that the example for time-varying covariate
> model is different from mine.
> I tried two ways but both are wrong.
> One way: stset duration, id(id) failure(some variable)
[followed by -stcox-, presumably]
> It seems that this way only used the time-varying variable in the
> first year.
If you were to -stset- the data as you describe, and then call -stcox- with
the time-varying variable as one of your covariates, the time-varying nature
of that variable is indeed automatically accounted for by -stcox-.
Cox regression works via an accounting of those at risk of failure at each
separate instance of time at which a failure occurs. Since this set (commonly
called a risk set) is indexed by the failure time associated with it, it is
quite easy to account for time-varying covariates -- you simply take the value
of the covariate at that time. There is no additional complication over what
you would need for time-constant covariates and, as such, there is no
additional syntax required.
Feng Lu also considered using option -tvc()- and was confused by the output.
The -tvc()- option is not needed with data, such as the above, that has the
time-varying nature of the covariate(s) spelled out in multiple observations
per subject. Instead, -tvc()- is for use when you want a covariate to
change as a continuous function of time, i.e.
time-varying covariate = (constant covariate in my data) * f(t)
where f(t) is some function of time, with f(t) = t by default and settable
via option -texp()-.
--Bobby
[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/