# [R] A question about external time-dependent covariates in co x model

Göran Broström gb at stat.umu.se
Thu Aug 19 21:56:34 CEST 2004

```On Thu, Aug 19, 2004 at 09:36:22AM -0300, Hanke, Alex wrote:
> Dear Rui,
> >From my understanding of time-dependent covariates (not an expert but have
> been working on a similar problem), it would appear that the coding of the
> status column is not correct. Unless you have observed an event at each
> interval you should only have status=1 for the last interval. In your
> example I see 3 in total. Also, I think that if "end" is proportional to
> your "covariate" you are incorporating a redundant time effect into the
> model. The time effect is in the baseline hazard.

Right, the 'splitting' was made incorrectly, but 'coxph' shouldn't
segfault anyway. The error seems to be (caught) in 'coxph_wtest.c',
line 29, which may be of interest to the R maintainer of 'survival',
Thomas L.

Göran

>
> Alex
> -----Original Message-----
> From: Rui Song [mailto:rsong at stat.wisc.edu]
> Sent: August 19, 2004 12:21 AM
> To: r-help at stat.math.ethz.ch
> Subject: [R] A question about external time-dependent covariates in cox
> model
>
>
> I am a graduate student in UW-Madison statistics department. I have a
> question about fitting a cox model with external time-dependent
> covariates.
>
> Say the original data is in the following format:
> Obs Eventtime  Status  Cov(time=5)  Cov(time=8)  Cov(time=10)	Cov(time=12)
> 1	5	1		2
> 2	8	0(censored)	2	4
> 3	10	1		2	4		6
> 4	12	1		2	4		6		8
> ....
>
> Notice that the time-dependent covariates are identical at the same
> time points for all obs since they are external to the failure process.
> process.
>
> Then I organized the data as the following:
> obs	start	end	eventtime	status	cov
> 1	0	5	5		1	2
> 2	0	5	8		0	2
> 2	5	8	8		0	4
> 3	0	5	10		1	2
> 3	5	8	10		1	4
> 3	8	10	10		1	6
> 4	0	5	12		1	2
> 4	5	8	12		1	4
> 4	8	10	12		1	6
> 4	10	12	12		1	8
>
> And fit the model using:
>
> fit<-coxph(Surv(start, end, status)~cov);
>
> When I fit the model to my data set (Which has 89 observations and 81
> distinct time points, sort of large.), I always got a message that
> "Process R segmentation fault (core dumped)". Would you let me know if it
> is due to the matrix sigularity in the computation of the partial
> likelihood or something else? And how should I fit a cox model with
> external time-dependent covariates?
>
> Thanks a lot for your time and help!
>
> Sincerely,
> Rui Song
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> http://www.R-project.org/posting-guide.html
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help