Learn R Programming

SWIM (version 1.0.0)

stress_VaR_ES: Stressing Value-at-Risk and Expected Shortfall

Description

Provides weights on simulated scenarios from a baseline stochastic model, such that a stressed model component (random variable) fulfils a constraint on its Value-at-Risk (VaR) and Expected Shortfall (ES) risk measures, both evaluated at a given level. Scenario weights are selected by constrained minimisation of the relative entropy to the baseline model.

Usage

stress_VaR_ES(
  x,
  alpha,
  q_ratio = NULL,
  s_ratio = NULL,
  q = NULL,
  s = NULL,
  k = 1,
  normalise = FALSE,
  names = NULL,
  log = FALSE
)

Arguments

x

A vector, matrix or data frame containing realisations of random variables. Columns of x correspond to random variables; OR A SWIM object, where x corresponds to the underlying data of the SWIM object.

alpha

Numeric vector, the levels of the stressed VaR.

q_ratio

Numeric vector, the ratio of the stressed VaR to the baseline VaR. If alpha and q_ratio are vectors, they must have the same length.

s_ratio

Numeric, vector, the ratio of the stressed ES to the baseline ES. If q (q_ratio) and s_ratio are vectors, they must have the same length.

q

Numeric vector, the stressed VaR at level alpha. If alpha and q are vectors, they must have the same length.

s

Numeric, vector, the stressed ES at level alpha. If q and s are vectors, they must have the same length.

k

Numeric, the column of x that is stressed (default = 1).

normalise

Logical. If true, values of the columns to be stressed are linearly normalised to the unit interval.

names

Character vector, the names of stressed models.

log

Boolean, the option to print weights' statistics.

Value

A SWIM object containing:

  • x, a data.frame containing the data;

  • new_weights, a list of functions, that applied to the kth column of x, generates the vectors of scenario weights. Each component corresponds to a different stress;

  • type = "VaR ES";

  • specs, a list, each component corresponds to a different stress and contains k, alpha, q and s.

See SWIM for details.

Details

The VaR at level alpha of a random variable with distribution function F is defined as its left-quantile at alpha: $$VaR_{alpha} = F^{-1}(alpha).$$

The ES at level alpha of a random variable with distribution function F is defined by: $$ES_{alpha} = 1 / (1 - alpha) * \int_{alpha}^1 VaR_u d u.$$

The stressed VaR and ES are the risk measures of the chosen model component, subject to the calculated scenario weights. If one of alpha, q, s (q_ratio, s_ratio) is a vector, the stressed VaR's and ES's of the kth column of x, at levels alpha, are equal to q and s, respectively.

The stressed VaR specified, either via q or q_ratio, might not equal the attained empirical VaR of the model component. In this case, stress_VaR will display a message and the specs contain the achieved VaR. Further, ES is then calculated on the bases of the achieved VaR.

Normalising the data may help avoiding numerical issues when the range of values is wide.

References

Pesenti2019reverseSWIM

Pesenti2020SSRNSWIM

Csiszar1975SWIM

See Also

Other stress functions: stress_HARA_RM_w(), stress_RM_mean_sd_w(), stress_RM_w(), stress_VaR(), stress_mean_sd_w(), stress_mean_sd(), stress_mean_w(), stress_mean(), stress_moment(), stress_prob(), stress_user(), stress_wass(), stress()

Examples

Run this code
# NOT RUN {
set.seed(0)
x <- as.data.frame(cbind(
  "normal" = rnorm(1000),
  "gamma" = rgamma(1000, shape = 2)))
res1 <- stress(type = "VaR ES", x = x,
  alpha = c(0.9, 0.95), q_ratio = 1.05, s_ratio = 1.08)

## calling stress_VaR_ES directly
## stressing "gamma"
res2 <- stress_VaR_ES(x = x, alpha = 0.9,
  q_ratio = 1.03, s_ratio = c(1.05, 1.08), k = 2)
get_specs(res2)
summary(res2)

# }

Run the code above in your browser using DataLab