
The function
predict_distance_forest
predicts distances between samples based on a survival forest fit.
predict_distance_forest(
survival_forest,
numeric_predictor,
factor_predictor,
data,
missing = "omit"
)
A list.
mean_distance
is the mean distance matrix.
sum_distance
is the matrix that sums the distances between samples.
sum_non_na
is the matrix of the number of non NA distances being averaged.
a fitted survival forest
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.
The best practice is to use the same variables names in the training and testing dataset.
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.
The best practice is to use the same variables names in the training and testing dataset.
the dataframe (test data) that stores the outcome and predictor variables.
Variables in the global environment will be used if data
is missing.
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.
The best practice is to use the same method as the trained random forest.
Predict Distances Between Samples Based on a Survival Forest Fit (Data Supplied as a Dataframe)
# \donttest{
library(survival)
a_survival_forest<-
survival_forest(
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,nboot=20)
a_distance<-
predict_distance_forest(
a_survival_forest,
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