DATA MINING
Desktop Survival Guide by Graham Williams |
|||||
Simple |
The simple dataset consists of just 10 data points with 1 covariate (predictor) called x:
> simple <- data.frame(time=c(1, 2, 3, 5, 7, 11, 4, 6, 9, 10), status=c(0, 1, 0, 0, 1, 0, 0, 0, 1, 1), age=c(50, 70, 45, 35, 62, 50, 45, 57, 57, 60)) > simple |
time status age 1 1 0 50 2 2 1 70 3 3 0 45 4 5 0 35 5 7 1 62 6 11 0 50 7 4 0 45 8 6 0 57 9 9 1 57 10 10 1 60 |
First we create a so-called survival object which takes the time and status variables and constructs an object which essentially summarises the censoring. Such an object is used as a response variable in a model formula. The event variable (status) is normally 0/1 or FALSE/TRUE or 1/2, representing alive/dead respectively.
> library(survival) > s.Surv <- Surv(simple$time, simple$status) > s.Surv |
[1] 1+ 2 3+ 5+ 7 11+ 4+ 6+ 9 10 |
Notice that those with a + correspond to times at which the observed event of interest (the 1) has yet to occur. The + means still alive.