Description Usage Arguments Details Value See Also Examples
Functions to print or plot objects from cfboost. Further
functions to extract the coefficients are specified. The extract
function allows to reduce the model to an earlier boosting iteration,
as e.g., the optimal stopping iteration computed with mstop.
1 2 3 4 5 6 7 8 9 10 11 12 13 | ## S3 method for class 'cfboost'
print(x, ...)
## S3 method for class 'cfboost'
summary(object, ...)
## S3 method for class 'cfboost'
plot(x, which = NULL, ask = TRUE && dev.interactive(),
type = "b", ylab = expression(f[partial]), add_rug = TRUE,
color.palette = c("heat.colors", "terrain.colors", "topo.colors",
"cm.colors", "rainbow", "none"), ...)
## S3 method for class 'cfboost'
coef(object, ...)
## S3 method for class 'cfboost'
object[i, ...]
|
x |
an object of class |
object |
an object of class |
which |
integer vector. Only the plots for the given base-learners are plotted. Per default, only the selected base-learners are plotted. |
ask |
logic. If true a user input is required between each plot,
see |
type |
type of plot to be drawn. See |
ylab |
A title for the y axis. |
add_rug |
logic. Determines if |
color.palette |
character. Determines how time-varying effects
of non-binary covariates should be ploted. A color palette of
"heat.colors", "terrain.colors", "topo.colors", "cm.colors",
"rainbow" is specified (as character). See |
i |
integer. Index specifying the model to extract. See example for more details. |
... |
additional arguments (not used a.t.m.) |
The function print prints basic information about the model
specified by object and returns the argument object
invisible. summary is a wrapper to the print
function put gives additional information on the frequency of
selection of the base-learners (see freq.sel).
plot gives a simple plotting interface for the estimated
effects of the model object.
The function coef extracts the coefficients from the model
object.
object[i] extracts the model from the i-th boosting iteration.
object[i] returns the cfboost model-object from the i-th
iteration.
cfboost for model fitting.
freq.sel for the selection frequencies of base-learners.
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 | ## a simple example
#################
# simulate data #
#################
set.seed(4321)
## 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.1 * time - 0.7 * x[1] + 0.5 * x[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 = 80, risk="oobag")
weights <- c(rep(1, 300), rep(0, 100))
## non-censored observations (in-bag)
sum(data$event[weights==1])/nrow(data[weights==1,])
## fit (a simple) model
model <- cfboost(Surv(time, event) ~ bolsTime(time) + bols(x.1) + bols(x.2) + bols(x.3),
control = ctrl, data = data, weights = weights)
#########################
# processing the output #
#########################
## estimate optimal mstop
(stop.opt <- mstop(model))
model_opt <- model[stop.opt]
model
## summary for mstop = 100
summary(model)
## summary (with "optimal" mstop)
summary(model_opt)
## plot of baseline hazard
plot(model_opt, which=1)
## plot of x.1 und x.2
par(mfrow=c(1,2))
plot(model_opt, which = c(2,3), ask = FALSE)
## extract coefficients
coef(model_opt)
## almost correct estimations
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.