quantile_stressed: Sample Quantiles of a Stressed Model

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/quantile.R

Description

Provides sample quantiles for components (random variables) of a stochastic model, corresponding to distribution functions under the scenario weights.

Usage

1
2
3
4
5
6
7
8
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 SWIM or SWIMw object.

probs

Vector of probabilities with values in [0,1] (default = (0, 0.25, 0.5, 0.75, 1)).

xCol

Numeric or character vector, (names of) the columns of the underlying data of the object (default = "all").

wCol

Numeric, the column of the scenario weights of the object (default = 1).

type

Character, one of "quantile","(i-1)/(n-1)", "i/(n+1)","i/n", (default = "quantile"). See details below.

base

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

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

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

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