Computes the mean, standard deviation, skewness, kurtosis, Value-at-Risk (VaR) and Conditional Value-at-Risk CVaR) under flexible probabilities.
empirical_stats(x, p, level =0.01)## Default S3 method:empirical_stats(x, p, level =0.01)## S3 method for class 'numeric'empirical_stats(x, p, level =0.01)## S3 method for class 'matrix'empirical_stats(x, p, level =0.01)## S3 method for class 'xts'empirical_stats(x, p, level =0.01)## S3 method for class 'ts'empirical_stats(x, p, level =0.01)## S3 method for class 'data.frame'empirical_stats(x, p, level =0.01)## S3 method for class 'tbl_df'empirical_stats(x, p, level =0.01)
Arguments
x: A time series defining the scenario-probability distribution.
p: An object of the ffp class.
level: A number with the desired probability level. The default is level = 0.01.
Returns
A tidy tibble with 3 columns:
stat: a column with Mu, Std, Skew, Kurt, VaR and CVaR.
name: the asset names.
value: the computed value for each statistic.
Details
The data in x and p are expected to have the same number of rows (size).
Examples
library(dplyr, warn.conflicts =FALSE)library(ggplot2)ret <- diff(log(EuStockMarkets))# with equal weights (standard scenario)ew <- rep(1/ nrow(ret), nrow(ret))empirical_stats(x = ret, p = as_ffp(ew))%>% ggplot(aes(x = name, y = value))+ geom_col()+ facet_wrap(~stat, scales ="free")+ labs(x =NULL, y =NULL)# with ffpexp_smooth <- exp_decay(ret,0.015)empirical_stats(ret, exp_smooth)%>% ggplot(aes(x = name, y = value))+ geom_col()+ facet_wrap(~stat, scales ="free")+ labs(x =NULL, y =NULL)