Learn R Programming

SWIM (version 1.0.0)

stress_mean: Stressing Means

Description

Provides weights on simulated scenarios from a baseline stochastic model, such that stressed model components (random variables) fulfil the mean constraints. Scenario weights are selected by constrained minimisation of the relative entropy to the baseline model.

Usage

stress_mean(x, k, new_means, normalise = TRUE, 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.

k

Numeric vector, the columns of x that are stressed.

new_means

Numeric vector, same length as k, containing the stressed means.

normalise

Logical. If true, values of f(x) are linearly scaled to the unit interval.

names

Character vector, the names of stressed models.

log

Boolean, the option to print weights' statistics.

...

Additional arguments to be passed to nleqslv or stress_moment.

Value

A SWIM object containing:

  • x, a data.frame containing the data;

  • new_weights, a list, each component corresponds to a different stress and is a vector of scenario weights;

  • type = "mean";

  • specs, a list, each component corresponds to a different stress and contains k and new_means.

See SWIM for details.

Details

The function stress_mean is a wrapper for the function stress_moment. See stress_moment for details on the additional arguments to ... and the underlying algorithm.

References

Pesenti2019reverseSWIM

Pesenti2020SSRNSWIM

Csiszar1975SWIM

See Also

See stress_mean_sd for stressing means and standard deviations jointly, and stress_moment for moment constraints.

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

Examples

Run this code
# NOT RUN {
set.seed(0)
x <- data.frame(cbind(
  "normal" = rnorm(1000),
  "gamma" = rgamma(1000, shape = 2),
  "beta" = rbeta(1000, shape1 = 2, shape2 = 2)))
## stressing means
res1 <- stress(type = "mean", x = x, k = 1:3,
  new_means = c(1, 1, 0.75))
summary(res1)
res1$specs
## calling stress_mean directly
res2 <- stress_mean(x = x, k = 1:3,
  new_means = c(1, 1, 0.75))
summary(res2)

## See also examples in stress_moment and stress_mean_sd.

# }

Run the code above in your browser using DataLab