Description Details Author(s) References See Also Examples
Likelihood-based boosting approach to fit flexible, structured survival models with component-wise linear or P-spline base-learners. Variable selection and model choice are built in features.
Package: | CoxFlexBoost |
Type: | Package |
Version: | 0.7-0 |
Date: | 2009-03-XX |
License: | GPL |
LazyLoad: | yes |
Benjamin Hofner <firstname.lastname@imbe.med.uni-erlangen.de>
Benjamin Hofner, Torsten Hothorn and Thomas Kneib (2008), Variable Selection and Model Choice in Structured Survival Models. Department of Statistics, Technical Report No. 43. http://epub.ub.uni-muenchen.de/7901/
Important functions include: rSurvTime
for simulations
of survival times,
cfboost
for the boosting algorithm, bols
and bbs
for the base-learners and
methods
for methods to be used with
results.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | ## a simple example
#################
# simulate data #
#################
set.seed(6102)
## sample covariates first
X <- matrix(NA, nrow=400, ncol=3)
X[,1] <- runif(400, -1, 1)
X[,2] <- runif(400, -1, 1)
X[,3] <- runif(400, -1, 1)
## time-constant hazard rate
lambda <- function(time, x){
exp(0 * time + 0.7 * x[1] + x[2]^2)
}
## specify censoring function
cens_fct <- function(time, mean_cens){
censor_time <- rexp(n = length(time), rate = 1/mean_cens)
event <- (time <= censor_time)
t_obs <- apply(cbind(time, censor_time), 1, min)
return(cbind(t_obs, event))
}
data <- rSurvTime(lambda, X, cens_fct, mean_cens = 5)
##################
# estimate model #
##################
ctrl <- boost_control( mstop = 100, risk="oobag")
weights <- c(rep(1, 300), rep(0, 100))
## fit (a simple) model
model <- cfboost(Surv(time, event) ~ bbs(x.1) + bbs(x.2) + bbs(x.3),
control = ctrl, data = data, weights = weights)
#########################
# processing the output #
#########################
## determine appropriate stopping iteration
mstop(model)
## summary (with mstop)
summary(model)
## or (almost) same result
model
## plot the risk
plot(risk(model))
## proceed with optimal model
model_opt <- model[mstop(model)]
## extract coefficients of optimal model
## (not very meaningfull for P-spline base-learner)
coef(model_opt)
## plot optimal model
plot(model_opt)
## extract fitted values
fitted(model_opt)
## make prediction for the first out-of-bag observation
predict(model_opt, newdata = data[301,])
## look at the selection frequencies for optimal model)
freq.sel(model_opt)
###################################
# model with time-varying effects #
###################################
## Not run:
## time-dependent hazard rate
lambda <- function(time, x){
exp(log(time) + 0.7 * x[1] + x[2]^2)
}
data <- rSurvTime(lambda, X, cens_fct, mean_cens = 5)
## fit model (quite time-consuming)
model <- cfboost(Surv(time, event) ~ bbsTime(time) + bbs(x.1) + bbs(x.2) + bbs(x.3),
control = ctrl, data = data, weights = weights)
## End(Not run)
##################################################
# estimate model with model choice decomposition #
##################################################
## the next model estimation is very time-consuming
## Not run:
model_mod_choice <- cfboost(Surv(time, event) ~ bolsTime(time)
+ bbsTime(time, df = 1, center = TRUE)
+ bbsTime(time, df = 1, center = TRUE)
+ bols(x.1) + bbs(x.1, df = 1, center = TRUE)
+ bolsTime(time, z = x.1)
+ bbsTime(time, z = x.1, df = 1, center = TRUE)
+ bols(x.2) + bbs(x.2, df = 1, center = TRUE)
+ bolsTime(time, z = x.2)
+ bbsTime(time, z = x.2, df = 1, center = TRUE)
+ bols(x.3) + bbs(x.3, df = 1, center = TRUE)
+ bolsTime(time, z = x.3)
+ bbsTime(time, z = x.3, df = 1, center = TRUE),
data = data, control = ctrl, weights = weights)
## End(Not run)
## proceed as above
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.