tree | R Documentation |
tree(
data,
vars,
facs,
target,
targetLevel,
train,
trainLevel,
imputeMissing = FALSE,
balanceClasses = FALSE,
scaleFeatures = FALSE,
clinicalMetrics = FALSE,
featureImportance = FALSE,
showInterpretation = FALSE,
showPlot = FALSE,
minCases = 10,
maxDepth = 4,
confidenceInterval = FALSE,
riskStratification = FALSE,
exportPredictions = FALSE,
clinicalContext = "diagnosis",
costRatio = 1,
prevalenceAdjustment = FALSE,
expectedPrevalence = 10
)
data |
The data as a data frame containing clinical variables, biomarkers, and patient outcomes. |
vars |
Continuous variables such as biomarker levels, age, laboratory values, or quantitative pathological measurements. |
facs |
Categorical variables such as tumor grade, stage, histological type, or patient demographics. |
target |
Primary outcome variable: disease status, treatment response, survival status, or diagnostic category. |
targetLevel |
Level representing disease presence, positive outcome, or event of interest. |
train |
Variable indicating training vs validation cohorts. If not provided, data will be split automatically. |
trainLevel |
Level indicating the training/discovery cohort. |
imputeMissing |
Impute missing values using medically appropriate methods (median within disease groups for continuous, mode for categorical). |
balanceClasses |
Balance classes to handle rare diseases or imbalanced outcomes. Recommended for disease prevalence <20\ \itemscaleFeaturesStandardize continuous variables (useful when combining biomarkers with different scales/units). \itemclinicalMetricsDisplay sensitivity, specificity, predictive values, likelihood ratios, and other clinical metrics. \itemfeatureImportanceIdentify most important clinical variables and biomarkers for the decision tree. \itemshowInterpretationProvide clinical interpretation of results including diagnostic utility and clinical recommendations. \itemshowPlotDisplay visual representation of the decision tree. \itemminCasesMinimum number of cases required in each terminal node (higher values prevent overfitting). \itemmaxDepthMaximum depth of decision tree (deeper trees may overfit). \itemconfidenceIntervalDisplay confidence intervals for performance metrics. \itemriskStratificationAnalyze risk stratification performance and create risk categories based on tree predictions. \itemexportPredictionsAdd predicted classifications and probabilities to the dataset. \itemclinicalContextClinical context affects interpretation thresholds and recommendations (e.g., screening requires high sensitivity). \itemcostRatioRelative cost of missing a case vs false alarm. Higher values favor sensitivity over specificity. \itemprevalenceAdjustmentAdjust predictive values for expected disease prevalence in target population (different from study sample). \itemexpectedPrevalenceExpected disease prevalence in target population for adjusted predictive value calculations. |
A results object containing:
results$todo | a html | ||||
results$text1 | a preformatted | ||||
results$text2 | a preformatted | ||||
results$text2a | a preformatted | ||||
results$text2b | a preformatted | ||||
results$text3 | a preformatted | ||||
results$text4 | a html | ||||
results$dataQuality | a preformatted | ||||
results$missingDataReport | a table | ||||
results$modelSummary | a html | ||||
results$clinicalMetrics | a table | ||||
results$clinicalInterpretation | a html | ||||
results$featureImportance | a table | ||||
results$riskStratification | a table | ||||
results$confusionMatrix | a table | ||||
results$adjustedMetrics | a table | ||||
results$plot | an image | ||||
results$deploymentGuidelines | a html | ||||
results$predictions | an output | ||||
results$probabilities | an output | ||||
Tables can be converted to data frames with asDF
or as.data.frame
. For example:
results$missingDataReport$asDF
as.data.frame(results$missingDataReport)
Enhanced decision tree analysis for medical research, pathology and
oncology. Provides clinical performance metrics, handles missing data
appropriately, and offers interpretations relevant to medical
decision-making.
# Example for cancer diagnosis
data(cancer_biomarkers)
tree(
data = cancer_biomarkers,
vars = c("PSA", "age", "tumor_size"),
facs = c("grade", "stage"),
target = "diagnosis",
targetLevel = "cancer",
train = "cohort",
trainLevel = "discovery",
imputeMissing = TRUE,
balanceClasses = TRUE
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.