View source: R/plot.subsample.rfsrc.R
| plot.subsample.rfsrc | R Documentation |
Plot confidence intervals for variable importance (VIMP) from a
subsample analysis. Compare predictors and assess whether their
importance is positive under the chosen interval method. Joint VIMP
and prediction error can also be displayed when included in the
resampling analysis.
## S3 method for class 'rfsrc'
plot.subsample(x, alpha = .01, xvar.names,
standardize = TRUE, normal = TRUE, jknife = FALSE, target, m.target = NULL,
pmax = 75, main = "", sorted = TRUE, show.plots = TRUE, ...)
x |
An object returned by |
alpha |
Significance level, strictly between zero and one.
Intervals have nominal confidence level |
xvar.names |
Names of rows to display: predictor names, or
|
standardize |
For regression, divide estimates by the selected
response's variance in the full training data. The same divisor
applies to all replicates, VIMP, and prediction error. Other
families are unchanged. Set |
normal |
Use normal-approximation intervals when |
jknife |
Use the delete- |
target |
For classification, use |
m.target |
Name of one response in a multivariate or mixed-outcome
forest. The default selects the first regression response with
results, or the first classification response with results if none
is available for regression. Use |
pmax |
Maximum number of rows to display. Supply a positive
integer or |
main |
Main plot title. |
sorted |
Order rows by decreasing reference estimate. For VIMP,
this places the most important predictors first. See |
show.plots |
Draw the plot. Set |
... |
Named graphical arguments, such as |
After fitting smp <- subsample(obj), use
plot.subsample(smp) to compare VIMP estimates and their
uncertainty. Each row represents a predictor or a requested joint-VIMP
or prediction-error statistic. Changing the confidence level, interval
method, or selected results uses the saved replicates without fitting
more forests.
The default plot is horizontal, with VIMP or prediction error on the horizontal axis. Whiskers mark the confidence limits; the box spans the lower and upper quartiles of the interval summary. For subsampling, the center line marks the full-data estimate for normal intervals and the interval median for nonparametric intervals. For double-bootstrap output, it marks the bootstrap mean.
Boxes are red when the lower confidence limit exceeds zero and
blue otherwise. For VIMP, red identifies positive importance under
the chosen interval method. An err row summarizes prediction
error, so its color is not a variable-selection result. Intervals
are calculated separately, without a multiple-testing adjustment.
These boxes describe uncertainty in the estimates, not variation
in the observed predictor values.
Subsampling provides three displays:
Use
normal = TRUE, jknife = FALSE. The standard error measures
variation about the subsample mean.
Use normal = TRUE, jknife = TRUE.
The standard error uses deviations from the full-data estimate,
including its difference from the subsample mean.
Use normal = FALSE.
Limits use empirical quantiles of centered and scaled
subsample estimates.
The jackknife standard error need not be larger than the subsampling
standard error. See subsample.rfsrc for the formulas
and finite-replicate scaling.
For double-bootstrap objects, normal = TRUE uses normal
intervals centered at the bootstrap mean; normal = FALSE
uses percentile intervals. jknife has no effect.
Use the same alpha when comparing plots with printed or
extracted results. Plotting defaults to .01; printing and
extraction default to .05.
Use xvar.names to choose rows, m.target to choose a
response, and target to choose its class or event statistic.
For example, m.target = "Ozone" selects results for the
response named Ozone, not a predictor to display.
Competing-risk indexing differs from extraction: the first event
uses target = 1 here but target = 0 in
extract.subsample().
xlim and ylim control the horizontal and vertical
axes as displayed. Use horizontal = FALSE to place VIMP or
prediction error on the vertical axis.
Set boxfill (or col) for box colors, border
for borders, and whisklty and whisklwd for the
confidence-limit lines. Outliers are hidden by default
(outline = FALSE).
cex.axis, col.axis, and las control axis
labels. Use xaxt = "n" or yaxt = "n" to suppress one
axis, or axes = FALSE for both. A single ylab string
sets the vertical-axis title. For custom row labels, supply
names with one label per selected row before sorting and
limiting the display to pmax rows. at sets positions
for the final displayed intervals.
plot.subsample(smp, show.plots = FALSE) returns the selected
interval matrix and labels without drawing.
extract.subsample(smp, raw = TRUE) returns all interval
methods and the replicate estimates. Both use the requested
standardize setting.
Invisibly returns a list with the following plotting components:
stats |
Five-row interval matrix, with one column per displayed statistic. Rows contain the lower confidence limit, lower quartile, center, upper quartile, and upper confidence limit. |
names |
Labels corresponding to the columns of |
Other components support the boxplot drawing and are not additional
confidence intervals. The same list is returned with
show.plots = FALSE.
Hemant Ishwaran and Udaya B. Kogalur
Ishwaran H. and Lu M. (2019). Standard errors and confidence intervals for variable importance in random forest regression, classification, and survival. Statistics in Medicine, 38, 558-582.
Politis, D.N. and Romano, J.P. (1994). Large sample confidence regions based on subsamples under minimal assumptions. The Annals of Statistics, 22(4):2031-2050.
Shao, J. and Wu, C.J. (1989). A general theory for jackknife variance estimation. The Annals of Statistics, 17(3):1176-1197.
subsample.rfsrc, extract.subsample,
bxp
## Small settings are for illustration; increase B for final inference.
set.seed(19)
dta <- na.omit(airquality)
o <- rfsrc(Ozone ~ ., data = dta, ntree = 100,
importance = "permute", block.size = 1)
smp <- subsample(o, B = 25, verbose = FALSE)
## Three interval displays, all at the same confidence level.
plot.subsample(smp, alpha = .05, main = "Subsampling normal intervals")
plot.subsample(smp, alpha = .05, jknife = TRUE,
main = "Jackknife normal intervals")
plot.subsample(smp, alpha = .05, normal = FALSE,
main = "Nonparametric intervals")
## Restrict the display and customize the main axes and whiskers.
plot.subsample(smp, alpha = .05,
xvar.names = c("Solar.R", "Wind", "Temp"),
xlim = c(-.1, .8), las = 2, cex.axis = .75,
whisklty = 1, whisklwd = 1.5)
plot.data <- plot.subsample(smp, alpha = .05, show.plots = FALSE)
print(plot.data)
## Multivariate regression: one subsample bank, two response displays.
mv <- rfsrc(cbind(Ozone, Temp) ~ ., data = dta, ntree = 100,
importance = "permute", block.size = 1)
mv.smp <- subsample(mv, B = 25, verbose = FALSE)
plot.subsample(mv.smp, m.target = "Ozone", alpha = .05,
main = "Ozone")
plot.subsample(mv.smp, m.target = "Temp", alpha = .05,
main = "Temperature")
print(extract.subsample(mv.smp, m.target = "Temp", alpha = .05)$var.sel.Z)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.