plot_weights: Plotting the scenario weights of a Stressed Model

Description Usage Arguments Value See Also Examples

View source: R/plot_weights.R

Description

Plots the scenario weights of a stressed model against a model component.

Usage

1
2
3
4
5
6
7
8
9
plot_weights(
  object,
  xCol = 1,
  wCol = "all",
  n,
  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").

n

Integer, the number of points used to plot (default = 5000 or the minimum of the data). If n = "all", all data points are plotted. If n is a subset of points, the plotted scenario weights are chosen in an equidistant way.

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 scenario weights of a stochastic model against a model component.

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

See Also

See plot_quantile for plotting sample quantiles of a stressed model and plot_cdf for plotting empirical distribution functions.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
 
## example with a stress with \code{credit_data} data set:
data("credit_data")
## two stresses in VaR
model_stress <- stress_VaR(credit_data, alpha = c(0.9, 0.95), q_ratio = 1.1, k =1) 
plot_weights(model_stress, xCol = "L", wCol = 1:2)

## additional stress on VaR and ES
model_stress <- stress_VaR_ES(model_stress, alpha = 0.9, q_ratio = 1.1, s_ratio = 1.2, k =1) 
plot_weights(model_stress, xCol = "L", wCol = "all", n = 1000, x_limits = c(0, 3500), 
             y_limits = c(0, 10))
             

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