| quantile_stressed {SWIM} | R Documentation |
Sample Quantiles of a Stressed Model
Description
Provides sample quantiles for components (random variables) of a stochastic model, corresponding to distribution functions under the scenario weights.
Usage
quantile_stressed(
object,
probs = seq(0, 1, 0.25),
xCol = "all",
wCol = 1,
type = c("quantile", "(i-1)/(n-1)", "i/(n+1)", "i/n"),
base = FALSE
)
Arguments
object |
A |
probs |
Vector of probabilities with values
in |
xCol |
Numeric or character vector, (names of) the columns of
the underlying data
of the |
wCol |
Numeric, the column of the scenario weights
of the |
type |
Character, one of |
base |
Logical, if |
Details
type defines the choice of algorithm used for
calculating the estimate of the sample quantiles.
"quantile" corresponds to the default interpolation used in
quantile. Further options are
"(i-1)/(n-1)", "i/(n+1)", "i/n" the inverse of the
empirical distribution function, using, respectively,
(wt - 1)/T, wt/(T+1), wt/T, where wt is the
cumulative weight and T the total weight (usually total
sample size). See wtd.quantile
for further details on type, on which
quantile_stressed is based. type is ignored for
when evaluating quantiles for SWIMw objects.
Value
Returns a matrix with estimates of the distribution quantiles
at the probabilities, probs, under the scenario weights
wCol.
Author(s)
Silvana M. Pesenti, Zhuomin Mao
See Also
See wtd.quantile on which the function
quantile_stressed is based.
See cdf for the empirical distribution function of
a stressed model.
Examples
## example with a stress on VaR
set.seed(0)
x <- as.data.frame(cbind(
"normal" = rnorm(1000),
"gamma" = rgamma(1000, shape = 2)))
res1 <- stress(type = "VaR", x = x,
alpha = c(0.9, 0.95), q_ratio = 1.05)
## stressed sample quantiles
quantile_stressed(res1, probs = seq(0.9, 0.99, 0.01), wCol = 2)