Title: | Simple Methods for Calculating and Backtesting Value at Risk and Expected Shortfall |
---|---|
Description: | Enables the user to calculate Value at Risk (VaR) and Expected Shortfall (ES) by means of various types of historical simulation. Currently plain-, age-, volatility-weighted- and filtered historical simulation are implemented in this package. Volatility weighting can be carried out via an exponentially weighted moving average model (EWMA) or other GARCH-type models. The performance can be assessed via Traffic Light Test, Coverage Tests and Loss Functions. The methods of the package are described in Gurrola-Perez, P. and Murphy, D. (2015) <https://EconPapers.repec.org/RePEc:boe:boeewp:0525> as well as McNeil, J., Frey, R., and Embrechts, P. (2015) <https://ideas.repec.org/b/pup/pbooks/10496.html>. |
Authors: | Sebastian Letmathe [aut, cre] |
Maintainer: | Sebastian Letmathe <[email protected]> |
License: | GPL-3 |
Version: | 1.1.4 |
Built: | 2024-12-06 06:52:30 UTC |
Source: | CRAN |
The conditional (Kupiec, 1995), the unconditional coverage test (Christoffersen, 1998) and the independence test (Christoffersen, 1998) of the Value-at-Risk (VaR) are applied.
cvgtest(obj = list(loss = NULL, VaR = NULL, p = NULL), conflvl = 0.95)
cvgtest(obj = list(loss = NULL, VaR = NULL, p = NULL), conflvl = 0.95)
obj |
a list that contains the following elements:
|
conflvl |
a numeric vector with one element; the significance
level at which the null hypotheses are evaluated; is set to |
With this function, the conditional and the unconditional coverage
tests introduced by Kupiec (1995) and Christoffersen (1998) can be applied.
Given a return series with
observations, divide the
series into
in-sample and
out-of-sample observations,
fit a model to the in-sample data and obtain rolling one-step forecasts of
the VaR for the out-of-sample time points.
Define
if or
otherwise,
for as the hit sequence, where
is
the confidence level for the VaR (often
or
).
Furthermore, denote
and let
be the actual covered
proportion of losses in the data.
1. Unconditional coverage test:
Let be the number of ones in
and analogously
the number of
zeros (all conditional on the first observation).
Also calculate
. Obtain
and
and subsequently the test statistic
now asymptotically follows a chi-square-distribution with one degree
of freedom.
2. Conditional coverage test:
The conditional coverage test combines the unconditional coverage test
with a test on independence. Denote by the probability of an
on day
being followed by a
on day
, where
and
correspond to the value of
on the respective day.
with and
.
Let be the number of observations, where the values on two following days
follow the pattern
. Calculate
where and
. The test
statistic is then given by
which asymptotically follows a chi-square-distribution with two degrees of freedom.
3. Independence test:
The asymptotically chi-square-distributed test statistic (one degree of freedom) is given by
—————————————————————————–
The function needs four inputs: the out-of-sample loss series obj$loss
, the
corresponding estimated VaR series obj$VaR
, the coverage level obj$p
,
for which the VaR has been calculated and the significance level conflvl
,
at which the null hypotheses are evaluated. If an object returned by this
function is entered into the R console, a detailed overview of the test results
is printed.
A list of class quarks
with the following four elements:
probability p stated in the null hypotheses of the coverage tests
the p-value of the unconditional coverage test
the p-value of the conditional coverage test
the p-value of the independence test
the significance level at which the null hypotheses are evaluated
selected model for estimation; only available if a list
returned by the rollcast
function is passed to cvgtest
selected method for estimation; only available if a list
returned by the rollcast
) function is passed to cvgtest
Christoffersen, P. F. (1998). Evaluating interval forecasts. International economic review, pp. 841-862.
Kupiec, P. (1995). Techniques for verifying the accuracy of risk measurement models. The J. of Derivatives, 3(2).
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) cvgtest(results)
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) cvgtest(results)
A dataset that contains the daily financial data of the DAX from 2000 to December 2023 (currency in EUR).
DAX
DAX
A data frame with 6094 rows and 11 variables:
id of the stock
date in format YY-MM-DD
opening price (daily)
highest price (daily)
lowest price (daily)
closing price (daily)
trading volume
adjusted closing price (daily)
returns obtained from the adj. closing prices
returns obtained from the closing prices
accumulated arithmetic/log return for the period
The data was obtained from Yahoo Finance.
A dataset that contains the daily financial data of the DJI from 2000 to December 2023 (currency in USD).
DJI
DJI
A data frame with 6037 rows and 11 variables:
id of the stock
date in format YY-MM-DD
opening price (daily)
highest price (daily)
lowest price (daily)
closing price (daily)
trading volume
adjusted closing price (daily)
returns obtained from the adj. closing prices
returns obtained from the closing prices
accumulated arithmetic/log return for the period
The data was obtained from Yahoo Finance.
Estimates volatility of a return series by means of an exponentially weighted moving average.
ewma(x, lambda = 0.94)
ewma(x, lambda = 0.94)
x |
a numeric vector of asset returns |
lambda |
decay factor for the calculation of weights; default is |
Returns a numerical vector vol
that contains the computed
volatility.
prices <- DAX$price_close returns <- diff(log(prices)) date <- DAX$ref_date[-1] cvar <- ewma(x = returns, lambda = 0.94) csig <- sqrt(cvar) plot(date, csig, type = 'l', main = 'conditional standard deviations for the DAX30 return series')
prices <- DAX$price_close returns <- diff(log(prices)) date <- DAX$ref_date[-1] cvar <- ewma(x = returns, lambda = 0.94) csig <- sqrt(cvar) plot(date, csig, type = 'l', main = 'conditional standard deviations for the DAX30 return series')
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, ...)
fhs(x, p = 0.975, model = c("EWMA", "GARCH"), lambda = 0.94, nboot = NULL, ...)
x |
a numeric vector of asset returns |
p |
confidence level for VaR calculation; default is |
model |
model for estimating conditional volatility; options are |
lambda |
decay factor for the calculation of weights; default is |
nboot |
size of bootstrap sample; must be a single non-NA integer value
with |
... |
additional arguments of the
|
Returns a list with the following elements:
Calculated Value at Risk
Calculated Expected Shortfall (Conditional Value at Risk)
Confidence level for VaR calculation
The model fit. Is the respective GARCH fit for
model = "GARCH"
(see rugarch
documentation) and 'EWMA'
for
model = "EWMA"
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 # volatility weighting via GARCH garch <- fhs(x = returns, p = 0.975, model = "GARCH", variance.model = list(model = "sGARCH"), nboot = 10000) garch
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 # volatility weighting via GARCH garch <- fhs(x = returns, p = 0.975, model = "GARCH", variance.model = list(model = "sGARCH"), nboot = 10000) garch
A dataset that contains the daily financial data of the FTSE from 2000 to December 2023 (currency in EUR).
FTSE100
FTSE100
A data frame with 6060 rows and 11 variables:
id of the stock
date in format YY-MM-DD
opening price (daily)
highest price (daily)
lowest price (daily)
closing price (daily)
trading volume
adjusted closing price (daily)
returns obtained from the adj. closing prices
returns obtained from the closing prices
accumulated arithmetic/log return for the period
The data was obtained from Yahoo Finance.
Computes 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)
hs(x, p = 0.975, method = c("age", "plain"), lambda = 0.98)
x |
a numeric vector of asset returns |
p |
confidence level for VaR calculation; default is |
method |
method to be used for calculation; default is |
lambda |
decay factor for the calculation of weights; default is |
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') hs(x = returns, p = 0.975, method = 'age', lambda = 0.98)
prices <- DAX$price_close returns <- diff(log(prices)) hs(x = returns, p = 0.975, method = 'plain') hs(x = returns, p = 0.975, method = 'age', lambda = 0.98)
A dataset that contains the daily financial data of the HSI from 2000 to December 2023.
HSI
HSI
A data frame with 5914 rows and 11 variables:
id of the stock
date in format YY-MM-DD
opening price (daily)
highest price (daily)
lowest price (daily)
closing price (daily)
trading volume
adjusted closing price (daily)
returns obtained from the adj. closing prices
returns obtained from the closing prices
accumulated arithmetic/log return for the period
The data was obtained from Yahoo Finance.
This 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)
lossfun(obj = list(loss = NULL, ES = NULL), beta = 1e-04)
obj |
a list that contains the following elements:
Please note that a list returned by the |
beta |
a single numeric value; a measure for the opportunity cost of
capital; default is |
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.
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
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) loss <- -results$xout ES <- results$ES loss.data <- list(loss = loss, ES = ES) lossfun(loss.data) # directly passing the output object of 'rollcast()' to 'lossfun()' lossfun(results)
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) loss <- -results$xout ES <- results$ES loss.data <- list(loss = loss, ES = ES) lossfun(loss.data) # directly passing the output object of 'rollcast()' to 'lossfun()' lossfun(results)
A dataset that contains the daily financial data of the NIK from 2000 to December 2023.
NIK225
NIK225
A data frame with 5881 rows and 11 variables:
id of the stock
date in format YY-MM-DD
opening price (daily)
highest price (daily)
lowest price (daily)
closing price (daily)
trading volume
adjusted closing price (daily)
returns obtained from the adj. closing prices
returns obtained from the closing prices
accumulated arithmetic/log return for the period
The data was obtained from Yahoo Finance.
Calculates portfolio returns or losses by assigning weights
plop(x, wts = NULL, approxim = c(0, 1))
plop(x, wts = NULL, approxim = c(0, 1))
x |
a numeric matrix of asset returns or losses |
wts |
a numeric vector or matrix containing the portfolio
weights; portfolio value is standardized to 1 on any observation unit;
sum of weights should not exceed 1 (row-wise for matrices); by default
the portfolio is equally weighted over time and across all assets; if a
vector is passed to |
approxim |
controls if a first-order approximation for the calculation
of returns or losses is used; default is |
Returns a list with the following elements:
Weighted portfolio returns or losses
Portfolio weights
# creating portfolio portfol <- cbind(SP500$price_close, DJI$price_close) returns <- apply(portfol, 2, function(x) diff(log(x))) # defining weights and applying the P&L operator function wts <- c(0.4, 0.6) portret <- plop(returns, wts = wts, approxim = 1) portloss <- plop(-returns, wts = wts, approxim = 1) plot.ts(cbind(portret$pl, portloss$pl))
# creating portfolio portfol <- cbind(SP500$price_close, DJI$price_close) returns <- apply(portfol, 2, function(x) diff(log(x))) # defining weights and applying the P&L operator function wts <- c(0.4, 0.6) portret <- plop(returns, wts = wts, approxim = 1) portloss <- plop(-returns, wts = wts, approxim = 1) plot.ts(cbind(portret$pl, portloss$pl))
This function regulates how objects created by the package quarks are plotted.
## S3 method for class 'quarks' plot(x, ...)
## S3 method for class 'quarks' plot(x, ...)
x |
an input object of class |
... |
additional arguments of the standard plot method. |
None
This function regulates how objects created by the package quarks
are
printed.
## S3 method for class 'quarks' print(x, ...)
## S3 method for class 'quarks' print(x, ...)
x |
an input object of class |
... |
included for compatibility; additional arguments will however not affect the output. |
None
Computes rolling one-step ahead forecasts of Value at Risk and Expected Shortfall (Conditional Value at Risk) by means of plain historical simulation age- and volatility-weighted historical simulation as well as filtered historical simulation.
rollcast( x, p = 0.975, model = c("EWMA", "GARCH"), method = c("plain", "age", "vwhs", "fhs"), lambda = c(0.94, 0.98), nout = NULL, nwin = NULL, nboot = NULL, smoothscale = c("none", "lpr", "auto"), smoothopts = list(), ... )
rollcast( x, p = 0.975, model = c("EWMA", "GARCH"), method = c("plain", "age", "vwhs", "fhs"), lambda = c(0.94, 0.98), nout = NULL, nwin = NULL, nboot = NULL, smoothscale = c("none", "lpr", "auto"), smoothopts = list(), ... )
x |
a numeric vector of asset returns |
p |
confidence level for VaR calculation; default is |
model |
model for estimating conditional volatility; options are |
method |
method to be used for calculation; default is |
lambda |
decay factor for the calculation of weights; default is |
nout |
number of out-of-sample observations; most recent observations are used;
default is |
nwin |
window size for rolling one-step forecasting; most recent observations
before out-of-sample are used; default is |
nboot |
size of bootstrap sample; must be a single non-NA integer value
with |
smoothscale |
a character object; defines the smoothing approach
for the unconditional variance from the logarithm of the squared centralized
returns; for |
smoothopts |
additional arguments of |
... |
additional arguments of the
|
Returns a list with the following elements:
Numerical vector containing out-of-sample forecasts of Value at Risk
Numerical vector containing out-of-sample forecasts of Expected Shortfall (Conditional Value at Risk)
Numerical vector containing out-of-sample returns
Confidence level for VaR calculation
Model for estimating conditional volatility
Method to be used for calculation
Number of out-of-sample observations
Window size for rolling one-step forecasting
Size of bootstrap sample
prices <- DAX$price_close returns <- diff(log(prices)) n <- length(returns) nout <- 250 # number of obs. for out-of-sample forecasting nwin <- 1000 # window size for rolling forecasts ### Example 1 - plain historical simulation results1 <- rollcast(x = returns, p = 0.975, method = 'plain', nout = nout, nwin = nwin) matplot(1:nout, cbind(-results1$xout, results1$VaR, results1$ES), type = 'hll', xlab = 'number of out-of-sample obs.', ylab = 'losses, VaR and ES', main = 'Plain HS - 97.5% VaR and ES for the DAX30 return series') ### Example 2 - age weighted historical simulation results2 <- rollcast(x = returns, p = 0.975, method = 'age', nout = nout, nwin = nwin) matplot(1:nout, cbind(-results2$xout, results2$VaR, results2$ES), type = 'hll', xlab = 'number of out-of-sample obs.', ylab = 'losses, VaR and ES', main = 'Age weighted HS - 97.5% VaR and ES for the DAX30 return series') ### Example 3 - volatility weighted historical simulation - EWMA results3 <- rollcast(x = returns, p = 0.975, model = 'EWMA', method = 'vwhs', nout = nout, nwin = nwin) matplot(1:nout, cbind(-results3$xout, results3$VaR, results3$ES), type = 'hll', xlab = 'number of out-of-sample obs.', ylab = 'losses, VaR and ES', main = 'Vol. weighted HS (EWMA) - 97.5% VaR and ES for the DAX30 return series') ### Example 4 - volatility weighted historical simulation - GARCH results4 <- rollcast(x = returns, p = 0.975, model = 'GARCH', method = 'vwhs', nout = nout, nwin = nwin) matplot(1:nout, cbind(-results4$xout, results4$VaR, results4$ES), type = 'hll', xlab = 'number of out-of-sample obs.', ylab = 'losses, VaR and ES', main = 'Vol. weighted HS (GARCH) - 97.5% VaR and ES for the DAX30 return series') ### Example 5 - filtered historical simulation - EWMA results5 <- rollcast(x = returns, p = 0.975, model = 'EWMA', method = 'fhs', nout = nout, nwin = nwin, nboot = 10000) matplot(1:nout, cbind(-results5$xout, results5$VaR, results5$ES), type = 'hll', xlab = 'number of out-of-sample obs.', ylab = 'losses, VaR and ES', main = 'Filtered HS (EWMA) - 97.5% VaR and ES for the DAX30 return series') ### Example 6 - filtered historical simulation - GARCH results6 <- rollcast(x = returns, p = 0.975, model = 'GARCH', method = 'fhs', nout = nout, nwin = nwin, nboot = 10000) matplot(1:nout, cbind(-results6$xout, results6$VaR, results6$ES), type = 'hll', xlab = 'number of out-of-sample obs.', ylab = 'losses, VaR and ES', main = 'Filtered HS (GARCH) - 97.5% VaR and ES for the DAX30 return series')
prices <- DAX$price_close returns <- diff(log(prices)) n <- length(returns) nout <- 250 # number of obs. for out-of-sample forecasting nwin <- 1000 # window size for rolling forecasts ### Example 1 - plain historical simulation results1 <- rollcast(x = returns, p = 0.975, method = 'plain', nout = nout, nwin = nwin) matplot(1:nout, cbind(-results1$xout, results1$VaR, results1$ES), type = 'hll', xlab = 'number of out-of-sample obs.', ylab = 'losses, VaR and ES', main = 'Plain HS - 97.5% VaR and ES for the DAX30 return series') ### Example 2 - age weighted historical simulation results2 <- rollcast(x = returns, p = 0.975, method = 'age', nout = nout, nwin = nwin) matplot(1:nout, cbind(-results2$xout, results2$VaR, results2$ES), type = 'hll', xlab = 'number of out-of-sample obs.', ylab = 'losses, VaR and ES', main = 'Age weighted HS - 97.5% VaR and ES for the DAX30 return series') ### Example 3 - volatility weighted historical simulation - EWMA results3 <- rollcast(x = returns, p = 0.975, model = 'EWMA', method = 'vwhs', nout = nout, nwin = nwin) matplot(1:nout, cbind(-results3$xout, results3$VaR, results3$ES), type = 'hll', xlab = 'number of out-of-sample obs.', ylab = 'losses, VaR and ES', main = 'Vol. weighted HS (EWMA) - 97.5% VaR and ES for the DAX30 return series') ### Example 4 - volatility weighted historical simulation - GARCH results4 <- rollcast(x = returns, p = 0.975, model = 'GARCH', method = 'vwhs', nout = nout, nwin = nwin) matplot(1:nout, cbind(-results4$xout, results4$VaR, results4$ES), type = 'hll', xlab = 'number of out-of-sample obs.', ylab = 'losses, VaR and ES', main = 'Vol. weighted HS (GARCH) - 97.5% VaR and ES for the DAX30 return series') ### Example 5 - filtered historical simulation - EWMA results5 <- rollcast(x = returns, p = 0.975, model = 'EWMA', method = 'fhs', nout = nout, nwin = nwin, nboot = 10000) matplot(1:nout, cbind(-results5$xout, results5$VaR, results5$ES), type = 'hll', xlab = 'number of out-of-sample obs.', ylab = 'losses, VaR and ES', main = 'Filtered HS (EWMA) - 97.5% VaR and ES for the DAX30 return series') ### Example 6 - filtered historical simulation - GARCH results6 <- rollcast(x = returns, p = 0.975, model = 'GARCH', method = 'fhs', nout = nout, nwin = nwin, nboot = 10000) matplot(1:nout, cbind(-results6$xout, results6$VaR, results6$ES), type = 'hll', xlab = 'number of out-of-sample obs.', ylab = 'losses, VaR and ES', main = 'Filtered HS (GARCH) - 97.5% VaR and ES for the DAX30 return series')
Application for downloading data from Yahoo Finance
runFTSdata()
runFTSdata()
None
A dataset that contains the daily financial data of the SP500 from 2000 to December 2023 (currency in USD).
SP500
SP500
A data frame with 6037 rows and 11 variables:
id of the stock
date in format YY-MM-DD
opening price (daily)
highest price (daily)
lowest price (daily)
closing price (daily)
trading volume
adjusted closing price (daily)
returns obtained from the adj. closing prices
returns obtained from the closing prices
accumulated arithmetic/log return for the period
The data was obtained from Yahoo Finance.
The Traffic Light Test, is applied to previously calculated Value-at-Risk series.
trftest(obj)
trftest(obj)
obj |
A list returned by the |
This function uses an object returned by the rollcast
function
of the quarks
package as an input for the
function argument obj
. A list with different elements, such as
the cumulative probabilities for the VaR series within obj
,
is returned. Instead of the list, only the traffic light backtesting results
are printed to the R console.
A list of class quarks
is returned with the following elements.
selected model for estimation
selected method for estimation
cumulative probability of observing the number of
breaches or fewer for (1 - p
)100%-VaR
number of exceedances for (1 - p
)100%-VaR
coverage level for (1-p
)100% VaR
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) trftest(results)
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) trftest(results)
Calculates univariate Value at Risk and Expected Shortfall (Conditional Value at Risk) by means of volatility weighted historical simulation. Volatility can be estimated with an exponentially weighted moving average or a GARCH-type model.
vwhs(x, p = 0.975, model = c("EWMA", "GARCH"), lambda = 0.94, ...)
vwhs(x, p = 0.975, model = c("EWMA", "GARCH"), lambda = 0.94, ...)
x |
a numeric vector of asset returns |
p |
confidence level for VaR calculation; default is |
model |
model for estimating conditional volatility; default is |
lambda |
decay factor for the calculation of weights; default is |
... |
additional arguments of the |
Returns a list with the following elements:
Calculated Value at Risk
Calculated Expected Shortfall (Conditional Value at Risk)
Confidence level for VaR calculation
The model fit. Is the respective GARCH fit for
model = 'GARCH'
(see rugarch
documentation) and 'EWMA'
for
model = 'EWMA'
prices <- DAX$price_close returns <- diff(log(prices)) # volatility weighting via EWMA ewma <- vwhs(x = returns, p = 0.975, model = "EWMA", lambda = 0.94) ewma # volatility weighting via GARCH garch <- vwhs(x = returns, p = 0.975, model = "GARCH", variance.model = list(model = "sGARCH")) garch
prices <- DAX$price_close returns <- diff(log(prices)) # volatility weighting via EWMA ewma <- vwhs(x = returns, p = 0.975, model = "EWMA", lambda = 0.94) ewma # volatility weighting via GARCH garch <- vwhs(x = returns, p = 0.975, model = "GARCH", variance.model = list(model = "sGARCH")) garch