plot_quantile {SWIM} | R Documentation |
Plotting Quantile Functions of a Stressed Model
Description
Plots the empirical quantile function of a stressed SWIM model component (random variable) or KDE quantile function of a stressed SWIMw model component under the scenario weights.
Usage
plot_quantile(
object,
xCol = 1,
wCol = "all",
base = FALSE,
n = 500,
x_limits,
y_limits,
displ = TRUE
)
Arguments
object |
A |
xCol |
Numeric or character, (name of) the column of the underlying data
of the |
wCol |
Vector, the columns of the scenario weights
of the |
base |
Logical, if |
n |
Integer, the number of points used to plot
( |
x_limits |
Vector, the limits of the x-axis of the plot, the
value for |
y_limits |
Vector, the limits of the y-axis of the plot, the
value for |
displ |
Logical, if |
Value
If displ = TRUE
, a plot displaying the empirical or KDE
quantile function of the stochastic model under the
scenario weights.
If displ = FALSE
, a data.frame for customised plotting with
ggplot
. The data.frame contains the following columns:
grid
, the grid points to plot the quantiles,
stress
(the stresses) and value
(the quantile values).
Denote by res
the return of the function call, then
ggplot
can be called via:
ggplot(res, aes(x = res[ ,1], y = value))
+ geom_lines(aes(color = factor(stress))).
Author(s)
Silvana M. Pesenti, Zhuomin Mao
See Also
See quantile_stressed
for sample quantiles of a
stressed model and plot_cdf
for plotting empirical or KDE
distribution functions under scenario weights.
Examples
## example with a stress on VaR
set.seed(0)
x <- as.data.frame(cbind(
"normal" = rnorm(10 ^ 5),
"gamma" = rgamma(10 ^ 5, shape = 2)))
res1 <- stress(type = "VaR", x = x,
alpha = c(0.75, 0.95), q_ratio = 1.15)
plot_quantile(res1, xCol = 1, wCol = 1:2, base = TRUE)
plot_quantile(res1, xCol = 1, wCol = 1:2, base = TRUE, x_limits = c(0.8, 1),
y_limits = c(0, 5))