The function
survival_tree
build a survival tree given the survival outcomes and predictors of numeric and factor variables.
survival_tree(
survival_outcome,
numeric_predictor,
factor_predictor,
weights = NULL,
data,
significance = 0.05,
min_weights = 50,
missing = "omit",
test_type = "univariate",
cut_type = 0
)
A list containing the information of the survival tree fit.
a Surv
object of right-censored outcomes.
In Surv(time,event)
,
time[i]
is the survival time of the ith sample.
event[i]
is the survival event of the ith sample.
a formula specifying the numeric predictors.
As in ~x1+x2+x3
, the three numeric variables x1
, x2
, and x3
are included as numeric predictors.
x1[i]
, x2[i]
, and x3[i]
are the predictors of the ith sample.
a formula specifying the numeric predictors.
As in ~z1+z2+z3
, the three character variables z1
, z2
, and z3
are included as factor predictors.
z1[i]
, z2[i]
, and z3[i]
are the predictors of the ith sample.
sample weights, a numeric vector.
weights[i]
is the weight of the ith sample.
the dataframe that stores the outcome and predictor variables.
Variables in the global environment will be used if data
is missing.
significance threshold, a numeric value.
Stop the splitting algorithm when no splits give a p-value smaller than significance
.
minimum weight threshold, a numeric value.
The weights in a node are greater than min_weights
.
a character value that specifies the handling of missing data.
If missing=="omit"
, samples with missing values in the splitting variables will be discarded.
If missing=="majority"
, samples with missing values in the splitting variables will be assigned to the majority node.
If missing=="weighted"
, samples with missing values in the splitting variables will be weighted by the weights of branch nodes.
a character value that specifies the type of statistical tests.
If test_type=="univariate"
, then it performs a log-rank test without p-value adjustments.
If test_type
is in p.adjust.methods
, i.e., one of holm, hochberg, hommel, bonferroni, BH, BY, or fdr,
then the p-values will be adjusted using the corresponding method.
an integer value that specifies how to cut between two numeric values.
If cut_type==0
, then cut at the ends.
If cut_type==1
, then cut from the middle.
If cut_type==2
, then cut randomly between the two values.
Build a Survival Tree (Data Supplied as a Dataframe)
library(survival)
a_survival_tree<-
survival_tree(
survival_outcome=Surv(time,status==2)~1,
numeric_predictor=~age+ph.ecog+ph.karno+pat.karno+meal.cal,
factor_predictor=~as.factor(sex),
data=lung)
Run the code above in your browser using DataLab