plot_quantile: Plotting Quantile Functions of a Stressed Model

Description Usage Arguments Value Author(s) See Also Examples

View source: R/plot_quantile.R

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
plot_quantile(
  object,
  xCol = 1,
  wCol = "all",
  base = FALSE,
  n = 500,
  x_limits,
  y_limits,
  displ = TRUE
)

Arguments

object

A SWIM or SWIMw object.

xCol

Numeric or character, (name of) the column of the underlying data of the object (default = 1).

wCol

Vector, the columns of the scenario weights of the object corresponding to different stresses (default = "all").

base

Logical, if TRUE, statistics under the baseline are also returned (default = "FALSE").

n

Integer, the number of points used to plot (default = 500).

x_limits

Vector, the limits of the x-axis of the plot, the value for xlim in the coord_cartesian function in ggplot.

y_limits

Vector, the limits of the y-axis of the plot, the value for ylim in the coord_cartesian function in ggplot.

displ

Logical, if TRUE the plot is displayed, otherwise the data.frame for customised plotting with ggplot is returned (default = TRUE).

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## 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))

spesenti/SWIM documentation built on Jan. 15, 2022, 11:19 a.m.