stress_mean_sd_w: Stressing Mean and Standard Deviation

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

View source: R/stress_mean_std.R

Description

Provides weights on simulated scenarios from a baseline stochastic model, such that a stressed model component (random variable) fulfils a constraint on its mean and standard deviation. Scenario weights are selected by constrained minimisation of the Wasserstein distance to the baseline model.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
stress_mean_sd_w(
  x,
  new_means,
  new_sd,
  k = 1,
  h = 1,
  names = NULL,
  log = FALSE,
  method = "Nelder-Mead",
  ...
)

Arguments

x

A vector, matrix or data frame containing realisations of random variables. Columns of x correspond to random variables; OR
A SWIMw object, where x corresponds to the underlying data of the SWIMw object. The stressed random component is assumed continuously distributed.

new_means

Numeric, the stressed mean.

new_sd

Numeric, the stressed standard deviation.

k

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

h

Numeric, a multiplier of the default bandwidth using Silverman’s rule (default h = 1).

names

Character vector, the names of stressed models.

log

Boolean, the option to print weights' statistics.

method

The method to be used in [stats::optim()]. (default = Nelder-Mead).

...

Additional arguments to be passed to nleqslv.

Value

A SWIMw object containing:

See SWIM for details.

Author(s)

Zhuomin Mao

References

\insertRef

Pesenti2019reverseSWIM

\insertRef

Pesenti2020SSRNSWIM

\insertRef

Pesenti2021SSRNSWIM

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(), stress_mean_w(), stress_mean(), stress_moment(), stress_prob(), stress_user(), stress_wass(), stress()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## Not run: 
set.seed(0)
x <- as.data.frame(cbind(
  "normal" = rnorm(1000),
  "gamma" = rgamma(1000, shape = 2)))
res1 <- stress_wass(type = "mean sd", x = x, k = 1,
  new_means=1, new_sd=0.9)
  summary(res1)

## calling stress_RM_w directly
## stressing "gamma"
res2 <- stress_mean_sd_w(x = x, 
  new_means=2.2, new_sd=1.5, k = 2)
summary(res2)

## End(Not run)

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