Skip to contents

The statistics a results table reports, in one call and under stated conventions: "Mean", "SD" (population, dividing by n), "CoV" (SD / Mean; 0 when both are 0, NaN when only the mean is), "Min", "Max" and "Variance", then "Percentile <q>" for each percentile, "TVaR <q>" for each TVaR level and "Mean + <k> SD", "Mean - <k> SD" for each multiple, with levels in percent as given, so the names are stable keys to join on.

Usage

statistics(
  x,
  percentiles,
  tvar_levels = c(99, 99.5, 99.6, 99.8, 99.9, 99.99),
  sd_multiples = c(1, 2, 3),
  quantile = "inverted_cdf",
  tvar = "exact"
)

Arguments

x

A numeric vector of draws, a sampled or a predictive_distribution (one row per component).

percentiles

Percentiles, in percent, in [0, 100].

tvar_levels

TVaR levels in percent.

sd_multiples

Multiples of the standard deviation.

quantile

"inverted_cdf" (the default, VaR()'s, R type = 1), "linear" (quantile(type = 7), numpy's default) or "kth_largest" (the k-th largest draw, k = max(1, floor((1 - p) n))).

tvar

"exact" (the default, TVaR()'s, mass 1/n per draw), "linear" (the mean of the linear quantile function over [p, 1]) or "whole_years" (the mean of the k largest draws).

Value

For draws or a sampled, a named numeric vector. For a predictive_distribution, its keys data frame with one column per statistic.

Examples

st <- statistics(c(1, 2, 3, 4), 50, tvar_levels = 50,
                 quantile = "linear", tvar = "linear")
st[c("Percentile 50", "TVaR 50")]
#> Percentile 50       TVaR 50 
#>          2.50          3.25