#create a survival simulated dataset
dataset <- matrix(nrow = 1000 , ncol = 100)
dataset <- apply(dataset, 1:2, function(i) runif(1, 1, 100))
dataset <- as.data.frame(dataset);
timeToEvent = rep(0,1000)
event = rep(0,1000)
c = rep(0,1000)
for(i in 1:1000)
{
timeToEvent[i] = dataset[i,1] + 0.5*dataset[i,30] + 2*dataset[i,65] + runif(1, 0, 1);
event[i] = sample(c(0,1),1)
c[i] = runif(1, 0, timeToEvent[i]-0.5)
if(event[i] == 0)
{
timeToEvent[i] = timeToEvent[i] - c[i]
}
}
require(survival)
#init the Surv object class feature
if(require(survival, quietly = TRUE))
{
target <- Surv(time=timeToEvent, event=event)
#run the censIndLR conditional independence test
require(stats)
res = censIndLR(target, dataset, xIndex=12, csIndex=c(35,7,4))
res
#run the SES algorithm using the censIndLR conditional independence
#test for the survival class variable
#require(gRbase) #for faster computations in the internal functions
sesObject <- SES(target , dataset , max_k=1 , threshold=0.05 , test="censIndLR");
#print summary of the SES output
summary(sesObject);
#plot the SES output
plot(sesObject, mode="all");
}
Run the code above in your browser using DataLab