Calculates univariate Value at Risk and Expected Shortfall (Conditional Value at Risk) by means of filtered historical simulation. Volatility can be estimated with an exponentially weighted moving average or a GARCH-type model.

fhs(x, p = 0.975, model = c("EWMA", "GARCH"), lambda = 0.94, nboot = NULL, ...)

Arguments

x

a numeric vector of asset returns

p

confidence level for VaR calculation; default is 0.975

model

model for estimating conditional volatility; options are 'EWMA' and 'GARCH'; if model = 'GARCH', additional arguments can be adjusted via ...; default is 'EWMA'

lambda

decay factor for the calculation of weights; default is 0.94

nboot

size of bootstrap sample; must be a single non-NA integer value with nboot > 0; default is NULL

...

additional arguments of the ugarchspec function from the rugarch-package; only applied if model = 'GARCH'; default settings for the arguments variance.model and mean.model are:

variance.model = list(model = 'sGARCH', garchOrder = c(1, 1))
mean.model = list(armaOrder = c(0, 0))

Value

Returns a list with the following elements:

VaR

Calculated Value at Risk

ES

Calculated Expected Shortfall (Conditional Value at Risk)

p

Confidence level for VaR calculation

garchmod

The model fit. Is the respective GARCH fit for model = "GARCH" (see rugarch documentation) and 'EWMA' for model = "EWMA"

Examples

prices <- DAX$price.close
returns <- diff(log(prices))
# volatility weighting via EWMA
ewma <- fhs(x = returns, p = 0.975, model = "EWMA", lambda = 0.94,
            nboot = 10000)
ewma
#> $VaR
#> [1] 0.02399405
#> 
#> $ES
#> [1] 0.03057634
#> 
#> $p
#> [1] 0.975
#> 
#> $garchmod
#> [1] "EWMA"
#> 
# volatility weighting via GARCH
garch <- fhs(x = returns, p = 0.975, model = "GARCH", variance.model =
list(model = "sGARCH"), nboot = 10000)
garch
#> $VaR
#> [1] 0.02300646
#> 
#> $ES
#> [1] 0.02917895
#> 
#> $p
#> [1] 0.975
#> 
#> $garchmod
#> 
#> *---------------------------------*
#> *          GARCH Model Fit        *
#> *---------------------------------*
#> 
#> Conditional Variance Dynamics 	
#> -----------------------------------
#> GARCH Model	: sGARCH(1,1)
#> Mean Model	: ARFIMA(0,0,0)
#> Distribution	: norm 
#> 
#> Optimal Parameters
#> ------------------------------------
#>         Estimate  Std. Error  t value Pr(>|t|)
#> mu      0.000662    0.000141   4.6989 0.000003
#> omega   0.000003    0.000001   2.9225 0.003473
#> alpha1  0.094987    0.009186  10.3409 0.000000
#> beta1   0.890729    0.010221  87.1483 0.000000
#> 
#> Robust Standard Errors:
#>         Estimate  Std. Error  t value Pr(>|t|)
#> mu      0.000662    0.000129  5.13189 0.000000
#> omega   0.000003    0.000004  0.65098 0.515059
#> alpha1  0.094987    0.027338  3.47457 0.000512
#> beta1   0.890729    0.035855 24.84286 0.000000
#> 
#> LogLikelihood : 16665.98 
#> 
#> Information Criteria
#> ------------------------------------
#>                     
#> Akaike       -5.9710
#> Bayes        -5.9662
#> Shibata      -5.9710
#> Hannan-Quinn -5.9693
#> 
#> Weighted Ljung-Box Test on Standardized Residuals
#> ------------------------------------
#>                         statistic p-value
#> Lag[1]                     0.2708  0.6028
#> Lag[2*(p+q)+(p+q)-1][2]    0.5562  0.6678
#> Lag[4*(p+q)+(p+q)-1][5]    1.5043  0.7388
#> d.o.f=0
#> H0 : No serial correlation
#> 
#> Weighted Ljung-Box Test on Standardized Squared Residuals
#> ------------------------------------
#>                         statistic   p-value
#> Lag[1]                      5.111 0.0237737
#> Lag[2*(p+q)+(p+q)-1][5]    13.799 0.0009311
#> Lag[4*(p+q)+(p+q)-1][9]    16.489 0.0015467
#> d.o.f=2
#> 
#> Weighted ARCH LM Tests
#> ------------------------------------
#>             Statistic Shape Scale   P-Value
#> ARCH Lag[3]     13.33 0.500 2.000 0.0002605
#> ARCH Lag[5]     13.75 1.440 1.667 0.0007851
#> ARCH Lag[7]     13.81 2.315 1.543 0.0022585
#> 
#> Nyblom stability test
#> ------------------------------------
#> Joint Statistic:  19.193
#> Individual Statistics:             
#> mu     0.0759
#> omega  3.0459
#> alpha1 0.2056
#> beta1  0.1792
#> 
#> Asymptotic Critical Values (10% 5% 1%)
#> Joint Statistic:     	 1.07 1.24 1.6
#> Individual Statistic:	 0.35 0.47 0.75
#> 
#> Sign Bias Test
#> ------------------------------------
#>                    t-value      prob sig
#> Sign Bias           2.0500 4.041e-02  **
#> Negative Sign Bias  0.3604 7.185e-01    
#> Positive Sign Bias  3.6506 2.640e-04 ***
#> Joint Effect       43.7545 1.702e-09 ***
#> 
#> 
#> Adjusted Pearson Goodness-of-Fit Test:
#> ------------------------------------
#>   group statistic p-value(g-1)
#> 1    20     179.4    4.065e-28
#> 2    30     193.7    2.815e-26
#> 3    40     224.3    6.938e-28
#> 4    50     244.4    9.269e-28
#> 
#> 
#> Elapsed time : 0.8042977 
#> 
#>