View source: R/plot.quantreg.rfsrc.R
| plot.quantreg.rfsrc | R Documentation |
Plots estimated conditional response quantiles against observed responses. An optional inset compares the forest's continuous ranked probability score (CRPS) with the score for the empirical CDF of training responses. Mean pinball losses can also be displayed for selected quantiles.
## S3 method for class 'rfsrc'
plot.quantreg(x, prbL = .25, prbU = .75,
m.target = NULL, crps = TRUE, subset = NULL,
xlab = NULL, ylab = NULL, ...,
inset.args = list(), crps.null = TRUE, quantreg.tau = NULL)
x |
A training or prediction object returned by
|
prbL, prbU |
Lower and upper quantile levels: single probabilities
in |
m.target |
Name of the continuous response to display. Defaults to the first response with quantile results. Selects existing results without calculating new predictions. |
crps |
If |
subset |
Rows to plot and score. Supply positive integer indices
or a logical vector with one nonmissing entry per row of the
quantile output. |
xlab, ylab |
Main-panel axis labels. Defaults are the selected
response name and |
... |
Named graphical arguments passed to
|
inset.args |
Named list of graphical arguments passed to
|
quantreg.tau |
Quantile levels for mean pinball-loss labels, as
a vector of finite probabilities strictly between zero and one.
Losses use the selected response and rows and appear in the
lower-right corner of the main panel. |
crps.null |
If |
Each observation is plotted at its observed response on the horizontal
axis. A point marks its predicted middle quantile, and a vertical
segment with endpoint marks spans its lower and upper quantiles.
The segment is a prediction interval for an individual response,
not a confidence interval for the conditional mean.
The dashed diagonal marks equality between observed and predicted
values. Defaults request the median and the 25th and 75th percentiles.
The response selected by m.target and rows selected by
subset apply to the panel and all scores.
Horizontal jitter separates overlapping observations; scores use the original response values. Rows with an unavailable response or plotted quantile are omitted from the panel with a warning.
To add pinball losses, supply levels such as
quantreg.tau = c(.1, .5, .9). They can differ from the levels
drawn in the panel. Losses are calculated by
get.pinball.error(x, tau = quantreg.tau, subset = subset,
m.target = m.target). Each mean uses selected rows with finite
responses and quantile predictions at that level. Smaller losses
indicate better quantile predictions.
The inset shows the standardized CRPS curve from
get.quantile.crps(). At each response threshold on the
horizontal axis, the right-hand axis shows prediction error integrated
from the first grid value to that threshold and divided by the
integration width. Smaller values indicate less error. Scores depend
on the grid's range and resolution; see quantreg for
the calculation. The first value is unavailable because its integration
width is zero. An entirely unavailable curve is omitted with a warning.
The null distribution is the empirical CDF of all finite training
responses for the selected outcome and is unchanged by subset.
Its CRPS curve uses the same grid, observations, integration, and
standardization as the forest curve. At each threshold, both scores
exclude rows with an unavailable response or forest CDF prediction.
For training plots, the null distribution includes the evaluated
responses and is an in-sample reference, even for OOB predictions.
Use ... to customize the main panel and inset.args for
the inset. Axis limits change only the displayed region, not the rows
scored or the CRPS integration limits. After drawing the inset,
graphics settings return to the main panel so that further drawing
applies there. Successive calls can be used in a multi-panel layout.
Used for its graphical side effect. Invisibly returns NULL.
Hemant Ishwaran and Udaya B. Kogalur
quantreg, get.quantile,
get.quantile.crps, get.pinball.error,
plot.default
## Univariate quantiles, with forest and null CRPS curves.
library(randomForestSRC)
set.seed(19)
dta <- na.omit(airquality)
prob <- c(.25, .50, .75)
q <- quantreg(Temp ~ ., data = dta, prob = prob, ntree = 100)
plot.quantreg(q)
## Add pinball losses for this plot only; the interval and inset are unchanged.
plot.quantreg(q, quantreg.tau = c(.2, .5, .8))
print(get.pinball.error(q, tau = c(.2, .5, .8)))
## Customize the main panel directly, and the inset separately.
plot.quantreg(q, main = "Temperature",
xlim = c(50, 100), ylim = c(45, 110), pch = 19,
inset.args = list(xlim = c(60, 95), ylim = c(0, .35),
lwd = 1.5))
## Keep the inset, but suppress its null reference.
plot.quantreg(q, crps.null = FALSE)
## Multivariate forest: select each response for plotting only.
mv <- quantreg(cbind(Ozone, Temp) ~ ., data = dta,
splitrule = "mahalanobis", prob = prob, ntree = 100)
print(names(get.quantile(mv, pretty = FALSE)))
op <- par(mfrow = c(1, 2))
plot.quantreg(mv, m.target = "Ozone")
plot.quantreg(mv, m.target = "Temp", main = "Temperature",
xlim = c(50, 100), ylim = c(45, 110),
inset.args = list(ylim = c(0, .35)))
par(op)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.