Learn R Programming

SWIM (version 1.0.0)

stress_prob: Stressing Intervals

Description

Provides weights on simulated scenarios from a baseline stochastic model, such that a stressed model component (random variable) fulfils constraints on probability of disjoint intervals. Scenario weights are selected by constrained minimisation of the relative entropy to the baseline model.

Usage

stress_prob(x, prob, lower = NULL, upper, k = 1, 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.

prob

Numeric vector, stressed probabilities corresponding to the intervals defined through lower and upper.

lower

Numeric vector, left endpoints of the intervals.

upper

Numeric vector, right endpoints of the intervals.

k

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

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, generate the vectors of scenario weights. Each component corresponds to a different stress;

  • type = "prob";

  • specs, a list, each component corresponds to a different stress and contains k, lower, upper and prob.

See SWIM for details.

Details

The intervals are treated as half open intervals, that is the lower endpoint are not included, whereas the upper endpoint are included. If upper = NULL, the intervals are consecutive and prob cumulative. The intervals defined through lower and upper must be disjoint.

References

Pesenti2019reverseSWIM

Pesenti2020SSRNSWIM

Csiszar1975SWIM

See Also

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_mean(), stress_moment(), stress_user(), stress_wass(), stress()

Examples

Run this code
# NOT RUN {
set.seed(0)
x <- rnorm(1000)
## consecutive intervals
res1 <- stress(type = "prob", x = x, prob = 0.008, upper = -2.4)
# probability under the stressed model
cdf(res1, xCol = 1)(-2.4)

## calling stress_prob directly
## multiple intervals
res2 <- stress_prob(x = x, prob = c(0.008, 0.06), 
  lower = c(-3, -2), upper = c(-2.4, -1.6))
# probability under the stressed model
cdf(res2, xCol = 1)(c(-2.4, -1.6)) - cdf(res2, xCol = 1)(c(-3, -2))

# }

Run the code above in your browser using DataLab