vs.rfsrc | R Documentation |
Drop least relevant variables from a rfsrc
model with optional diagnostics.
vs.rfsrc(
formula,
data,
nvar = -1L,
depth = NULL,
verbose = FALSE,
plot = verbose,
refit = TRUE,
...
)
formula , data |
a formula and data frame containing the response and all potential predictor variables |
nvar |
number of variables desired in final model (if positive) or the number of variables to drop (if negative) |
depth |
logical or a numeric value (if |
verbose , plot |
logical; if |
refit |
logical; if |
... |
additional parameters passed to
|
The formula
of the final model.
vs.glmnet
set.seed(1)
vs.rfsrc(iris)
vs.rfsrc(I(Species == 'setosa') ~ ., iris)
## select variables based on first-order depth
f <- formula(rev(iris))
vs.rfsrc(f, iris, depth = TRUE, verbose = TRUE, plot = FALSE, ntree = 10)
## keep only most relevant 2 variables
vs.rfsrc(f, iris, nvar = 2)
## drop 2 least relevant variables
vs.rfsrc(f, iris, nvar = -2)
vs.rfsrc(f, iris, nvar = -2, refit = FALSE)
library('survival')
f <- Surv(time, status == 0) ~ rx + sex + age + obstruct + adhere + nodes
vs.rfsrc(f, colon, nvar = 4, ntree = 5)
# vs.rfsrc(f, colon, nvar = -2, ntree = 5) ## same
## for slower models, refit = FALSE may improve performance
vs.rfsrc(f, colon, nvar = 4, ntree = 5, refit = FALSE, plot = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.