# Generate some survival data with 10 informative covariates
n <- 200; p <- 100
beta <- c(rep(1,10),rep(0,p-10))
x <- matrix(rnorm(n*p),n,p)
real.time <- -(log(runif(n)))/(10*exp(drop(x %*% beta)))
cens.time <- rexp(n,rate=1/10)
status <- ifelse(real.time <= cens.time,1,0)
obs.time <- ifelse(real.time <= cens.time,real.time,cens.time)
# define training and test set
train.index <- 1:100
test.index <- 101:200
# Fit CoxBoost to the training data
cbfit <- CoxBoost(time=obs.time[train.index],status=status[train.index],
x=x[train.index,],stepno=300,penalty=100)
# mean partial log-likelihood for test set in every boosting step
step.logplik <- predict(cbfit,newdata=x[test.index,],
newtime=obs.time[test.index],
newstatus=status[test.index],
at.step=0:300,type="logplik")
plot(step.logplik)
# names of covariates with non-zero coefficients at boosting step
# with maximal test set partial log-likelihood
print(cbfit$xnames[cbfit$coefficients[which.max(step.logplik),] != 0])
Run the code above in your browser using DataLab