| plot_hist {SWIM} | R Documentation |
Plotting Histograms of a Stressed Model
Description
Plots the histogram of a stressed model component (random variable) under the scenario weights.
Usage
plot_hist(
object,
xCol = 1,
wCol = "all",
base = FALSE,
x_limits,
displ = TRUE,
binwidth,
displLines = FALSE
)
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 |
x_limits |
Vector, the limits of the x-axis of the plot, the
value for |
displ |
Logical, if |
binwidth |
Numeric, the width of the bins used to plot
the histogram, the |
displLines |
Logical, if |
Value
If displ = TRUE, a histogram of the stochastic model
under the scenario weights.
If displ = FALSE, a data.frame for customised plotting with
ggplot. The data.frame contains the columns: the column,
xCol, of the data of the stressed model, stress
(the stresses) and value (the values).
Denote by res the return of the function call, then
ggplot can be called via:
ggplot(res, aes(x = res[ ,1], y = ..density.., weight = value)))
+ geom_{freqpoly}(binwidth, aes(color = factor(stress))).
See Also
See cdf and plot_cdf for
values and plotting of the empirical distribution
function of a stressed model, respectively, and
quantile_stressed for sample quantiles of
a stressed model.
Examples
## example with a stress on VaR
set.seed(0)
x <- data.frame("gamma" = rgamma(10^5, shape = 2))
res1 <- stress(type = "VaR", x = x,
alpha = c(0.75, 0.95), q_ratio = 1.1)
plot_hist(res1, xCol = "gamma", wCol = 1:2, base = TRUE, binwidth = 0.4)
plot_hist(res1, xCol = "gamma", wCol = 1:2, base = TRUE, binwidth = 0.4, displLines = TRUE)