get_data: Extracting from a Stressed Model

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

View source: R/class.R

Description

Extracting the data (realisations of the stochastic model), the scenario weights, the functions generating the scenario weights, or the specifications of the stress from an object of class SWIM or SWIMw.

Usage

1
2
3
4
5
6
7
8
9
get_data(object, xCol = "all")

get_weights(object, wCol = "all")

get_weightsfun(object, wCol = "all")

get_specs(object, wCol = "all")

summary_weights(object, wCol = "all")

Arguments

object

A SWIM or SWIMw object.

xCol

Numeric or character vector, (names of) the columns of the underlying data of the object (default = "all").

wCol

Vector, the columns of the scenario weights of the object corresponding to different stresses (default = "all").

Value

get_data: A data.frame containing the realisations of the stochastic model on which the object is based.

get_weights: A data.frame containing the scenario weights of the object. Columns corresponds to different stresses.

get_weightsfun: A list containing functions, which, when applied to a column of the data, generate the scenario weights of the object. The corresponding stressed columns can be obtained via get_specs.

Use get_weights if the SWIM object only contains scenario weights and not a list of functions.

get_specs: A data.frame containing specifications of the stresses with each row corresponding to a different stress. Only a selection of the specifications is returned; however, all input variables are stored in the object. See also SWIM.

summary_weights: print a list containing summary statistics of the stresses with each element being a table for a different stress. The summary statistics include minimum, maximum, standard deviation, Gini coefficient, entropy and effective sample size.

Gini coefficient uses the formula \frac{∑_{i=1}^{n} ∑_{j=1}^{n}≤ft|x_{i}-x_{j}\right|}{2 n^{2} \bar{x}}.

Effective Sample Size is equal to n / (1+Var(W)), see Equation (9.13) in Owen, Art B. "Monte Carlo theory, methods and examples." (2013).

Functions

Author(s)

Silvana M. Pesenti

See Also

SWIM

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
## continuing example in stress_VaR
set.seed(0)
x <- as.data.frame(cbind(
     "normal" = rnorm(1000), 
     "gamma" = rgamma(1000, shape = 2)))
  res1 <- stress(type = "VaR", x = x, 
                 alpha = 0.9, q_ratio = 1.05, k = 1)

## returning the underlying data
all(get_data(res1) == x)
 ## the scenario weights
w <- get_weights(res1) 
get_weightsfun(res1)
get_specs(res1)
  
## now add a stress on the means of both variables
res1 <- stress(type = "mean", x = res1, k = 1:2, new_means = c(0.5,1.5))
get_specs(res1)
## the required moments for a stress of type "mean" are not displayed 
## the type of stress and the specs for the second stress can be 
## extracted directly from the SWIM object.
res1$type[[2]]
res1$specs[[2]]
                                             
                                                              
                                                                                                

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