plot.subsample.rfsrc: Plot Subsampling Confidence Intervals for Variable Importance

View source: R/plot.subsample.rfsrc.R

plot.subsample.rfsrcR Documentation

Plot Subsampling Confidence Intervals for Variable Importance

Description

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.

Usage

## 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, ...)

Arguments

x

An object returned by subsample.rfsrc, including double-bootstrap output.

alpha

Significance level, strictly between zero and one. Intervals have nominal confidence level 1-\alpha. The default .01 gives 99 percent intervals. Use alpha = .05 to match the default for extraction and printing.

xvar.names

Names of rows to display: predictor names, or "joint" and "err" when those statistics were requested. If omitted, all rows are considered, subject to pmax.

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 FALSE for the original scale.

normal

Use normal-approximation intervals when TRUE and nonparametric intervals when FALSE. For double-bootstrap objects, these are bootstrap normal and percentile intervals.

jknife

Use the delete-d jackknife standard error for normal intervals. The default uses the subsampling standard error. Ignored when normal = FALSE or for double-bootstrap objects.

target

For classification, use 0 (the default) for the overall statistic, or a class label or position 1, 2, and so on for a class-specific statistic. For competing risks, use an event position from 1 to J, where J is the number of event types; the first event is the default. Ignored for regression and right-censored survival.

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 target to select a class or event within that response.

pmax

Maximum number of rows to display. Supply a positive integer or Inf for all rows. When this limit is exceeded, the rows with the largest reference estimates are displayed in decreasing order, even if sorted = FALSE.

main

Main plot title.

sorted

Order rows by decreasing reference estimate. For VIMP, this places the most important predictors first. See pmax.

show.plots

Draw the plot. Set FALSE to return its numerical summaries without drawing.

...

Named graphical arguments, such as xlim, ylim, xlab, ylab, boxfill, border, whisklty, and whisklwd. A named pars list is also accepted; direct arguments take precedence. See Details.

Details

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.

Interpreting the display

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.

Choosing the interval method

Subsampling provides three displays:

Normal subsampling (default).

Use normal = TRUE, jknife = FALSE. The standard error measures variation about the subsample mean.

Normal jackknife.

Use normal = TRUE, jknife = TRUE. The standard error uses deviations from the full-data estimate, including its difference from the subsample mean.

Nonparametric subsampling.

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.

Selecting predictors and outcomes

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().

Customizing the plot

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.

Obtaining numerical results

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.

Value

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 stats.

Other components support the boxplot drawing and are not additional confidence intervals. The same list is returned with show.plots = FALSE.

Author(s)

Hemant Ishwaran and Udaya B. Kogalur

References

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.

See Also

subsample.rfsrc, extract.subsample, bxp

Examples


## 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)


randomForestSRC documentation built on Nov. 1, 2026, 5:07 p.m.