[R] A question on time-dependent covariates in the Cox model.
Jacob Etches
jacob.etches at utoronto.ca
Wed Jun 22 15:21:43 CEST 2005
This is a question about time-varying effects rather than time-varying
covariates, even if the SAS method tests for the former by using the
latter. SAS evaluates the line
>> dosetime=time*dose;
for all observations at each event time as it estimates the model, such
that you are not using future information. It has the effect of
testing for a linear change in the magnitude of the effect of dose over
time. I believe Paul Allison's survival book recommends this as a
quick and dirty test for constancy of effect. Had you put that line in
a datastep prior to PHREG, rather than in PHREG, you'd get a completely
different (and uninformative) result (probably the same as R is giving
you), because each observation's total survival time would be used to
create a single value for the interaction term. You could manually
replicate SAS's behaviour in R if you wanted, but every observation
would have to start a new time interval whenever any other observation
has an event, as Peter explained below.
You might also want to look at Aalen's additive survival model for
non-linear changes in effect over time:
http://www.med.uio.no/imb/stat/addreg/
hope that helps,
Jacob Etches
On 2005/06/22, at 06:34, Peter Dalgaard wrote:
> "Marianne dk" <m_323stat at hotmail.com> writes:
>
>> I have a dataset with
>>
>> event=death
>> time (from medical examination until death/censoring)
>> dose (given at examination time)
>>
>> Two groups are considered, a non-exposed group (dose=0), an exposed
>> group
>> (dose between 5 and 60).
>>
>> For some reason there is a theory of the dose increasing its effect
>> over
>> time (however it was only given (and measured) once = at the time of
>> examination).
>>
>> I tested a model:
>>
>> coxph(Surv(time,dod)~dose + dose:time)
>>
>> Previously I tested the model in SAS:
>>
>> proc phreg data=test;
>> model time*dod(0)=dose dosetime /rl ties=efron;
>> dosetime=time*dose;
>> run;
>>
>> Without the interaction terms I get the same results for the two
>> models. By
>> including the interaction terms I do not. The model in R gives a
>> negative
>> coefficient for the interaction term which is expected to be positive
>> (and
>> is so in SAS). The LRTs are also completely different.
>>
>> TWO QUESTIONS:
>>
>> 1) Is it reasonable to bring in an interaction term when dose is only
>> measured once?
>>
>> 2) If yes, can anyone give a hint on explaining the difference
>> between the
>> models in R and SAS?
>
> I don't know what SAS does, maybe it second-guesses your intentions,
> but R will definitely get it completely wrong. If you use time as a
> covariate, the same time (of death/censoring) will be applied at all
> death times. Pretty obviously, long observation times tend to be
> associated with low mortalities! With interactions you get, er,
> similarly incorrect effects.
>
> To do coxph with time-dependent variables, you need to split data
> into little time segments, according to the death time of every death,
> inserting a new variable (ntime, say) which is the time of the
> endpoint of the interval.
>
> --
> O__ ---- Peter Dalgaard Øster Farimagsgade 5, Entr.B
> c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
> (*) \(*) -- University of Copenhagen Denmark Ph: (+45)
> 35327918
> ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45)
> 35327907
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
More information about the R-help
mailing list