hs.RdComputes Value at Risk and Expected Shortfall (Conditional Value at Risk) by means of plain and age-weighted historical simulation.
hs(x, p = 0.975, method = c("age", "plain"), lambda = 0.98)a numeric vector of asset returns
confidence level for VaR calculation; default is 0.975
method to be used for calculation; default is 'plain'
decay factor for the calculation of weights; default is 0.98
Returns a list with the following elements:
Calculated Value at Risk
Calculated Expected Shortfall (Conditional Value at Risk)
Confidence level for VaR calculation
prices <- DAX$price.close
returns <- diff(log(prices))
hs(x = returns, p = 0.975, method = 'plain')
#> $VaR
#> [1] 0.0316466
#>
#> $ES
#> [1] 0.04461608
#>
#> $p
#> [1] 0.975
#>
hs(x = returns, p = 0.975, method = 'age', lambda = 0.98)
#> $VaR
#> [1] 0.02104498
#>
#> $ES
#> [1] 0.03277479
#>
#> $p
#> [1] 0.975
#>