lossfun.RdThis functions allows for the calculation of loss functions in order to assess the performance of models in regard to forecasting ES.
lossfun(obj = list(loss = NULL, ES = NULL), beta = 1e-04)a list that contains the following elements:
lossa numeric vector that contains the values of a loss series
ordered from past to present; is set to NULL by default
ESa numeric vector that contains the estimated values of the
ES for the same time points of the loss series loss; is set to
NULL by default
Please note that a list returned by the rollcast function can be directly
passed to lossfun.
a single numeric value; a measure for the opportunity cost of
capital; default is 1e-04.
an S3 class object, which is a list of
regulatory loss function
firm's loss function following Sarma et al. (2003)
loss function following Abad et al. (2015)
Feng's loss function; a compromise of regulatory and firm's loss function
Given a negative return series obj$loss, the corresponding Expected
Shortfall (ES) estimates obj$ES and a parameter beta that
defines the opportunity cost of capital, four different definitions of loss
functions are considered.
Abad, P., Muela, S. B., & Martín, C. L. (2015). The role of the loss function in value-at-risk comparisons. The Journal of Risk Model Validation, 9(1), 1-19.
Sarma, M., Thomas, S., & Shah, A. (2003). Selection of Value-at-Risk models. Journal of Forecasting, 22(4), 337-358.
prices <- DAX$price.close
returns <- diff(log(prices))
n <- length(returns)
nout <- 250 # number of obs. for out-of-sample forecasting
nwin <- 500 # window size for rolling forecasts
results <- rollcast(x = returns, p = 0.975, method = 'age', nout = nout,
nwin = nwin)
#>
#> Calculations completed.
loss <- -results$xout
ES <- results$ES
loss.data <- list(loss = loss, ES = ES)
lossfun(loss.data)
#>
#> Please note that the following results are multiplied with 10000.
#> $lossfun1
#> [1] 4.298044
#>
#> $lossfun2
#> [1] 11.16899
#>
#> $lossfun3
#> [1] 11.40937
#>
#> $lossfun4
#> [1] 10.53394
#>
# directly passing the output object of 'rollcast()' to 'lossfun()'
lossfun(results)
#>
#> Please note that the following results are multiplied with 10000.
#> $lossfun1
#> [1] 4.298044
#>
#> $lossfun2
#> [1] 11.16899
#>
#> $lossfun3
#> [1] 11.40937
#>
#> $lossfun4
#> [1] 10.53394
#>