# varcast: Calculation of one-step ahead forecasts of Value at Risk and... In ufRisk: Risk Measure Calculation in Financial TS

 varcast R Documentation

## Calculation of one-step ahead forecasts of Value at Risk and Expected Shortfall (parametric and semiparametric)

### Description

One-step ahead forecasts of Value at Risk and Expected Shortfall for a selection of short-memory and long-memory parametric as well as semiparametric GARCH-type models are computed.

### Usage

varcast(
x,
a.v = 0.99,
a.e = 0.975,
model = c("sGARCH", "lGARCH", "eGARCH", "apARCH", "fiGARCH", "filGARCH"),
garchOrder = c(1, 1),
distr = c("norm", "std"),
n.out = 250,
smooth = c("none", "lpr"),
...
)


### Arguments

 x a vector containing the price series. a.v confidence level for calculating VaR; is set to 0.99 by default. a.e confidence level for calculating ES; is set to 0.975 by default. model model to be estimated. Options are 'sGARCH', 'eGARCH', 'apARCH', 'lGARCH', 'fiGARCH' and 'filGARCH'; is set to 'sGARCH' by default. garchOrder orders to be estimated; c(1, 1), i.e. p = q = 1, is the default. distr distribution to use for the innovations of the respective GARCH model; is set to 'std' by default n.out size of out-sample; is set to 250 by default. smooth a character object; defines the data-driven smoothing approach for the estimation of the nonparametric scale function; for smooth = 'lpr', the scale function is obtained from the logarithm of the squared centralized returns by means of the msmooth() function or tsmoothlm() function if model is set to 'sGARCH', 'eGARCH', 'apARCH' and lGARCH'} or \code{'fiGARCH and 'filGARCH', respectively; is set to smooth = 'none' by default. ... depending on the choice of model, further arguments can be passed to either smoots::msmooth() or to tsmoothlm(); if no other arguments are given, the default settings are used for both functions with the exception of p = 3.

### Details

Let Y_t be a (demeaned) return series. The semiparametric extension of the GARCH(p,q) model (Bollerslev, 1986) is called a Semi-GARCH model (Feng, 2004) and is defined by

Y_t = s(x_t)\sigma_t \eta_t,

with \eta_t \sim IID(0,1) and

\sigma^2_t = \alpha_0 + \sum_{i=1}^p \alpha_i Y^2_{t-i} + \sum_{j=1}^q \beta_j \sigma^2_{t-j},

where \sigma_t > 0 are the conditional standard deviations, s(x_t) > 0 is a nonparametric scale function with x_t being the rescaled observation time points on the interval [0,1] and \alpha_i and \beta_j are non-negative real valued coefficients, except for \alpha_0, which must satisfy \alpha_0 > 0. Furthermore, it is assumed that Var(\sigma_t \eta_t) = 1. In this functions, different short-memory and long-memory GARCH-type models are selectable for the parametric part of the model. More specifically, the standard GARCH (Bollerslev, 1986), the Log-GARCH (Pantula, 1986; Geweke, 1986; Milhoj, 1988), the eGARCH (Nelson, 1991), the APARCH (Ding et al., 1993), the FIGARCH (Baillie et al., 1996) and the FI-Log-GARCH (Feng et al., 2020) model are implemented. For more information on the representations of the last three models mentioned, we refer the reader to the corresponding references listed in the references section.

While the innovations \eta_t must be i.i.d. (independent and identically distributed) with zero-mean and unit-variance and while any distribution that satisfies these conditions is suitable, the standardized t-distribution is selected for the estimation of the models and computation of the Value at Risk (VaR) as well as the Expected Shortfall (ES) within this function.

For a given level \alpha \in (0, 1),

VaR(\alpha) = inf \{z \in R: F_L(z) \geq \alpha\}

defines the VaR at level alpha. In this definition, L is the loss variable (making a loss is denoted as a positive value, whereas gains are negative values) and F_L is its cumulative distribution function. Explained differently, VaR(\alpha) is the \alpha-quantile of the loss distribution.

The ES for a level \alpha, however, is given by

ES(\alpha) = (1 / (1 - \alpha)) \int_{\alpha}^1 VaR(u)du,

i.e. it is the expected loss in case VaR(\alpha) is exceeded. More information on these risk measures can be found on pp. 64-72 in McNeil et al. (2015).

To apply the function, a numeric vector that contains the price series that is to be analyzed ordered from past to present must be passed to the argument x. Furthermore, the user can set different levels of alpha for the VaR and the ES via the arguments a.v and a.e, respectively. A parametric short-memory or long-memory GARCH-type model can be selected by means of model, which only accepts a single-element character vector as input. At the time of the release of package version 1.0.0, a standard GARCH ('sGARCH'), a Log-GARCH ('lGARCH'), an eGARCH ('eGARCH'), an APARCH ('apARCH'), a FIGARCH ('fiGARCH') and a FI-Log-GARCH ('filGARCH') model can be selected, each with conditional t-distribution. By default, a standard GARCH model is applied. The orders of the GARCH-type models can be defined with garchOrder, which is a numeric vector with two elements. Its first element is the ARCH order p, whereas the GARCH order q can be adjusted via the second element. If no adjustments are made, the orders p = q = 1 are selected. The number of out-sample observations is set via the argument n.out. If n is the total number of observations of the whole price series, the model is estimated for the first n - n.out observations (in-sample), while the VaR and the ES are obtained for the last n.out observations (out-sample) based on the estimated model for the in-sample. Moreover, the data-driven estimation method of the underlying scale function can be adjusted via the argument smooth. If smooth = 'lpr' is selected, the scale function is obtained by applying an iterative plug-in algorithm logarithm of the squared centralized returns. Depending on the setting of model an algorithm proposed by Feng, Gries and Fritz (2020) or by Letmathe, Feng and Uhde (2021) is employed. In the former case, the function msmooth() of the smoots package is applied and for the latter the tsmoothlm() function of the esemifar package is used. An ellipsis ... is implemented to allow for additional arguments for msmooth() and tsmoothlm().

NOTE:

This function makes use of the arima() function of the stats package, of the fracdiff() function of the fracdiff package, of the ugarchspec() and ugarchfit() functions of the rugarch package, of the msmooth() function of the smoots package and of the esemifar() function of the esemifar for estimation. Moreover, Log-GARCH and FI-Log-GARCH models in the parametric part of the complete models are estimated via their ARMA and FARIMA representations, respectively, and must therefore satisfy p \geq q.

### Value

This function returns a list with the following elements.

model

selected model for estimation

mean

the estimated mean of the in-sample returns

model.fit

estimated model parameters for the parametric part of the in-sample

np.est

the estimation results for the nonparametric part of the in-sample model

ret.in

in-sample return series

ret.out

out-sample return series

sig.in

estimated in-sample total volatility

sig.fc

out-sample forecasts of the total volatility

scale

the estimated nonparametric scale function values for the in-sample

scale.fc

the scale function forecast for the out-sample

VaR.e

out-sample forecasts of the (1-a.e)100% VaR

VaR.v

out-sample forecasts of the (1-a.v)100% VaR

ES

out-sample forecasts of the (1-a.e)100% ES

dfree

estimated degrees of freedom for the standardized returns

a.v

coverage level for the 99 % VaR

a.e

coverage level for 97.5 % VaR

garchOrder

the orders p and q of the implemented GARCH-type model

### Author(s)

• Sebastian Letmathe (Scientific Employee) (Department of Economics, Paderborn University)

• Dominik Schulz (Scientific Employee) (Department of Economics, Paderborn University),

### References

Baillie, R. T., Bollerslev, T., & Mikkelsen, H. O. (1996). Fractionally integrated generalized autoregressive conditional heteroskedasticity. In: Journal of Econometrics, 74.1, pp. 3-30.

Bollerslev, T. (1986) Generalized autoregressive conditional heteroskedasticity. In: Journal of Econometrics 31.3, pp. 307-327.

Ding, Z., Granger, C.W., and Engle, R.F. (1993). A long memory property of stock market returns and a new model. In: Journal of Empirical Finance 1.1, pp. 83-106.

Feng, Y. (2004). Simultaneously modeling conditional heteroskedasticity and scale change. In: Econometric Theory 20.3, pp. 563-596.

Feng, Y., Beran, J., Letmathe, S., & Ghosh, S. (2020). Fractionally integrated Log-GARCH with application to value at risk and expected shortfall (No. 137). Paderborn University, CIE Center for International Economics.

Pantula, S.G. (1986). Modeling the persistence of conditional variances: a comment. In: Econometric Reviews 5, pp. 79-97.

Geweke, J. (1986). Comment on: Modelling the persistence of conditional variances. In: Econometric Reviews 5, pp. 57-61.

Letmathe, S., Feng, Y., & Uhde, A. (2021). Semiparametric GARCH models with long memory applied to Value at Risk and Expected Shortfall (No. 141). Paderborn University, CIE Center for International Economics.

McNeil, A.J., Frey, R., and Embrechts, P. (2015). Quantitative risk management: concepts, techniques and tools - revised edition. Princeton University Press.

Milhoj, A. (1988). A Multiplicative parametrization of ARCH models. Universitetets Statistiske Institut.

Nelson, D. B. (1991). Conditional heteroskedasticity in asset returns: A new approach. In: Econometrica: Journal of the Econometric Society, 347-370.

### Examples


# Example for Walmart Inc. (WMT)
prices = WMT$price.close # forecasting VaR and ES results = varcast(prices, model = 'sGARCH', n.out = 250) ret.out = results$ret.out
n.out = length(ret.out)
VaR97.5 = results$VaR.e VaR99 = results$VaR.v
ES = results\$ES

# plotting VaR at 99% coverage
matplot(1:n.out, cbind(-ret.out, VaR99),
type = 'hl',
xlab = 'number of out-of-sample obs.', ylab = 'losses, VaR and ES',
main = '99% VaR (red) for the WMT return series')

# plotting VaR at 97.5% coverage and corresponding ES
matplot(1:n.out, cbind(-ret.out, ES, VaR97.5),
type = 'hll',
xlab = 'number of out-of-sample obs.', ylab = 'losses, VaR and ES',
main = '97.5% VaR (green) and ES (red) for the WMT return series')



ufRisk documentation built on Oct. 22, 2023, 9:07 a.m.