ggRandomForests provides ggplot2 (Wickham 2009)
diagnostic and exploration figures for fits from
randomForestSRC::rfsrc() (rfsrc class;
randomForestSRC >= 3.4.0), randomForestRHF::rhf()
(rhf class; randomForestRHF >= 2.0.0),
varPro::varpro() (varpro class; varPro >= 3.1.0),
or randomForest.
randomForestSRC gives a unified treatment of Breiman's (2001) random
forests across data settings: regression and classification forests when the
response is numeric or categorical, survival and competing-risk forests
(Ishwaran et al. 2008) for right-censored data.
Details
The package is built on one decision: keep the data step and the figure step
apart. A gg_* function pulls a tidy data object out of the forest; its
plot() method turns that object into a figure. Two things follow.
The data object stands on its own. It carries everything its plot needs, so you can save it, inspect it, or come back to it later without keeping the original forest (which can be large) in memory.
You are never locked into the default figure. Each plot() method
returns a single plottable object: a ggplot you extend with +,
or a patchwork composite for the multi-panel methods. Add layers, swap
scales, apply a theme, or ignore the default entirely and build the figure
from the tidy data yourself. Every gg_* object also carries
print() and summary() methods: print() shows a short
header rather than dumping every row, and summary() returns a
diagnostics object.
Forest diagnostics
gg_rfsrc: predicted versus observed values.gg_error: OOB error against the number of trees.gg_vimp: variable importance ranking (Ishwaran et al. 2010).gg_variable: marginal variable dependence.gg_roc: ROC curves for classification forests (see alsocalc_rocandcalc_auc).gg_survival: Kaplan-Meier / Nelson-Aalen estimates.gg_brier: time-resolved Brier score and CRPS for survival forests.
Partial dependence
gg_partial: tidies the output ofrandomForestSRC::plot.variable(partial = TRUE).gg_partial_rfsrc: computes partial dependence from the fitted forest directly, viapartial.rfsrc.
SHAP explanations
gg_shap: SHAP values for regression and classification forests, wrappingkernelshap, withshap_importance,shap_beeswarmandshap_dependencefigures.
varPro rule-based variable selection
gg_varpro: variable importance from avarprofit.gg_partial_varpro(aliasgg_partialpro): partial effects on an interpretable scale.gg_beta_varpro: per-region lasso coefficients.gg_isopro: isolation-forest outlier scores.gg_ivarpro: individual (per-observation) importance.
Unsupervised varPro
gg_udependent: variable dependency graph.gg_beta_uvarpro: entropy-based variable ranking.gg_sdependent: signal-variable detection.
Random Hazard Forests These functions are for time-to-event data whose predictors can change during follow-up. They show how event risk, time-varying discrimination, and variable priority change over time, and let you inspect a saved tree-size tuning search.
gg_rhf: per-case event-risk curves over time.gg_auct: AUC curves over follow-up time.gg_rhf_importance: variable priority by time window.gg_tune_rhf: saved tree-size tuning paths by OOB risk or OOB iAUC.
See vignette("rhf", package = "ggRandomForests") for a longitudinal
workflow that uses all four RHF families.
varPro is a required dependency (Imports), so the varPro
families are always available. randomForestRHF and kernelshap
are in Suggests: their functions check for the package and fail with
a clear message when it is not installed.
References
Breiman, L. (2001). Random forests, Machine Learning, 45:5-32.
Ishwaran H, Kogalur U (2026). Fast Unified Random Forests for Survival, Regression, and Classification (RF-SRC). R package version 3.6.2. https://cran.r-project.org/package=randomForestSRC
Ishwaran H. and Kogalur U.B. (2007). Random survival forests for R. R News 7(2), 25–31.
Ishwaran H., Kogalur U.B., Blackstone E.H. and Lauer M.S. (2008). Random survival forests. Ann. Appl. Statist. 2(3), 841–860.
Ishwaran, H., U. B. Kogalur, E. Z. Gorodeski, A. J. Minn, and M. S. Lauer (2010). High-dimensional variable selection for survival data. J. Amer. Statist. Assoc. 105, 205-217.
Ishwaran, H. (2007). Variable importance in binary regression trees and forests. Electronic J. Statist., 1, 519-537.
Lu M, Ishwaran H (2024). Model-independent variable selection via the rule-based variable priority framework. arXiv:2409.09003. https://arxiv.org/abs/2409.09003
Ishwaran H, Kogalur U (2026). Model-Independent Variable Selection via the Rule-Based Variable Priority. R package version 3.2.0. https://CRAN.R-project.org/package=varPro
Ishwaran H, Hsich EM, Kogalur UB, Lee DKK (2026). Random Hazard Forests. arXiv:2608.21597. doi:10.48550/arXiv.2608.21597 .
Ishwaran H, Kogalur UB (2026). randomForestRHF: Random Hazard Forests. R package version 2.0.3. https://CRAN.R-project.org/package=randomForestRHF
Wickham, H. ggplot2: elegant graphics for data analysis. Springer New York, 2009.