[R] Problem of data format using function of tmerger()

wong jane j@ne@wong083 @end|ng |rom gm@||@com
Thu Mar 21 03:52:37 CET 2019


We want to perform a survival analysis using time-dependent covariates in
the Cox
regression. In this analysis, ESRD1_END and ESRD1_TIME are the outcome and
follow-up time,respectively. AKI_END is a binary time-dependent variable,
while
AKI_TIME is the time point for AKI_END measurement. The Cox model is some-
thing like: Surv(tstart, tstop, ESRD1_END) ˜ AKI_END.
However, it seems the formatted data were incorrect using the functions of
event()
and tdc(), mainly including two problems:
1, The output of event(y, x) is inconsistent with the input data x.
2, Missing value NA was generated from tdc(y, x).


> library(survival)
> ori_data <- read.table("test_data.csv", sep=",", header=TRUE,
stringsAsFactors=F)
> str(ori_data)
' data.frame ' : 7 obs. of 5 variables:
$ data95_Obs: int 10112 15 11 12 13 14 16
$ ESRD1_TIME: num 6.27 9.35 16.77 10.84 18.33 ...
$ ESRD1_END : int 1 0 0 0 0 1 1
$ AKI_END : int 1 1 0 0 0 0 1
$ AKI_TIME : num 3.23 7.65 16.77 10.84 18.33 ...
> dim(ori_data)
[1] 7 5
> head(ori_data)
data95_Obs ESRD1_TIME ESRD1_END AKI_END AKI_TIME
 10112 6.267 1 1 3.233
 15 9.347 0 1 7.654
 11 16.775 0 0 16.775
 12 10.836 0 0 10.836
 13 18.330 0 0 18.330
 14 6.971 1 0 6.971

> #generate the variables "tstart", "tstop" and "status". However, the
"status" is different
> #from "ESRD1_END"
> ori_data <- tmerge(ori_data, ori_data, id=data95_Obs,
status=event(ESRD1_TIME, ESRD1_END))
> dim(ori_data)
[1] 7 9
> head(ori_data)
data95_Obs ESRD1_TIME ESRD1_END AKI_END AKI_TIME id tstart tstop status
 10112 6.267 1 1 3.233 10112 0 6.267 1
 15 9.347 0 1 7.654 15 0 9.347 0
 11 16.775 0 0 16.775 11 0 16.775 1
 12 10.836 0 0 10.836 12 0 10.836 0
 13 18.330 0 0 18.330 13 0 18.330 0
 14 6.971 1 0 6.971 14 0 6.971 0

> #generate the time-dependent variable "AKI_TC". However, why there are
some NAs.
> ori_data <- tmerge(ori_data, ori_data, id=data95_Obs,
AKI_TC=tdc(AKI_TIME, AKI_END))
> dim(ori_data)
[1] 9 10
> head(ori_data)
data95_Obs ESRD1_TIME ESRD1_END AKI_END AKI_TIME id tstart tstop status
 10112 6.267 1 1 3.233 10112 0.000 3.233 0
 10112 6.267 1 1 3.233 10112 3.233 6.267 1
 15 9.347 0 1 7.654 15 0.000 7.654 0
 15 9.347 0 1 7.654 15 7.654 9.347 0
 11 16.775 0 0 16.775 11 0.000 16.775 1
 12 10.836 0 0 10.836 12 0.000 10.836 0
AKI_TC
 NA
 1
 NA
 0
 NA
 NA

	[[alternative HTML version deleted]]



More information about the R-help mailing list