stress_user: User Defined Stress

Description Usage Arguments Value References See Also Examples

View source: R/stress_user.R

Description

Returns a SWIM object with scenario weights defined by the user.

Usage

1
2
3
4
5
6
7
8
stress_user(
  x,
  new_weights = NULL,
  new_weightsfun = NULL,
  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.

new_weights

A vector, matrix or data frame containing scenario weights. Columns of new_weights correspond to different stresses.
new_weights are normalised to have a mean of 1.

new_weightsfun

A list of functions, that applied to the kth column of x generate the vectors of the scenario weights. Each function corresponds to a stress.
The weights generated for each stress are normalised to have a mean of 1.

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:

See SWIM for details.

References

\insertRef

Pesenti2019reverseSWIM

\insertRef

Pesenti2020SSRNSWIM

\insertRef

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_prob(), stress_wass(), stress()

Examples

1
2
3
4
5
6
7
set.seed(0)
x <- as.data.frame(cbind(
  "normal" = rnorm(1000),
  "gamma" = rgamma(1000, shape = 2)))
res1 <- stress(type = "user", x = x, new_weightsfun = function(x)x ^ 2, k = 1)
## plot user defined weights against the first column of x.
plot(x$normal, get_weights(res1), pch = ".")

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