2015-07-25 02:10:28 +02:00
|
|
|
|
|
|
|
#' Trees to find Subgroups
|
|
|
|
#'
|
2015-07-27 01:40:52 +02:00
|
|
|
#' \code{vt.tree} is a wrapper of \code{\link{VT.tree.class}} and
|
|
|
|
#' \code{\link{VT.tree.reg}}. With parameter tree.type, any of these two class
|
|
|
|
#' can be used with its own parameter.
|
2015-07-25 02:10:28 +02:00
|
|
|
#'
|
2015-07-27 01:40:52 +02:00
|
|
|
#' See \code{\link{VT.tree}}, \code{\link{VT.tree.class}} and
|
|
|
|
#' \code{\link{VT.tree.reg}} classes.
|
2015-07-25 02:10:28 +02:00
|
|
|
#'
|
2015-07-27 01:40:52 +02:00
|
|
|
#' @param tree.type must be a character. "class" for classification tree, "reg"
|
|
|
|
#' for regression tree.
|
|
|
|
#' @param vt.difft \code{\link{VT.difft}} object. Or return of
|
|
|
|
#' \code{\link{vt.forest}} function.
|
|
|
|
#' @param sens must be a character c(">","<"). See \code{\link{VT.tree}} for
|
|
|
|
#' details.
|
|
|
|
#' @param threshold must be numeric. It can be a unique value or a vector. If
|
|
|
|
#' numeric vector, a list is returned. See \code{\link{VT.tree}} for details.
|
|
|
|
#' @param screening must be logical. If TRUE, only varimp variables of VT.object
|
|
|
|
#' is used to create the tree.
|
|
|
|
#' @param ... rpart() function parameters. Can be used for any tree.type.
|
|
|
|
#'
|
|
|
|
#' @return \code{VT.tree} or a list of \code{VT.tree} depending on threshold
|
|
|
|
#' dimension. See examples.
|
|
|
|
#'
|
|
|
|
#' @examples
|
|
|
|
#' \dontrun{
|
|
|
|
#' # data(sepsis)
|
|
|
|
#' vt.o <- vt.data(sepsis, "survival", "THERAPY", T)
|
|
|
|
#' # inside model :
|
|
|
|
#' vt.f <- vt.forest("one", vt.o)
|
|
|
|
#' # use classification tree
|
|
|
|
#' vt.tr <- vt.tree("class", vt.f, threshold = c(0.01, 0.05))
|
|
|
|
#' # return a list
|
|
|
|
#' class(vt.tr)
|
|
|
|
#' # access one of the tree
|
|
|
|
#' vt.tr$tree1
|
|
|
|
#' # return infos
|
|
|
|
#' vt.tr$tree1$getInfos()
|
|
|
|
#' # ...
|
|
|
|
#' }
|
|
|
|
#'
|
2015-07-25 02:10:28 +02:00
|
|
|
#' @include tree.R
|
2015-07-27 01:40:52 +02:00
|
|
|
#'
|
2015-07-25 02:10:28 +02:00
|
|
|
#' @name vt.tree
|
2015-07-27 01:40:52 +02:00
|
|
|
#'
|
2015-07-25 02:10:28 +02:00
|
|
|
#' @export vt.tree
|
|
|
|
|
|
|
|
vt.tree <- function(tree.type = "class", vt.difft, sens = ">", threshold = seq(.5, .8, .1), screening = NULL, ...){
|
|
|
|
if(!inherits(vt.difft, "VT.difft"))
|
|
|
|
stop("vt.difft parameter must be aVirtualTwins::VT.difft class")
|
|
|
|
if(is.numeric(threshold)){
|
|
|
|
if(length(threshold)>1){
|
|
|
|
res.name <- paste0("tree", 1:length(threshold))
|
|
|
|
res.list <- lapply(X = threshold, FUN = vt.tree, tree.type = tree.type, vt.difft = vt.difft, sens = sens, screening = screening, ...)
|
|
|
|
names(res.list) <- res.name
|
|
|
|
return(res.list)
|
|
|
|
}else{
|
|
|
|
if(tree.type == "class")
|
|
|
|
tree <- aVirtualTwins:::VT.tree.class(vt.difft = vt.difft, sens = sens, threshold = threshold, screening = screening)
|
|
|
|
else
|
|
|
|
tree <- aVirtualTwins:::VT.tree.reg(vt.difft = vt.difft, sens = sens, threshold = threshold, screening = screening)
|
|
|
|
|
|
|
|
tree$run(...)
|
|
|
|
|
|
|
|
return(tree)
|
|
|
|
}
|
|
|
|
}else
|
|
|
|
stop("threshold must be numeric")
|
|
|
|
}
|