# [R] time dependency of Cox regression

array chip arrayprofile at yahoo.com
Wed Nov 3 18:08:43 CET 2004

```Thanks very much for the suggestion. still some
quiestions. In your example of splitting the covariate
into 6 time-dependent covariates (6 records per
person), will the survival time and censored status be
the same for each of the 6 records? If that's the
case, how does the model know that each of the 6
time-dependent covariates corresponds to 6 consecutive
time points?

I am thinking about create a dummy factor variable
called "time" to indicate which time interval each
patient's survival time is in. For example, if a
patient's survival time is less than 2 years, then the
dummy variable is 2, and so on for each patient. Then
I specify a covariate x time interaction term in the
Cox regression. I would assume the Cox regression will
return a separte hazard ratio for each level of the
dummy factor variable which corresponds to the hazard
ratio of each year. Is this a reasonable way to do it?

Thanks

--- Thomas Lumley <tlumley at u.washington.edu> wrote:

> > array chip wrote:
> >> Hi,
> >>
> >> How can I specify a Cox proportional hazards
> model
> >> with a covariate which i believe its strength on
> >> survival changes/diminishes with time? The value
> of
> >> the covariate was only recorded once at the
> beginning
> >> of the study for each individual (e.g. at the
> >> diagnosis of the disease), so I do not have the
> time
> >> course data of the covariate for any given
> individual.
> >> For example, I want to state at the end of the
> >> analysis that the hazard ratio of the covariate
> is 6
> >> at the beginning, decrease to 3 after 2 years and
> >> decrease to 1.5 after 5 years.
>
>
> If you fit a Cox model with the fixed covariate,
> plot(cox.zph(model)) will
> show you an estimate of how the log hazard ratio
> changes over time, with
> pointwise confidence intervals.
>
> If you want more precise estimates and confidence
> intervals you can split
> up your covariate into a set of time-dependent
> covariates.
>
> If you wanted a time period for each year up to 6
> years you would make 6
> time dependent covariates, looking like
>
>   x 0 0 0 0 0
>   0 x 0 0 0 0
>   0 0 x 0 0 0
>   0 0 0 x 0 0
>   0 0 0 0 x 0
>   0 0 0 0 0 x
>
> and have (up to) six records per person.  The
> survSplit() function in the
> survival package will do the splitting, you then
> need to set the
> appropriate terms to zero and fit the model.
>
>  	-thomas
>

```