| Title: | SM/LM EGARCH & GARCH, VaR/ES Backtesting & Dual LM Extensions |
|---|---|
| Description: | Implement and fit a variety of short-memory (SM) and long-memory (LM) models from a very broad family of exponential generalized autoregressive conditional heteroskedasticity (EGARCH) models, such as a MEGARCH (modified EGARCH), FIEGARCH (fractionally integrated EGARCH), FIMLog-GARCH (fractionally integrated modulus Log-GARCH), and more. The FIMLog-GARCH as part of the EGARCH family is discussed in Feng et al. (2023) <https://econpapers.repec.org/paper/pdnciepap/156.htm>. For convenience and the purpose of comparison, a variety of other popular SM and LM GARCH-type models, like an APARCH model, a fractionally integrated APARCH (FIAPARCH) model, standard GARCH and fractionally integrated GARCH (FIGARCH) models, GJR-GARCH and FIGJR-GARCH models, TGARCH and FITGARCH models, are implemented as well as dual models with simultaneous modelling of the mean, including dual long-memory models with a fractionally integrated autoregressive moving average (FARIMA) model in the mean and a long-memory model in the variance, and semiparametric volatility model extensions. Parametric models and parametric model parts are fitted through quasi-maximum-likelihood estimation. Furthermore, common forecasting and backtesting functions for value-at-risk (VaR) and expected shortfall (ES) based on the package's models are provided. |
| Authors: | Dominik Schulz [aut, cre] (Paderborn University, Germany), Yuanhua Feng [aut] (Paderborn University, Germany), Christian Peitz [aut] (Financial Intelligence Unit (German Government)), Oliver Kojo Ayensu [aut] (Paderborn University, Germany), Thomas Gries [ctb] (Paderborn University, Germany), Sikandar Siddiqui [ctb] (Deloitte Audit Analytics GmbH, Frankfurt, Germany), Shujie Li [ctb] (Paderborn University, Germany) |
| Maintainer: | Dominik Schulz <[email protected]> |
| License: | GPL-3 |
| Version: | 1.0.6 |
| Built: | 2026-06-10 07:41:19 UTC |
| Source: | https://github.com/cran/fEGarch |
A library of quasi maximum-likelihood estimation (QMLE) methods for fitting various short- and long-memory models from a broad family of exponential generalized autoregressive conditional heteroskedasticity (EGARCH) models. For the purpose of comparison, a FIAPARCH (fractionally integrated asymmetric power ARCH), a FIGARCH (fractionally integrated GARCH), a FITGARCH, a FIGJR-GARCH and their short-memory variants can be implemented as well.
fEGarch is an R package for estimating a broad family of
EGARCH models (Feng et al., 2025; Ayensu et al., 2025)
including both short- and long-memory as well as a
selection of varying transformations for the asymmetry and the
magnitude term in such a model, for example in form of the
FIMLog-GARCH (Feng et al., 2023). Log-GARCH specifications can be
implemented as well as a special case of the broad EGARCH family.
The six most common conditional distributions are supported, namely
a normal distribution, a - distribution, a generalized error
distribution, as well as the skewed variants of these three
distributions. Furthermore, as a novelty, an average Laplace (AL)
distribution (see for example Feng et al., 2025) and its skewed
version are provided as well.
The main functions to implement these models are
fEGarch_spec in combination with
fEGarch. Further details on these models can also
be found in the documentation of these two functions. For
convenience, further specification functions for particular
submodels are available as well: egarch_spec,
loggarch_spec, megarch_spec,
mloggarch_spec, fiegarch_spec,
filoggarch_spec,
fimegarch_spec and fimloggarch_spec.
As a popular alternative for the sake of comparison, a FIAPARCH
model can be fitted as well using fiaparch. The
corresponding documentation page also includes further information
on the model. Similarly, figarch can be utilized for
fitting FIGARCH models, fitgarch for fitting
FITGARCH models and figjrgarch for fitting
FIGJR-GARCH models. A general function for the estimation of additional
GARCH-type models, including the aforementioned additional models
as well as their short-memory variants, is
garchm_estim.
In addition, the package provides functionalities in order to
simultaneously model the conditional mean (using either autoregressive
moving-average (ARMA) models or fractionally integrated ARMA (FARIMA)
models) alongside the
conditional variance. For this purpose, the function
mean_spec can be utilized and its result needs to be
passed to fEGarch alongside the result of either
fEGarch_spec or one of its wrappers.
Further options include the specification of semiparametric volatility models (see also Ayensu et al., 2025), where a smooth, nonparametric scale function is at first estimated and removed from an observed series, before estimating a parametric model. The scale estimation is currently done through automated local polynomial regression with designated bandwidth selection algorithms under short memory and long memory.
The main functions of the package are:
fEGarch_spec:setting the model specifications for a model from the broader EGARCH family,
mean_spec:setting the model specifications for the conditional mean,
fEGarch:fitting a model from the broad family of EGARCH models given a model specification and an observation series,
garchm_estim:fitting a GARCH-type model selectable from a standard GARCH, a GJR-GARCH, a TGARCH, an APARCH, a FIGARCH, a FIGJR-GARCH, a FITGARCH and a FIAPARCH,
fEGarch_sim:simulating from an EGARCH family model,
fiaparch_sim:simulating from a FIAPARCH model,
figarch_sim:simulating from a FIGARCH model,
figjrgarch_sim:simulating from a FIGJR-GARCH model,
fitgarch_sim:simulating from a FITGARCH model,
aparch_sim:simulating from an APARCH model,
garch_sim:simulating from a GARCH model,
gjrgarch_sim:simulating from a GJR-GARCH model,
tgarch_sim:simulating from a TGARCH model,
predict,fEGarch_fit-method:multistep point forecasts of the conditional mean and the conditional standard deviation,
predict_roll,fEGarch_fit-method:rolling point forecasts of the conditional mean and the conditional standard deviation over a test set.
measure_risk:value at risk and expected shortfall computation for various model specifications.
find_dist:fits all eight distributions considered in this package to a supposed iid series and selects the best fitted distribution following either BIC (the default) or AIC.
backtest_suite,fEGarch_risk-method:runs a selection of functions for backtesting VaR and ES.
The package includes a few datasets. Follow the corresponding links to the documentation of the datasets to find additional information including the sources.
UKinflation:monthly inflation rate of the UK.
SP500:daily log-returns of the S&P 500 index.
The package is distributed under the General Public License v3 ([GPL-3](https://tldrlegal.com/license/gnu-general-public-license-v3-(gpl-3))).
Dominik Schulz (Department of Economics, Paderborn
University),
Author and Package Creator
Yuanhua Feng (Department of Economics, Paderborn
University),
Author
Christian Peitz (Financial Intelligence Unit, German Government),
Author
Oliver Kojo Ayensu (Department of Economics, Paderborn
University),
Author
Ayensu, O. K., Feng, Y., & Schulz, D. (2025). Recent Extensions of Exponential GARCH Models: Theory and Application. Forthcoming preprint, Paderborn University.
Baillie, R., Bollerslev, T., & Mikkelsen, H. O. (1996). Fractionally integrated generalized autoregressive conditional heteroskedasticity. Journal of Econometrics, 74(1), 3-30. DOI: 10.1016/S0304-4076(95)01749-6.
Bollerslev, T. (1986). Generalized autoregressive conditional heteroskedasticity. Journal of Econometrics, 31(3): 307-327. DOI: 10.1016/0304-4076(86)90063-1.
Bollerslev, T., & Mikkelsen, H. O. (1996). Modeling and pricing long memory in stock market volatility. Journal of Econometrics, 73(1), 151–184. DOI: 10.1016/0304-4076(95)01749-6.
Conrad, C., & Haag, B. R. (2006). Inequality constraints in the fractionally integrated GARCH model. Journal of Financial Econometrics, 4(3): 413-449. DOI: 10.1093/jjfinec/nbj015.
Conrad, C., & Karanasos, M. (2006). The impulse response function of the long memory GARCH process. Economics Letters, 90(1): 34-41. DOI: 10.1016/j.econlet.2005.07.001.
Ding, Z., Granger, C. W. J., & Engle, R. F. (1993). A long memory property of stock market returns and a new model. Journal of Empirical Finance, 1(1): 83-106. DOI: 10.1016/0927-5398(93)90006-D.
Engle, R. F. (1982). Autoregressive Conditional Heteroscedasticity with Estimates of the Variance of United Kingdom Inflation. Econometrica, 50(4): 987-1007. DOI: 10.2307/1912773.
Feng, Y., Beran, J., Ghosh, S., & Letmathe, S. (2020). Fractionally integrated Log-GARCH with application to value at risk and expected shortfall. Working Papers CIE No. 137, Paderborn University, Center for International Economics. URL: http://groups.uni-paderborn.de/wp-wiwi/RePEc/pdf/ciepap/WP137.pdf.
Feng, Y., Gries, T., Letmathe, S., & Schulz, D. (2022). The smoots Package in R for Semiparametric Modeling of Trend Stationary Time Series. The R Journal, 14(1), 182-195. URL: https://journal.r-project.org/articles/RJ-2022-017/.
Feng, Y., Gries, T., & Letmathe, S. (2023). FIEGARCH, modulus asymmetric FILog-GARCH and trend-stationary dual long memory time series. Working Papers CIE No. 156, Paderborn University. URL: https://econpapers.repec.org/paper/pdnciepap/156.htm.
Feng, Y., Peitz, C., & Siddiqui, S. (2025). A few useful members of the EGARCH-family with short- or long-memory in volatility. Unpublished working paper at Paderborn University.
Geweke, J. (1986). Modeling the persistence of conditional variances: A comment. Econometric Reviews, 5(1), 57-61. DOI: 10.1080/07474938608800088.
Glosten, L. R., Jagannathan, R., & Runkle, D. E. (1993). On The Relation between The Expected Value and The Volatility of Nominal Excess Return on stocks. Journal of Finance 48(5), 1779-1801. DOI: 10.1111/j.1540-6261.1993.tb05128.x.
Karanasos, M., Psaradakis, Z., & Sola, M. (2004). On the autocorrelation properties of long-memory GARCH processes. Journal of Time Series Analysis, 25(2): 265-281. DOI: 10.1046/j.0143-9782.2003.00349.x.
Letmathe, S., Beran, J., & Feng, Y. (2023). An extended exponential SEMIFAR model with application in R. Communications in Statistics - Theory and Methods, 53(22), 7914–7926. DOI: 10.1080/03610926.2023.2276049.
Milhoj, A. (1987). A Multiplicative Parameterization of ARCH Models. University of Copenhagen, Denmark.
Missiakoulis, S. (1983). Sargan Densities: Which One?. Journal of Econometrics, 23(2): 223-233. DOI: 10.1016/0304-4076(93)90078-J
Nelson, D. B. (1991). Conditional Heteroskedasticity in Asset Returns: A New Approach. Econometrica, 59(2), 347–370. DOI: 10.2307/2938260.
Nielsen, M. O., & Noel, A. L. (2021). To infinity and beyond: Efficient computation of ARCH()
models. Journal of Time Series Analysis,
42(3), 338–354. DOI: 10.1111/jtsa.12570.
Pantula, S. G. (1986). Modeling the persistence of conditional variances: A comment. Econometric Reviews, 5(1), 71-74. DOI: 10.1080/07474938608800089.
Tse, Y. K. (1987). A Note On Sargan Densities. Journal of Econometrics, 34(3): 349-354. DOI: 10.1016/0304-4076(87)90017-0
Tse, Y. K. (1998). The conditional heteroskedasticity of the yen-dollar exchange rate. Journal of Applied Econometrics, 13(1): 49-55. DOI: 10.1002/(SICI)1099-1255(199801/02)13:1<49::AID-JAE459>3.0.CO;2-O.
Zakoian, J.-M. (1994). Threshold heteroskedastic models. Journal of Economic Dynamics and Control, 18(5): 931-955. DOI: 10.1016/0165-1889(94)90039-6.
Accessors to access the elements of the same name in
output objects returned by either fEGarch,
garchm_estim, predict or predict_roll.
## S4 method for signature 'fEGarch_fit' sigt(x) ## S4 method for signature 'fEGarch_fit' cmeans(x) ## S4 method for signature 'fEGarch_fit' etat(x) ## S4 method for signature 'fEGarch_fit' inf_criteria(x) ## S4 method for signature 'fEGarch_fit' llhood(x) ## S4 method for signature 'fEGarch_fit' pars(x) ## S4 method for signature 'fEGarch_fit' se(x) ## S4 method for signature 'fEGarch_fit' vcov_mat(x) ## S4 method for signature 'fEGarch_forecast' sigt(x) ## S4 method for signature 'fEGarch_forecast' cmeans(x)## S4 method for signature 'fEGarch_fit' sigt(x) ## S4 method for signature 'fEGarch_fit' cmeans(x) ## S4 method for signature 'fEGarch_fit' etat(x) ## S4 method for signature 'fEGarch_fit' inf_criteria(x) ## S4 method for signature 'fEGarch_fit' llhood(x) ## S4 method for signature 'fEGarch_fit' pars(x) ## S4 method for signature 'fEGarch_fit' se(x) ## S4 method for signature 'fEGarch_fit' vcov_mat(x) ## S4 method for signature 'fEGarch_forecast' sigt(x) ## S4 method for signature 'fEGarch_forecast' cmeans(x)
x |
an object returned by either |
Convenience methods to access the elements of the same name
that can otherwise be accessed via the operator @ within
objects that inherit from class "fEGarch_fit", which covers
objects returned by either fEGarch,
garchm_estim, predict (for sigt and cmeans)
or predict_roll (for sigt and cmeans).
As alternatives for sigt, cmeans and etat, see also
sigma,fEGarch_fit-method, fitted,fEGarch_fit-method
and residuals,fEGarch_fit-method.
The element within the input object of the same name as the method
is returned. Depending on the element that can be a numeric vector,
an object of class "zoo" or a numeric matrix.
window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, start = "2010-01-01", end = "2012-12-31") est <- fEGarch(egarch_spec(), rt) # Access estimated conditional standard deviations using # the common operator "@" ... sigt1 <- est@sigt # ... or use the accessor method "sigt()" sigt2 <- sigt(est) zoo::plot.zoo( cbind("Approach 1" = sigt1, "Approach 2" = sigt2) ) # Other methods cmeans(est) etat(est) inf_criteria(est) llhood(est) pars(est) se(est) vcov_mat(est)window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, start = "2010-01-01", end = "2012-12-31") est <- fEGarch(egarch_spec(), rt) # Access estimated conditional standard deviations using # the common operator "@" ... sigt1 <- est@sigt # ... or use the accessor method "sigt()" sigt2 <- sigt(est) zoo::plot.zoo( cbind("Approach 1" = sigt1, "Approach 2" = sigt2) ) # Other methods cmeans(est) etat(est) inf_criteria(est) llhood(est) pars(est) se(est) vcov_mat(est)
Fit an APARCH model under the six most common and further conditional distributions to observed data using quasi maximum-likelihood estimation.
aparch( rt, orders = c(1, 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), meanspec = mean_spec(), Drange = c(0, 1), nonparspec = locpol_spec(), use_nonpar = FALSE, n_test = 0, start_pars = NULL, LB = NULL, UB = NULL, control = list(), control_nonpar = list(), mean_after_nonpar = FALSE, parallel = TRUE, ncores = max(1, future::availableCores() - 1), trunc = "none", presample = 50, Prange = c(1, 5), fix_delta = c(NA, 1, 2), skip_vcov = FALSE )aparch( rt, orders = c(1, 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), meanspec = mean_spec(), Drange = c(0, 1), nonparspec = locpol_spec(), use_nonpar = FALSE, n_test = 0, start_pars = NULL, LB = NULL, UB = NULL, control = list(), control_nonpar = list(), mean_after_nonpar = FALSE, parallel = TRUE, ncores = max(1, future::availableCores() - 1), trunc = "none", presample = 50, Prange = c(1, 5), fix_delta = c(NA, 1, 2), skip_vcov = FALSE )
rt |
the observed series ordered from past to present; can be
a numeric vector, a |
orders |
a two-element numeric vector containing the two model
orders |
cond_dist |
the conditional distribution to consider as a
character object; the default is a conditional normal distribution
|
meanspec |
an object of class "mean_spec"; indicates the specifications for the model in the conditional mean. |
Drange |
a two-element numeric vector that indicates the boundaries
of the interval over which to search for the fractional differencing
parameter |
nonparspec |
an object of class |
use_nonpar |
a logical indicating whether or not to implement a
semiparametric extension of the volatility model defined through |
n_test |
a single numerical value indicating, how many observations
at the end of |
start_pars |
the starting parameters for the numerical optimization
routine; should be of the same length as the parameter output vector
within the output object (also keeping the same order); for |
LB |
the lower boundaries of the parameters in the numerical optimization
routine; should be of the same length as the parameter output vector
within the output object (also keeping the same order); for |
UB |
the upper boundaries of the parameters in the numerical optimization
routine; should be of the same length as the parameter output vector
within the output object (also keeping the same order); for |
control |
a list that is passed to |
control_nonpar |
a list containing changes to the arguments
for the hyperparameter estimation algorithm in the nonparametric
scale function estimation for
|
mean_after_nonpar |
only for |
parallel |
only relevant for a (skewed) average Laplace (AL)
distribution, i.e.
if |
ncores |
only relevant for a (skewed) average Laplace (AL)
distribution, i.e.
if |
trunc |
a positive integer indicating the finite truncation length of the
infinite-order polynomials of the infinite-order representations of the
long-memory model parts; the character |
presample |
the presample length for initialization (for extended EGARCH- / Log-GARCH-type models only relevant for the FARIMA-part, as series in log-transformed conditional variance are initialized by zero). |
Prange |
a two-element vector that indicates the search boundaries for
the parameter |
fix_delta |
let the parameter |
skip_vcov |
a logical indicating whether or not to skip the computation of the variance-covariance matrix of the parameter estimators and therefore also standard error computation. |
Let , with as the
time index, be a theoretical time series that follows
Here, means that the innovations
are independent and identically distributed (iid) with mean zero
and variance one, whereas are the conditional standard
deviations in .
Moreover, , , , ,
are real-valued coefficients.
and are the model orders definable through the argument orders,
where is the first element and is the second element in the
argument. In addition, we have as a
real-valued parameter, and . is the intercept. It is assumed that
all and are non-negative.
See also the reference section for sources on the APARCH (Ding et al., 1993) and the FIAPARCH (Tse, 1998) models.
In the current package version, standard errors of parameter estimates are
computed from the Hessian at the optimum of the log-likelihood using
hessian. To ensure numerical stability and
applicability to a huge variety of differently scaled data, parametric
models are first fitted to data that is scaled to have sample variance
1. Parameter estimates and other quantities are then either
retransformed or recalculated afterwards for the original data.
For a conditional average Laplace distribution, an optimal model for each
distribution parameter from 1 to 5 is estimated (assuming that
is then fixed to the corresponding value). Afterwards, is then
estimated by selecting the estimated model among the five fitted models that
has the largest log-likelihood. The five models are, by default, fitted
simultaneously using parallel programming techniques (see also the arguments
parallel and ncores, which are only relevant for a conditional
average Laplace distribution). After the optimal model (including
the estimate of called ) has been determined,
is seen as fixed to obtain the standard errors via the Hessian matrix for the
estimates of the continuous parameters. A standard error for is therefore
not obtained and the ones obtained for the remaining estimates do not account
for .
An ARMA-APARCH or a FARIMA-APARCH can be fitted by adjusting the
argument meanspec correspondingly.
As an alternative, a semiparametric extension of the pure models
in the conditional variance can be implemented. If use_nonpar = TRUE,
meanspec is omitted and before fitting a model in the
conditional volatility following the remaining function arguments, a smooth scale function,
i.e. a function representing the unconditional standard deviation over time,
is being estimated following the specifications in nonparspec and
control_nonpar. This preliminary step stabilizes the input
series rt, as long-term changes in the unconditional variance
are being estimated and removed before the parametric step using
tsmooth. control_nonpar can be adjusted following
to make changes to the arguments of tsmooth
for short-memory specifications. These arguments specify settings
for the automated bandwidth selection algorithms implemented by this
function. By default, we use the settings
InfR = "Nai",
bStart = 0.15, cb = 0.05, and
method = "lpr" for tsmooth.
locpol_spec passed to nonparspec handles
more direct settings of the local polynomial smoother itself. See
the documentation for these functions to get a detailed overview
of these settings. Assume to be the observed series, where
,
then , with being the arithmetic
mean over the observed , is computed and subsequently
. The subtraction of
is necessary so that are all different from zero
almost surely. Once are available, its trend ,
with as the rescaled time on the interval , is
being estimated using
tsmooth and denoted here by
. Then from
obtain ,
and obtain the estimated scale function as
.
The stabilized / standardized version of the series
is then , to which
a purely parametric volatility model following the remaining function arguments
is then
fitted. The estimated volatility at a given time point is then
the product of the estimate of the corresponding scale function value
and of the estimated conditional standard deviation (following the parametric
model part) for that same time point. See for example Feng et al. (2022)
or Letmathe et al. (2023) for more information on the semiparametric extension
of volatility models.
The order for manual settings of start_pars, LB and UB
is crucial. The correct order is: , ,
,,,
, ,
, ,
shape parameter,
skewness parameter. Depending on the exact model specification,
parameters irrelevant for the specification at hand should be dropped
in start_pars, LB and UB.
An object of S4-class "fEGarch_fit_aparch"
is returned. It contains the following elements.
pars:a named numeric vector with the parameter estimates.
se:a named numeric vector with the obtained standard errors in accordance with the parameter estimates.
vcov_mat:the variance-covariance matrix of the parameter estimates with named columns and rows.
rt:the input object rt (or at least the training data, if n_test is greater than zero);
if rt was a "zoo" or "ts" object, the formatting is kept.
cmeans:the estimated conditional means; if rt was a "zoo" or "ts" object, the formatting is also applied to cmeans.
sigt:the estimated conditional standard deviations (or for use_nonpar = TRUE the estimated total
volatilities, i.e. scale function value times conditional standard deviation); if rt was a "zoo" or "ts" object, the formatting is also applied to sigt.
etat:the obtained residuals; if rt was a "zoo" or "ts" object, the formatting is also applied to etat.
orders:a two-element numeric vector stating the considered model orders.
cond_dist:a character value stating the conditional distribution considered in the model fitting.
long_memo:a logical value stating whether or not long memory was considered in the model fitting.
llhood:the log-likelihood value obtained at the optimal parameter combination.
inf_criteria:a named two-element numeric vector with the corresponding AIC (first element) and BIC (second element) of the fitted parametric model part; for purely parametric models, these criteria are valid for the entire model; for semiparametric models, they are only valid for the parametric step and are not valid for the entire model.
meanspec:the settings for the model in the conditional mean; is an object
of class "mean_spec" that is identical to the object passed to the input argument
meanspec.
test_obs:the observations at the end up the input rt reserved for
testing following n_test.
scale_fun:the estimated scale function values, if use_nonpar = TRUE, otherwise
NULL; formatting of rt is reused.
nonpar_model:the estimation object returned by tsmooth for
use_nonpar = TRUE.
trunc:the input argument trunc.
Ding, Z., Granger, C. W. J., & Engle, R. F. (1993). A long memory property of stock market returns and a new model. Journal of Empirical Finance, 1(1): 83-106. DOI: 10.1016/0927-5398(93)90006-D.
Feng, Y., Gries, T., Letmathe, S., & Schulz, D. (2022). The smoots Package in R for Semiparametric Modeling of Trend Stationary Time Series. The R Journal, 14(1), 182-195. URL: https://journal.r-project.org/articles/RJ-2022-017/.
Letmathe, S., Beran, J., & Feng, Y. (2023). An extended exponential SEMIFAR model with application in R. Communications in Statistics - Theory and Methods, 53(22), 7914–7926. DOI: 10.1080/03610926.2023.2276049.
Tse, Y. K. (1998). The conditional heteroskedasticity of the yen-dollar exchange rate. Journal of Applied Econometrics, 13(1): 49-55. DOI: 10.1002/(SICI)1099-1255(199801/02)13:1<49::AID-JAE459>3.0.CO;2-O.
window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") model <- aparch(rt) modelwindow.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") model <- aparch(rt) model
A streamlined simulation function to simulate from asymmetric power autoregressive conditional heteroskedasticity (APARCH) models.
aparch_sim( pars = list(mu = 0, ar = numeric(0), ma = numeric(0), D = 0, omega = 4e-04, phi = 0.05, beta = 0.8, gamma = 0.1, delta = 2, df = 10, shape = 2, P = 3, skew = 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), n = 1000, nstart = 5000, trunc = "none" )aparch_sim( pars = list(mu = 0, ar = numeric(0), ma = numeric(0), D = 0, omega = 4e-04, phi = 0.05, beta = 0.8, gamma = 0.1, delta = 2, df = 10, shape = 2, P = 3, skew = 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), n = 1000, nstart = 5000, trunc = "none" )
pars |
a named list with the parameter specifications; the user can provide a named list with only the settings they would like to adjust relative to the default settings. |
cond_dist |
a one-element character vector specifying the conditional distribution to consider. |
n |
the number of observations to return. |
nstart |
the number of burn-in observations to simulate before
the final |
trunc |
a truncation for the finite-order coefficient series
in long-memory models; can either be the character |
See the documentation on aparch for information
on the APARCH model. This function provides
an easy way to simulate from these models.
A list with four elements is returned: rt are the simulated
observations, etat are the underlying innovations,
sigt are the correspondingly simulated conditional
standard deviations, and cmeans are the simulated
conditional means. These four elements are formatted as
"ts" class time series objects.
sim <- aparch_sim(n = 1000) mat <- do.call(cbind, sim) plot(mat, main = "")sim <- aparch_sim(n = 1000) mat <- do.call(cbind, sim) plot(mat, main = "")
This is method for producing various plots of the decomposition results returned by this package.
## S4 method for signature 'fEGarch_fit' autoplot(object, which = NULL, ...)## S4 method for signature 'fEGarch_fit' autoplot(object, which = NULL, ...)
object |
an object returned by the fitting functions of this package,
for example by |
which |
various plots can be selected either via a keyword or a number;
enter |
... |
no purpose and only implemented for compatibility. |
Create predefined standard plots of the estimation objects returned by the
fEGarch package.
Plots are created in the ggplot2 plot style. The type of plot can be chosen
either interactively from the console, or the argument which can be
used to directly select the kind of plot to create (see also the description
of the argument which) within the function call.
A ggplot2-graphic object is returned, i.e. an object of classes
"gg" and "ggplot".
Dominik Schulz (Research Assistant) (Department of Economics, Paderborn
University),
Author and Package Creator
window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") # Pure conditional volatility model spec <- fEGarch_spec() model <- fEGarch(spec, rt) autoplot(model, which = 3)window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") # Pure conditional volatility model spec <- fEGarch_spec() model <- fEGarch(spec, rt) autoplot(model, which = 3)
ggplot2)Plot risk measure results returned by measure_risk
as a points-over-threshold plot in style of ggplot2.
## S4 method for signature 'fEGarch_risk' autoplot(object, which = NULL, ...)## S4 method for signature 'fEGarch_risk' autoplot(object, which = NULL, ...)
object |
an object returned by |
which |
one of the levels of VaR and ES saved in
|
... |
without use. |
Returns a ggplot2 plot object.
window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2003-12-31") egarch_spec() %>% fEGarch(rt = rt, n_test = 250) %>% predict_roll() %>% measure_risk() %>% autoplot(which = 0.99)window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2003-12-31") egarch_spec() %>% fEGarch(rt = rt, n_test = 250) %>% predict_roll() %>% measure_risk() %>% autoplot(which = 0.99)
Makes log-returns available from an input closing price series.
close_to_lreturn(close)close_to_lreturn(close)
close |
a closing price series as a numeric vector or some time series object
like |
Let , , be an observed closing price series. The function
returns
, t = 2,...,n.
Returns the log-return series following the input close. The output object
has one observation less than close, but keeps potential time series
formatting.
# Assume SP500 + 100 was a closing price series, # which it is not close <- SP500 + 100 close_to_lreturn(close)# Assume SP500 + 100 was a closing price series, # which it is not close <- SP500 + 100 close_to_lreturn(close)
Given a vector of values assumed to stem from
independent and identically distributed (iid) random variables, fit a selection
of distributions, from the normal distribution, the -distribution, the
generalized error distribution (GED), the average Laplace distribution (ALD), and
their skewed variants, to the data using maximum-likelihood estimation (MLE).
distr_est( x, dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), fix_mean = NULL, fix_sdev = NULL, Prange = c(1, 5), skip_vcov = FALSE ) norm_est(x, fix_mean = NULL, fix_sdev = NULL, skip_vcov = FALSE) std_est(x, fix_mean = NULL, fix_sdev = NULL, skip_vcov = FALSE) ged_est(x, fix_mean = NULL, fix_sdev = NULL, skip_vcov = FALSE) ald_est( x, fix_mean = NULL, fix_sdev = NULL, Prange = c(1, 5), skip_vcov = FALSE ) snorm_est(x, fix_mean = NULL, fix_sdev = NULL, skip_vcov = FALSE) sstd_est(x, fix_mean = NULL, fix_sdev = NULL, skip_vcov = FALSE) sged_est(x, fix_mean = NULL, fix_sdev = NULL, skip_vcov = FALSE) sald_est( x, fix_mean = NULL, fix_sdev = NULL, Prange = c(1, 5), skip_vcov = FALSE )distr_est( x, dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), fix_mean = NULL, fix_sdev = NULL, Prange = c(1, 5), skip_vcov = FALSE ) norm_est(x, fix_mean = NULL, fix_sdev = NULL, skip_vcov = FALSE) std_est(x, fix_mean = NULL, fix_sdev = NULL, skip_vcov = FALSE) ged_est(x, fix_mean = NULL, fix_sdev = NULL, skip_vcov = FALSE) ald_est( x, fix_mean = NULL, fix_sdev = NULL, Prange = c(1, 5), skip_vcov = FALSE ) snorm_est(x, fix_mean = NULL, fix_sdev = NULL, skip_vcov = FALSE) sstd_est(x, fix_mean = NULL, fix_sdev = NULL, skip_vcov = FALSE) sged_est(x, fix_mean = NULL, fix_sdev = NULL, skip_vcov = FALSE) sald_est( x, fix_mean = NULL, fix_sdev = NULL, Prange = c(1, 5), skip_vcov = FALSE )
x |
a numeric vector with the data. |
dist |
a character value that specifies the distribution to consider;
available are a normal distribution ( |
fix_mean |
optional; for the default |
fix_sdev |
optional; for the default |
Prange |
a two-element numeric vector, giving the boundaries of the search space
for the shape parameter |
skip_vcov |
a logical indicating whether or not the computation of the variance-covariance matrix should be skipped. |
Let be an individual observation. Let a real-valued location
parameter, representing the unconditional mean of the distribution, and
a real-valued scale parameter, representing the unconditional
standard deviation. Generally, let be a vector with all parameters
of the underlying distribution. The likelihood of is given through
for a normal distribution,
for a -distribution with as the degrees of freedom and
as the gamma function,
for a GED with as its real-valued shape and with , ,
and in
for an ALD with as its discrete shape, where ,
and
with .
The individual-observation likelihoods for the skewed variants are derived analogously
from the idea by Fernandez and Steel (1998). The log-likelihoods to maximize
over are then just the sum of the log-transformed likelihoods for each observation.
distr_est is a general purpose distribution fitting function, where the
distribution can be selected through the argument dist. norm_est,
std_est, ged_est, ald_est, snorm_est,
sstd_est, sged_est, and sald_est are wrappers around
distr_est in order to directly provide fitting functions for the
different distributions available in this package.
Returns a list with the following elements.
Fernandez, C., & Steel, M. F. J. (1998). Bayesian Modeling of Fat Tails and Skewness. Journal of the American Statistical Association, 93(441), 359–371. DOI: 10.1080/01621459.1998.10474117.
# Draw obs. from GED and implement standard deviation 1.2 # and mean 3.1 x <- rged_s(4000, shape = 1.5) * 1.2 + 3.1 # Fit GED ged_est(x) # Fit GED differently using distr_est() distr_est(x, dist = "ged") # Fit GED while fixing mean and standard deviation ged_est(x, fix_mean = 3.1, fix_sdev = 1.2) # Fit another distribution sstd_est(x)# Draw obs. from GED and implement standard deviation 1.2 # and mean 3.1 x <- rged_s(4000, shape = 1.5) * 1.2 + 3.1 # Fit GED ged_est(x) # Fit GED differently using distr_est() distr_est(x, dist = "ged") # Fit GED while fixing mean and standard deviation ged_est(x, fix_mean = 3.1, fix_sdev = 1.2) # Fit another distribution sstd_est(x)
Two common subspecifications of the broad EGARCH family, namely for a EGARCH-type and a Log-GARCH-type model.
egarch_type_spec( orders = c(1, 1), long_memo = TRUE, cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), powers = c(1, 1), modulus = c(FALSE, FALSE) ) loggarch_type_spec( orders = c(1, 1), long_memo = TRUE, cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald") )egarch_type_spec( orders = c(1, 1), long_memo = TRUE, cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), powers = c(1, 1), modulus = c(FALSE, FALSE) ) loggarch_type_spec( orders = c(1, 1), long_memo = TRUE, cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald") )
orders |
a two-element numeric vector with the model
orders; the first element is the order |
long_memo |
a logical value that indicates whether the long-memory version of the model should be considered or not. |
cond_dist |
a character value stating the underlying
conditional distribution to consider; available are a normal
distribution ( |
powers |
a two-element numeric vector that states the exponents in the power-transformations of the asymmetry and the magnitude terms in that order (see Details for more information). |
modulus |
a two-element logical vector indicating if the innovations in the asymmetry and the magnitude terms (in that order) should use a modulus transformation (see Details for more information). |
These are wrappers for fEGarch_spec.
egarch_type_spec() is when setting model_type in
fEGarch_spec to eGARCH.
loggarch_type_spec() is a shortcut when setting
model_type = "loggarch". See fEGarch_spec
for further details.
An object of class "egarch_type_spec" or
"loggarch_type_spec" is returned.
Use quasi-maximum-likelihood estimation to fit a model from the broader EGARCH family to some observed time series.
fEGarch( spec = egarch_spec(), rt, drange = c(0, 1), meanspec = mean_spec(), Drange = c(0, 1), nonparspec = locpol_spec(), use_nonpar = FALSE, n_test = 0, start_pars = NULL, LB = NULL, UB = NULL, control = list(), control_nonpar = list(), mean_after_nonpar = FALSE, parallel = TRUE, ncores = max(1, future::availableCores() - 1), trunc = "none", presample = 50, Prange = c(1, 5), skip_vcov = FALSE )fEGarch( spec = egarch_spec(), rt, drange = c(0, 1), meanspec = mean_spec(), Drange = c(0, 1), nonparspec = locpol_spec(), use_nonpar = FALSE, n_test = 0, start_pars = NULL, LB = NULL, UB = NULL, control = list(), control_nonpar = list(), mean_after_nonpar = FALSE, parallel = TRUE, ncores = max(1, future::availableCores() - 1), trunc = "none", presample = 50, Prange = c(1, 5), skip_vcov = FALSE )
spec |
an S4 object of class |
rt |
the input time series to fit the model to ordered from
past to present; can also be a |
drange |
a two-element numeric vector that indicates the boundaries
of the interval over which to search for the fractional differencing
parameter |
meanspec |
an object of class "mean_spec"; indicates the specifications for the model in the conditional mean. |
Drange |
a two-element numeric vector that indicates the boundaries
of the interval over which to search for the fractional differencing
parameter |
nonparspec |
an object of class |
use_nonpar |
a logical indicating whether or not to implement a
semiparametric extension of the volatility model defined through |
n_test |
a single numerical value indicating, how many observations
at the end of |
start_pars |
a vector with starting parameters for the optimization; must be of the same length as the output vector of parameters; the default NULL uses internally saved default sets of starting values; see "Details" for the order of elements. |
LB |
a vector with lower boundaries for parameters; must be of the same length as the output vector of parameters; the default NULL uses internally saved default sets of lower boundary values; see "Details" for the order of elements. |
UB |
a vector with upper boundaries for parameters; must be of the same length as the output vector of parameters; the default NULL uses internally saved default sets of upper boundary values; see "Details" for the order of elements. |
control |
a list that is passed to |
control_nonpar |
a list containing changes to the arguments
for the hyperparameter estimation algorithm in the nonparametric
scale function estimation for
|
mean_after_nonpar |
only for |
parallel |
only relevant for a (skewed) average Laplace (AL)
distribution, i.e.
if |
ncores |
only relevant for a (skewed) average Laplace (AL)
distribution, i.e.
if |
trunc |
a positive integer indicating the finite truncation length of the
infinite-order polynomials of the infinite-order representations of the
long-memory model parts; the character |
presample |
the presample length for initialization (for extended EGARCH- / Log-GARCH-type models only relevant for the FARIMA-part, as series in log-transformed conditional variance are initialized by zero). |
Prange |
a two-element vector that indicates the search boundaries for
the parameter |
skip_vcov |
a logical indicating whether or not to skip the computation of the variance-covariance matrix of the parameter estimators and therefore also standard error computation. |
For details on the models in the conditional variance, see fEGarch_spec.
For details on the models in the conditional mean, see mean_spec.
The combined model defined through mean_spec and
fEGarch_spec is the specified model. It can be thought of
as the model described in mean_spec with
therein being governed by a model from the EGARCH family (see for example Feng et al., 2025) as described in
fEGarch_spec, however with mean of fixed
to zero.
The specified model is then fitted using quasi maximum likelihood estimation,
where pre-sample values of are
filled in through its theoretical expectation of zero, which is analogous to not
setting pre-sample values in the long-memory case. In addition, in
short-memory models, pre-sample values of are roughly
approximated through , where
is the sample variance of the observations.
See the references section for sources on the EGARCH (Nelson, 1991), FIEGARCH (Bollerslev and Mikkelsen, 1996), Log-GARCH (Geweke, 1986; Pantula, 1986; Milhoj, 1987) and FILog-GARCH (Feng et al., 2020) models. For information on the FIMLog-GARCH, see Feng et al. (2023).
In the current package version, standard errors of parameter estimates are
computed from the Hessian at the optimum of the log-likelihood using
hessian. To ensure numerical stability and
applicability to a huge variety of differently scaled data, parametric
models are first fitted to data that is scaled to have sample variance
1. Parameter estimates and other quantities are then either
retransformed or recalculated afterwards for the original data.
For a conditional average Laplace distribution, an optimal model for each
distribution parameter from 1 to 5 is estimated (assuming that
is then fixed to the corresponding value). Afterwards, is then
estimated by selecting the estimated model among the five fitted models that
has the largest log-likelihood. The five models are, by default, fitted
simultaneously using parallel programming techniques (see also the arguments
parallel and ncores, which are only relevant for a conditional
average Laplace distribution). After the optimal model (including
the estimate of called ) has been determined,
is seen as fixed to obtain the standard errors via the Hessian matrix for the
estimates of the continuous parameters. A standard error for is therefore
not obtained and the ones obtained for the remaining estimates do not account
for .
As an alternative, a semiparametric extension of the pure models
in the conditional variance can be implemented. If use_nonpar = TRUE,
meanspec is omitted and before fitting a zero-mean model in the
conditional volatility following spec, a smooth scale function,
i.e. a function representing the unconditional standard deviation over time,
is being estimated following the specifications in nonparspec and
control_nonpar. This preliminary step stabilizes the input
series rt, as long-term changes in the unconditional variance
are being estimated and removed before the parametric step using
either tsmooth or tsmoothlm
depending on whether spec specifies a model with short memory
or with long memory. control_nonpar can be adjusted following
the arguments of tsmooth for short-memory
specifications of spec, on the other hand changes to
arguments of tsmoothlm can be passed to it
for long-memory specifications. These arguments specify settings
for the automated bandwidth selection algorithms implemented by these
two functions. By default, we use the settings
Mcf = "NP", InfR = "Opt",
bStart = 0.15, bvc = "Y", cb = 0.05,
and method = "lpr" within the call to tsmooth,
as well as pmin = 0, pmax = 1, qmin = 0,
qmax = 1, InfR = "Opt",
bStart = 0.15, cb = 0.05, and
method = "lpr" for tsmoothlm.
locpol_spec passed to nonparspec handles
more direct settings of the local polynomial smoother itself. See
the documentation for these functions to get a detailed overview
of these settings. Assume to be the observed series, where
,
then , with being the arithmetic
mean over the observed , is computed and subsequently
. The subtraction of
is necessary so that are all different from zero
almost surely. Once are available, its trend ,
with as the rescaled time on the interval , is
being estimated using either tsmooth or
tsmoothlm and denoted here by
. Then from
obtain ,
and obtain the estimated scale function as
.
The stabilized / standardized version of the series
is then , to which
a purely parametric volatility model following spec is then
fitted. The estimated volatility at a given time point is then
the product of the estimate of the corresponding scale function value
and of the estimated conditional standard deviation (following the parametric
model part) for that same time point. See for example Feng et al. (2022)
or Letmathe et al. (2023) for more information on the semiparametric extension
of volatility models. Moreover, if bwidth in the object passed to nonparspec
is not at its default NULL but instead a numeric value between 0 and 0.5,
the automated bandwidth selection is skipped and the provided bandwidth in bwidth
is used.
The order for manual settings of start_pars, LB and UB
is crucial. The correct order is: , ,
,,,
, , , ,
, ,
for Type I models (see fEGarch_spec). For Type
II models, we have , ,
,,,
, , ,
shape parameter,
skewness parameter. Depending on the exact model specification,
parameters irrelevant for the specification at hand should be dropped
in start_pars, LB and UB.
An object of S4-class "fEGarch_fit_egarch" "fEGarch_fit_loggarch"
is returned depending on the selected model type in the model
specification. It contains the following elements.
pars:a named numeric vector with the parameter estimates.
se:a named numeric vector with the obtained standard errors in accordance with the parameter estimates.
vcov_mat:the variance-covariance matrix of the parameter estimates with named columns and rows.
rt:the input object rt (or at least the training data, if n_test is greater than zero);
if rt was a "zoo" or "ts" object, the formatting is kept.
sigt:the estimated conditional standard deviations (or for use_nonpar = TRUE the estimated total
volatilities, i.e. scale function value times conditional standard deviation); if rt was a "zoo" or "ts" object, the formatting is also applied to sigt.
cmeans:the estimated conditional means; if rt was a "zoo" or "ts" object, the formatting is also applied to cmeans.
etat:the obtained residuals; if rt was a "zoo" or "ts" object, the formatting is also applied to etat.
orders:a two-element numeric vector stating the considered model orders.
cond_dist:a character value stating the conditional distribution considered in the model fitting.
long_memo:a logical value stating whether or not long memory was considered in the model fitting.
llhood:the log-likelihood value obtained at the optimal parameter combination.
inf_criteria:a named two-element numeric vector with the corresponding AIC (first element) and BIC (second element) of the fitted parametric model part; for purely parametric models, these criteria are valid for the entire model; for semiparametric models, they are only valid for the parametric step and are not valid for the entire model.
powers:a two-element numeric vector stating the powers considered for the asymmetry term (first element) and the magnitude term (second element); only exists, if a type I model was fitted.
modulus:a two-element logical vector stating the modulus transformations (TRUE, otherwise FALSE) considered for the asymmetry term (first element) and the magnitude term (second element); only exists, if a type I model was fitted.
meanspec:the settings for the model in the conditional mean; is an object
of class "mean_spec" that is identical to the object passed to the input argument
meanspec.
test_obs:the observations at the end up the input rt reserved for
testing following n_test.
scale_fun:the estimated scale function values, if use_nonpar = TRUE, otherwise
NULL; formatting of rt is reused.
nonpar_model:the estimation object returned by either
tsmooth or tsmoothlm for
use_nonpar = TRUE.
trunc:the input argument trunc.
Bollerslev, T., & Mikkelsen, H. O. (1996). Modeling and pricing long memory in stock market volatility. Journal of Econometrics, 73(1), 151–184. DOI: 10.1016/0304-4076(95)01749-6.
Feng, Y., Beran, J., Ghosh, S., & Letmathe, S. (2020). Fractionally integrated Log-GARCH with application to value at risk and expected shortfall. Working Papers CIE No. 137, Paderborn University, Center for International Economics. URL: http://groups.uni-paderborn.de/wp-wiwi/RePEc/pdf/ciepap/WP137.pdf.
Feng, Y., Gries, T., Letmathe, S., & Schulz, D. (2022). The smoots Package in R for Semiparametric Modeling of Trend Stationary Time Series. The R Journal, 14(1), 182-195. URL: https://journal.r-project.org/articles/RJ-2022-017/.
Feng, Y., Gries, T., & Letmathe, S. (2023). FIEGARCH, modulus asymmetric FILog-GARCH and trend-stationary dual long memory time series. Working Papers CIE No. 156, Paderborn University. URL: https://econpapers.repec.org/paper/pdnciepap/156.htm.
Feng, Y., Peitz, C., & Siddiqui, S. (2025). A few useful members of the EGARCH-family with short- or long-memory in volatility. Unpublished working paper at Paderborn University.
Geweke, J. (1986). Modeling the persistence of conditional variances: A comment. Econometric Reviews, 5(1), 57-61. DOI: 10.1080/07474938608800088.
Letmathe, S., Beran, J., & Feng, Y. (2023). An extended exponential SEMIFAR model with application in R. Communications in Statistics - Theory and Methods, 53(22), 7914–7926. DOI: 10.1080/03610926.2023.2276049.
Milhoj, A. (1987). A Multiplicative Parameterization of ARCH Models. University of Copenhagen, Denmark.
Nelson, D. B. (1991). Conditional Heteroskedasticity in Asset Returns: A New Approach. Econometrica, 59(2), 347–370. DOI: 10.2307/2938260.
Pantula, S. G. (1986). Modeling the persistence of conditional variances: A comment. Econometric Reviews, 5(1), 71-74. DOI: 10.1080/07474938608800089.
window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") # Pure conditional volatility model spec <- fEGarch_spec() model <- fEGarch(spec, rt) model # Simultaneously model conditional mean spec <- egarch_spec() model2 <- suppressWarnings( fEGarch(spec, rt, meanspec = mean_spec(orders = c(1, 1))) ) model2window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") # Pure conditional volatility model spec <- fEGarch_spec() model <- fEGarch(spec, rt) model # Simultaneously model conditional mean spec <- egarch_spec() model2 <- suppressWarnings( fEGarch(spec, rt, meanspec = mean_spec(orders = c(1, 1))) ) model2
A streamlined simulation function to simulate from models
that are part of the broader EGARCH family specifiable
through fEGarch_spec.
fEGarch_sim( spec = egarch_spec(), pars = list(mu = 0, ar = numeric(0), ma = numeric(0), D = 0, omega_sig = -9, phi = 0.8, psi = numeric(0), kappa = -0.2, gamma = 0.3, d = 0, df = 10, shape = 2, P = 3, skew = 1), n = 1000, nstart = 5000, trunc = "none" )fEGarch_sim( spec = egarch_spec(), pars = list(mu = 0, ar = numeric(0), ma = numeric(0), D = 0, omega_sig = -9, phi = 0.8, psi = numeric(0), kappa = -0.2, gamma = 0.3, d = 0, df = 10, shape = 2, P = 3, skew = 1), n = 1000, nstart = 5000, trunc = "none" )
spec |
an object of class |
pars |
a named list with the parameter specifications; the user can provide a named list with only the settings they would like to adjust relative to the default settings. |
n |
the number of observations to return. |
nstart |
the number of burn-in observations to simulate before
the final |
trunc |
a truncation for the finite-order coefficient series
in long-memory models; can either be the character |
See the documentation on fEGarch_spec for information
on the models of the broader EGARCH family. This function provides
an easy way to simulate from these models.
A list with four elements is returned: rt are the simulated
observations, etat are the underlying innovations,
sigt are the correspondingly simulated conditional
standard deviations, and cmeans are the simulated
conditional means. These four elements are formatted as
"ts" class time series objects.
spec <- megarch_spec() sim <- fEGarch_sim(spec = spec) mat <- do.call(cbind, sim) plot(mat, main = "")spec <- megarch_spec() sim <- fEGarch_sim(spec = spec) mat <- do.call(cbind, sim) plot(mat, main = "")
Create an object with specifications for a model from the broader EGARCH family.
fEGarch_spec( model_type = c("egarch", "loggarch"), orders = c(1, 1), long_memo = FALSE, cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), powers = c(1, 1), modulus = c(FALSE, FALSE) )fEGarch_spec( model_type = c("egarch", "loggarch"), orders = c(1, 1), long_memo = FALSE, cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), powers = c(1, 1), modulus = c(FALSE, FALSE) )
model_type |
a character value (either |
orders |
a two-element numeric vector with the model
orders; the first element is the order |
long_memo |
a logical value that indicates whether the long-memory version of the model should be considered or not. |
cond_dist |
a character value stating the underlying
conditional distribution to consider; available are a normal
distribution ( |
powers |
a two-element numeric vector that states the exponents in the power-transformations of the asymmetry and the magnitude terms in that order (see Details for more information). |
modulus |
a two-element logical vector indicating if the innovations in the asymmetry and the magnitude terms (in that order) should use a modulus transformation (see Details for more information). |
Let , with as the
time index, be a theoretical time series that follows
Here, means that the innovations
are independent and identically distributed (iid) with mean zero
and variance one, whereas are the conditional standard
deviations in . Note that denotes the natural logarithm.
Moreover, is the backshift operator and
, where
, , are real-valued coefficients.
is a suitable function in .
Generally, should be an iid
zero-mean sequence with finite variance.
We have as a real-valued parameter.
The real-valued parameter
is in fact
.
This previous set of
equations defines the broader family of EGARCH models (Feng et al., 2025; Ayensu et al., 2025), from which
subtypes are described in the following that depend on the choice of
.
We have , where
are characteristic polynomials
with real coefficients ,
by fixing , and without common roots. Furthermore,
the
fractional differencing parameter is .
can be defined in different ways.
Following a type I specification (model_type = "egarch"), we have
with and being
suitable transformations of and
where and are two additional real-valued
parameters. In case of a simple (FI)EGARCH, we have
(and therefore with
) and
.
Generally, we consider two cases:
whereas
Note that denotes the sign of
. incorporates a power transformation
and a modulus transformation together with a power
transformation. The choices
and correspond to
setting the first element in modulus to FALSE or
TRUE, respectively, under
model_type = "egarch", where can be selected
via the first element in powers. As a special case, for
, a log-transformation is employed and the division
through is dropped, i.e.
and
are employed for . Completely analogous
thoughts hold for and and the second
elements in the arguments modulus and powers. The aforementioned
model family is a type I model selectable through
model_type = "egarch". Simple (FI)EGARCH models are given through
selection of and
in combination with . Another of such type I models
is the FIMLog-GARCH (Feng et al., 2023), where instead
and are selected
with .
As additional specifications of a Log-GARCH and a FILog-GARCH, which belong to the broader EGARCH family, we redefine
now as a polynomial of order and
where
Everything else is defined as before. Since
where , , and by defining
the equation of can be stated to be
as in the broad EGARCH family at the very beginning. Therefore, Log-GARCH
and FI-Log-GARCH models are equivalent to the type I models, where
with usage of with and where
. Nonetheless,
in this package, the type II models make use of the more common
parameterization of stated at the
beginning of the type II model description.
This describes the
established Log-GARCH models as part of the broad EGARCH family
(type II models; model_type = "loggarch").
While the arguments powers and modulus are only relevant
under a type I model, i.e. for model_type = "egarch", the arguments
orders, long_memo and cond_dist are
meaningful for both model_type = "egarch"
and model_type = "loggarch", i.e. both under type I and II models.
The first element of the two-element vector orders is the order ,
while the second element is the order . Furthermore, for
long_memo = TRUE, the mentioned models are kept as they are, while
for long_memo = FALSE the parameter is set to zero.
cond_dist controls the conditional distribution.
The unconditional mean is controlled via the function
mean_spec; for include_mean = FALSE therein, is not being estimated and fixed
to zero; its default is however include_mean = TRUE.
See also the closely related spec-functions that immediately create
specifications of specific submodels of the broad EGARCH family. These
functions are egarch_spec(), fiegarch_spec(),
loggarch_spec(),filoggarch_spec(), megarch_spec(),
mloggarch_spec() and mafiloggarch_spec(), which are all
wrappers for fEGarch_spec().
See the references section for sources on the EGARCH (Nelson, 1991), FIEGARCH (Bollerslev and Mikkelsen, 1996), Log-GARCH (Geweke, 1986; Pantula, 1986; Milhoj, 1987) and FILog-GARCH (Feng et al., 2020) models.
An object of either class "egarch_type_spec" or
"loggarch_type_spec" is returned, depending on the
choice for the input argument model_type.
Ayensu, O. K., Feng, Y., & Schulz, D. (2025). Recent Extensions of Exponential GARCH Models: Theory and Application. Forthcoming preprint, Paderborn University.
Bollerslev, T., & Mikkelsen, H. O. (1996). Modeling and pricing long memory in stock market volatility. Journal of Econometrics, 73(1), 151–184. DOI: 10.1016/0304-4076(95)01749-6.
Feng, Y., Beran, J., Ghosh, S., & Letmathe, S. (2020). Fractionally integrated Log-GARCH with application to value at risk and expected shortfall. Working Papers CIE No. 137, Paderborn University, Center for International Economics. URL: http://groups.uni-paderborn.de/wp-wiwi/RePEc/pdf/ciepap/WP137.pdf.
Feng, Y., Gries, T., & Letmathe, S. (2023). FIEGARCH, modulus asymmetric FILog-GARCH and trend-stationary dual long memory time series. Working Papers CIE No. 156, Paderborn University. URL: https://econpapers.repec.org/paper/pdnciepap/156.htm.
Feng, Y., Peitz, C., & Siddiqui, S. (2025). A few useful members of the EGARCH-family with short- or long-memory in volatility. Unpublished working paper at Paderborn University.
Geweke, J. (1986). Modeling the persistence of conditional variances: A comment. Econometric Reviews, 5(1), 57-61. DOI: 10.1080/07474938608800088.
Milhoj, A. (1987). A Multiplicative Parameterization of ARCH Models. University of Copenhagen, Denmark.
Nelson, D. B. (1991). Conditional Heteroskedasticity in Asset Returns: A New Approach. Econometrica, 59(2), 347–370. DOI: 10.2307/2938260.
Pantula, S. G. (1986). Modeling the persistence of conditional variances: A comment. Econometric Reviews, 5(1), 71-74. DOI: 10.1080/07474938608800089.
# EGARCH(1, 1) with cond. normal distribution spec1 <- fEGarch_spec() # EGARCH(2, 1) with cond. t-distribution spec2 <- fEGarch_spec(orders = c(2, 1), cond_dist = "std") # FIEGARCH(1, 1) with cond. normal distribution spec3 <- fEGarch_spec(long_memo = TRUE) # MEGARCH(1, 1) with cond. generalized error distribution spec4 <- fEGarch_spec(modulus = c(TRUE, FALSE), powers = c(0, 1)) # Some unnamed specification spec5 <- fEGarch_spec( model_type = "egarch", orders = c(1, 1), long_memo = TRUE, cond_dist = "std", powers = c(0.25, 0.75), modulus = c(TRUE, FALSE) )# EGARCH(1, 1) with cond. normal distribution spec1 <- fEGarch_spec() # EGARCH(2, 1) with cond. t-distribution spec2 <- fEGarch_spec(orders = c(2, 1), cond_dist = "std") # FIEGARCH(1, 1) with cond. normal distribution spec3 <- fEGarch_spec(long_memo = TRUE) # MEGARCH(1, 1) with cond. generalized error distribution spec4 <- fEGarch_spec(modulus = c(TRUE, FALSE), powers = c(0, 1)) # Some unnamed specification spec5 <- fEGarch_spec( model_type = "egarch", orders = c(1, 1), long_memo = TRUE, cond_dist = "std", powers = c(0.25, 0.75), modulus = c(TRUE, FALSE) )
Fit a fractionally integrated APARCH model under the six most common and further conditional distributions to observed data using quasi maximum-likelihood estimation.
fiaparch( rt, orders = c(1, 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), drange = c(0, 1), meanspec = mean_spec(), Drange = c(0, 1), nonparspec = locpol_spec(), use_nonpar = FALSE, n_test = 0, start_pars = NULL, LB = NULL, UB = NULL, control = list(), control_nonpar = list(), mean_after_nonpar = FALSE, parallel = TRUE, ncores = max(1, future::availableCores() - 1), trunc = "none", presample = 50, Prange = c(1, 5), fix_delta = c(NA, 1, 2), skip_vcov = FALSE )fiaparch( rt, orders = c(1, 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), drange = c(0, 1), meanspec = mean_spec(), Drange = c(0, 1), nonparspec = locpol_spec(), use_nonpar = FALSE, n_test = 0, start_pars = NULL, LB = NULL, UB = NULL, control = list(), control_nonpar = list(), mean_after_nonpar = FALSE, parallel = TRUE, ncores = max(1, future::availableCores() - 1), trunc = "none", presample = 50, Prange = c(1, 5), fix_delta = c(NA, 1, 2), skip_vcov = FALSE )
rt |
the observed series ordered from past to present; can be
a numeric vector, a |
orders |
a two-element numeric vector containing the two model
orders |
cond_dist |
the conditional distribution to consider as a
character object; the default is a conditional normal distribution
|
drange |
a two-element numeric vector that gives the boundaries of the
search interval for the fractional differencing parameter |
meanspec |
an object of class "mean_spec"; indicates the specifications for the model in the conditional mean. |
Drange |
a two-element numeric vector that indicates the boundaries
of the interval over which to search for the fractional differencing
parameter |
nonparspec |
an object of class |
use_nonpar |
a logical indicating whether or not to implement a
semiparametric extension of the volatility model defined through |
n_test |
a single numerical value indicating, how many observations
at the end of |
start_pars |
the starting parameters for the numerical optimization
routine; should be of the same length as the parameter output vector
within the output object (also keeping the same order); for |
LB |
the lower boundaries of the parameters in the numerical optimization
routine; should be of the same length as the parameter output vector
within the output object (also keeping the same order); for |
UB |
the upper boundaries of the parameters in the numerical optimization
routine; should be of the same length as the parameter output vector
within the output object (also keeping the same order); for |
control |
a list that is passed to |
control_nonpar |
a list containing changes to the arguments
for the hyperparameter estimation algorithm in the nonparametric
scale function estimation for
|
mean_after_nonpar |
only for |
parallel |
only relevant for a (skewed) average Laplace (AL)
distribution, i.e.
if |
ncores |
only relevant for a (skewed) average Laplace (AL)
distribution, i.e.
if |
trunc |
a positive integer indicating the finite truncation length of the
infinite-order polynomials of the infinite-order representations of the
long-memory model parts; the character |
presample |
the presample length for initialization (for extended EGARCH- / Log-GARCH-type models only relevant for the FARIMA-part, as series in log-transformed conditional variance are initialized by zero). |
Prange |
a two-element vector that indicates the search boundaries for
the parameter |
fix_delta |
let the parameter |
skip_vcov |
a logical indicating whether or not to skip the computation of the variance-covariance matrix of the parameter estimators and therefore also standard error computation. |
Consider a FIAPARCH() with constant asymmetry term regardless
of the lag. Let , with as the
time index, be a theoretical time series that follows
Here, means that the innovations
are independent and identically distributed (iid) with mean zero
and variance one, whereas are the conditional standard
deviations in .
Moreover, is the backshift operator and
, where
, , are real-valued coefficients. Furthermore,
, where
, , are real-valued coefficients.
and are the model orders definable through the argument orders,
where is the first element and is the second element in the
argument. In addition, we have as a
real-valued parameter and and as the
parameter for the level of integration. With the model reduces
to a short-memory APARCH, for we have a full integration, and for
, we have fractional integration, where is
considered to describe a long-memory process. is the intercept. It is assumed that
all and are non-negative.
The pre-sample values of
are replaced by the in-sample arithmetic mean of
where
are considered as the observations and is the sample
mean of . Initial values
for and
as initial guesses for and are obtained
from a previous fitting of a short-memory APARCH.
Currently, only a model of orders with can be fitted;
to ensure the non-negativity of all of the infinite-order coefficient series
, which in combination
with ensures that all the conditional volatilities
are greater than zero, we employ inequality constraints ensuring that the first
50 coefficients of the infinite-order ARCH-representation are non-negative as an
approximation to ensuring that all of the coefficients are non-negative. To ensure
that they are non-negative, one may in theory consider the sufficient conditions
mentioned in Bollerslev and Mikkelsen (1996) or Tse (1998), which are however
sometimes restrictive, or the simultaneously necessary and sufficient conditions
by Conrad and Haag (2006), which are however complex to implement properly.
See also the reference section for sources on the APARCH (Ding et al., 1993) and the FIAPARCH (Tse, 1998) models.
The truncated infinite order polynomial is computed following the idea by Nielsen and Noel (2021) as is the series of conditional variances for most computational efficiency. To ensure stability of the first fitted in-sample conditional standard deviations, we however use a small, but also adjustable (also to length zero) presample, which may introduce biases into the parameter estimators.
In the current package version, standard errors of parameter estimates are
computed from the Hessian at the optimum of the log-likelihood using
hessian. To ensure numerical stability and
applicability to a huge variety of differently scaled data, parametric
models are first fitted to data that is scaled to have sample variance
1. Parameter estimates and other quantities are then either
retransformed or recalculated afterwards for the original data.
For a conditional average Laplace distribution, an optimal model for each
distribution parameter from 1 to 5 is estimated (assuming that
is then fixed to the corresponding value). Afterwards, is then
estimated by selecting the estimated model among the five fitted models that
has the largest log-likelihood. The five models are, by default, fitted
simultaneously using parallel programming techniques (see also the arguments
parallel and ncores, which are only relevant for a conditional
average Laplace distribution). After the optimal model (including
the estimate of called ) has been determined,
is seen as fixed to obtain the standard errors via the Hessian matrix for the
estimates of the continuous parameters. A standard error for is therefore
not obtained and the ones obtained for the remaining estimates do not account
for .
An ARMA-FIAPARCH or a FARIMA-FIAPARCH can be fitted by adjusting the
argument meanspec correspondingly.
As an alternative, a semiparametric extension of the pure models
in the conditional variance can be implemented. If use_nonpar = TRUE,
meanspec is omitted and before fitting a zero-mean model in the
conditional volatility following the remaining function arguments, a smooth scale function,
i.e. a function representing the unconditional standard deviation over time,
is being estimated following the specifications in nonparspec and
control_nonpar. This preliminary step stabilizes the input
series rt, as long-term changes in the unconditional variance
are being estimated and removed before the parametric step using
tsmoothlm. control_nonpar can be adjusted following
to make changes to the arguments of tsmoothlm
for long-memory specifications. These arguments specify settings
for the automated bandwidth selection algorithms implemented by this
function. By default, we use the settings
pmin = 0, pmax = 1, qmin = 0,
qmax = 1, InfR = "Nai",
bStart = 0.15, cb = 0.05, and
method = "lpr" for tsmoothlm.
locpol_spec passed to nonparspec handles
more direct settings of the local polynomial smoother itself. See
the documentation for these functions to get a detailed overview
of these settings. Assume to be the observed series, where
,
then , with being the arithmetic
mean over the observed , is computed and subsequently
. The subtraction of
is necessary so that are all different from zero
almost surely. Once are available, its trend ,
with as the rescaled time on the interval , is
being estimated using
tsmoothlm and denoted here by
. Then from
obtain ,
and obtain the estimated scale function as
.
The stabilized / standardized version of the series
is then , to which
a purely parametric volatility model following the remaining function arguments
is then
fitted. The estimated volatility at a given time point is then
the product of the estimate of the corresponding scale function value
and of the estimated conditional standard deviation (following the parametric
model part) for that same time point. See for example Feng et al. (2022)
or Letmathe et al. (2023) for more information on the semiparametric extension
of volatility models.
The order for manual settings of start_pars, LB and UB
is crucial. The correct order is: , ,
,,,
, , , , ,
shape parameter,
skewness parameter. Depending on the exact model specification,
parameters irrelevant for the specification at hand should be dropped
in start_pars, LB and UB.
An object of S4-class "fEGarch_fit_fiaparch"
is returned. It contains the following elements.
pars:a named numeric vector with the parameter estimates.
se:a named numeric vector with the obtained standard errors in accordance with the parameter estimates.
vcov_mat:the variance-covariance matrix of the parameter estimates with named columns and rows.
rt:the input object rt (or at least the training data, if n_test is greater than zero);
if rt was a "zoo" or "ts" object, the formatting is kept.
cmeans:the estimated conditional means; if rt was a "zoo" or "ts" object, the formatting is also applied to cmeans.
sigt:the estimated conditional standard deviations (or for use_nonpar = TRUE the estimated total
volatilities, i.e. scale function value times conditional standard deviation); if rt was a "zoo" or "ts" object, the formatting is also applied to sigt.
etat:the obtained residuals; if rt was a "zoo" or "ts" object, the formatting is also applied to etat.
orders:a two-element numeric vector stating the considered model orders.
cond_dist:a character value stating the conditional distribution considered in the model fitting.
long_memo:a logical value stating whether or not long memory was considered in the model fitting.
llhood:the log-likelihood value obtained at the optimal parameter combination.
inf_criteria:a named two-element numeric vector with the corresponding AIC (first element) and BIC (second element) of the fitted parametric model part; for purely parametric models, these criteria are valid for the entire model; for semiparametric models, they are only valid for the parametric step and are not valid for the entire model.
meanspec:the settings for the model in the conditional mean; is an object
of class "mean_spec" that is identical to the object passed to the input argument
meanspec.
test_obs:the observations at the end up the input rt reserved for
testing following n_test.
scale_fun:the estimated scale function values, if use_nonpar = TRUE, otherwise
NULL; formatting of rt is reused.
nonpar_model:the estimation object returned by tsmoothlm for
use_nonpar = TRUE.
trunc:the input argument trunc.
Bollerslev, T., & Mikkelsen, H. O. (1996). Modeling and pricing long memory in stock market volatility. Journal of Econometrics, 73(1): 151-184. DOI: 10.1016/0304-4076(95)01736-4.
Conrad, C., & Haag, B. R. (2006). Inequality constraints in the fractionally integrated GARCH model. Journal of Financial Econometrics, 4(3): 413-449. DOI: 10.1093/jjfinec/nbj015.
Ding, Z., Granger, C. W. J., & Engle, R. F. (1993). A long memory property of stock market returns and a new model. Journal of Empirical Finance, 1(1): 83-106. DOI: 10.1016/0927-5398(93)90006-D.
Feng, Y., Gries, T., Letmathe, S., & Schulz, D. (2022). The smoots Package in R for Semiparametric Modeling of Trend Stationary Time Series. The R Journal, 14(1), 182-195. URL: https://journal.r-project.org/articles/RJ-2022-017/.
Letmathe, S., Beran, J., & Feng, Y. (2023). An extended exponential SEMIFAR model with application in R. Communications in Statistics - Theory and Methods, 53(22), 7914–7926. DOI: 10.1080/03610926.2023.2276049.
Nielsen, M. O., & Noel, A. L. (2021). To infinity and beyond: Efficient computation of ARCH()
models. Journal of Time Series Analysis,
42(3), 338–354. DOI: 10.1111/jtsa.12570.
Tse, Y. K. (1998). The conditional heteroskedasticity of the yen-dollar exchange rate. Journal of Applied Econometrics, 13(1): 49-55. DOI: 10.1002/(SICI)1099-1255(199801/02)13:1<49::AID-JAE459>3.0.CO;2-O.
window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") model <- fiaparch(rt) modelwindow.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") model <- fiaparch(rt) model
A streamlined simulation function to simulate from fractionally integrated asymmetric power autoregressive conditional heteroskedasticity (FIAPARCH) models.
fiaparch_sim( pars = list(mu = 0, ar = numeric(0), ma = numeric(0), D = 0, omega = 4e-04, phi = 0.2, beta = 0.4, gamma = 0.1, delta = 2, d = 0.25, df = 10, shape = 2, P = 3, skew = 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), n = 1000, nstart = 5000, trunc = "none" )fiaparch_sim( pars = list(mu = 0, ar = numeric(0), ma = numeric(0), D = 0, omega = 4e-04, phi = 0.2, beta = 0.4, gamma = 0.1, delta = 2, d = 0.25, df = 10, shape = 2, P = 3, skew = 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), n = 1000, nstart = 5000, trunc = "none" )
pars |
a named list with the parameter specifications; the user can provide a named list with only the settings they would like to adjust relative to the default settings. |
cond_dist |
a one-element character vector specifying the conditional distribution to consider. |
n |
the number of observations to return. |
nstart |
the number of burn-in observations to simulate before
the final |
trunc |
a truncation for the finite-order coefficient series
in long-memory models; can either be the character |
See the documentation on fiaparch for information
on the FIAPARCH model. This function provides
an easy way to simulate from these models.
A list with four elements is returned: rt are the simulated
observations, etat are the underlying innovations,
sigt are the correspondingly simulated conditional
standard deviations, and cmeans are the simulated
conditional means. These four elements are formatted as
"ts" class time series objects.
sim <- fiaparch_sim(n = 1000) mat <- do.call(cbind, sim) plot(mat, main = "")sim <- fiaparch_sim(n = 1000) mat <- do.call(cbind, sim) plot(mat, main = "")
Fit a fractionally integrated GARCH (FIGARCH) model under the six most common and further conditional distributions to observed data using quasi maximum-likelihood estimation.
figarch( rt, orders = c(1, 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), drange = c(0, 1), meanspec = mean_spec(), Drange = c(0, 1), nonparspec = locpol_spec(), use_nonpar = FALSE, n_test = 0, start_pars = NULL, LB = NULL, UB = NULL, control = list(), control_nonpar = list(), mean_after_nonpar = FALSE, parallel = TRUE, ncores = max(1, future::availableCores() - 1), trunc = "none", presample = 50, Prange = c(1, 5), skip_vcov = FALSE )figarch( rt, orders = c(1, 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), drange = c(0, 1), meanspec = mean_spec(), Drange = c(0, 1), nonparspec = locpol_spec(), use_nonpar = FALSE, n_test = 0, start_pars = NULL, LB = NULL, UB = NULL, control = list(), control_nonpar = list(), mean_after_nonpar = FALSE, parallel = TRUE, ncores = max(1, future::availableCores() - 1), trunc = "none", presample = 50, Prange = c(1, 5), skip_vcov = FALSE )
rt |
the observed series ordered from past to present; can be
a numeric vector or a |
orders |
a two-element numeric vector containing the two model
orders |
cond_dist |
the conditional distribution to consider as a
character object; the default is a conditional normal distribution
|
drange |
a two-element numeric vector that gives the boundaries of the
search interval for the fractional differencing parameter |
meanspec |
an object of class "mean_spec"; indicates the specifications for the model in the conditional mean. |
Drange |
a two-element numeric vector that indicates the boundaries
of the interval over which to search for the fractional differencing
parameter |
nonparspec |
an object of class |
use_nonpar |
a logical indicating whether or not to implement a
semiparametric extension of the volatility model defined through |
n_test |
a single numerical value indicating, how many observations
at the end of |
start_pars |
the starting parameters for the numerical optimization
routine; should be of the same length as the parameter output vector
within the output object (also keeping the same order); for |
LB |
the lower boundaries of the parameters in the numerical optimization
routine; should be of the same length as the parameter output vector
within the output object (also keeping the same order); for |
UB |
the upper boundaries of the parameters in the numerical optimization
routine; should be of the same length as the parameter output vector
within the output object (also keeping the same order); for |
control |
a list that is passed to |
control_nonpar |
a list containing changes to the arguments
for the hyperparameter estimation algorithm in the nonparametric
scale function estimation for
|
mean_after_nonpar |
only for |
parallel |
only relevant for a (skewed) average Laplace (AL)
distribution, i.e.
if |
ncores |
only relevant for a (skewed) average Laplace (AL)
distribution, i.e.
if |
trunc |
a positive integer indicating the finite truncation length of the
infinite-order polynomials of the infinite-order representations of the
long-memory model parts; the character |
presample |
the presample length for initialization (for extended EGARCH- / Log-GARCH-type models only relevant for the FARIMA-part, as series in log-transformed conditional variance are initialized by zero). |
Prange |
a two-element vector that indicates the search boundaries for
the parameter |
skip_vcov |
a logical indicating whether or not to skip the computation of the variance-covariance matrix of the parameter estimators and therefore also standard error computation. |
Let , with as the
time index, be a theoretical time series that follows
Here, means that the innovations
are independent and identically distributed (iid) with mean zero
and variance one, whereas are the conditional standard
deviations in .
Moreover, is the backshift operator and
, where
, , are real-valued coefficients. Furthermore,
, where
, , are real-valued coefficients.
and are the model orders definable through the argument orders,
where is the first element and is the second element in the
argument. In addition, we have as a
real-valued parameter and as the
parameter for the level of integration. With the model reduces
to a short-memory GARCH, for we have a full integration, and for
, we have fractional integration, where is usually
considered to describe a long-memory process. is the intercept. It is assumed that
all and are non-negative. Furthermore, we have
as the intercept.
Currently, only a model of orders with can be fitted;
to ensure the non-negativity of all of the infinite-order coefficient series
, which in combination
with ensures that all the conditional volatilities
are greater than zero, we employ inequality constraints ensuring that the first
50 coefficients of the infinite-order ARCH-representation are non-negative as an
approximation to ensuring that all of the coefficients are non-negative. To ensure
that they are non-negative, one may in theory consider the sufficient conditions
mentioned in Bollerslev and Mikkelsen (1996) or Tse (1998), which are however
sometimes restrictive, or the simultaneously necessary and sufficient conditions
by Conrad and Haag (2006), which are however complex to implement properly.
The truncated infinite order polynomial is computed following the idea by Nielsen and Noel (2021) as is the series of conditional variances for most computational efficiency. To ensure stability of the first fitted in-sample conditional standard deviations, we however use a small, but also adjustable (also to length zero) presample, which may introduce biases into the parameter estimators.
In the current package version, standard errors of parameter estimates are
computed from the Hessian at the optimum of the log-likelihood using
hessian. To ensure numerical stability and
applicability to a huge variety of differently scaled data, parametric
models are first fitted to data that is scaled to have sample variance
1. Parameter estimates and other quantities are then either
retransformed or recalculated afterwards for the original data.
For a conditional average Laplace distribution, an optimal model for each
distribution parameter from 1 to 5 is estimated (assuming that
is then fixed to the corresponding value). Afterwards, is then
estimated by selecting the estimated model among the five fitted models that
has the largest log-likelihood. The five models are, by default, fitted
simultaneously using parallel programming techniques (see also the arguments
parallel and ncores, which are only relevant for a conditional
average Laplace distribution). After the optimal model (including
the estimate of called ) has been determined,
is seen as fixed to obtain the standard errors via the Hessian matrix for the
estimates of the continuous parameters. A standard error for is therefore
not obtained and the ones obtained for the remaining estimates do not account
for .
An ARMA-FIGARCH or a FARIMA-FIGARCH can be fitted by adjusting the
argument meanspec correspondingly.
As an alternative, a semiparametric extension of the pure models
in the conditional variance can be implemented. If use_nonpar = TRUE,
meanspec is omitted and before fitting a zero-mean model in the
conditional volatility following the remaining function arguments, a smooth scale function,
i.e. a function representing the unconditional standard deviation over time,
is being estimated following the specifications in nonparspec and
control_nonpar. This preliminary step stabilizes the input
series rt, as long-term changes in the unconditional variance
are being estimated and removed before the parametric step using
tsmoothlm. control_nonpar can be adjusted following
to make changes to the arguments of tsmoothlm
for long-memory specifications. These arguments specify settings
for the automated bandwidth selection algorithms implemented by this
function. By default, we use the settings
pmin = 0, pmax = 1, qmin = 0,
qmax = 1, InfR = "Nai",
bStart = 0.15, cb = 0.05, and
method = "lpr" for tsmoothlm.
locpol_spec passed to nonparspec handles
more direct settings of the local polynomial smoother itself. See
the documentation for these functions to get a detailed overview
of these settings. Assume to be the observed series, where
,
then , with being the arithmetic
mean over the observed , is computed and subsequently
. The subtraction of
is necessary so that are all different from zero
almost surely. Once are available, its trend ,
with as the rescaled time on the interval , is
being estimated using
tsmoothlm and denoted here by
. Then from
obtain ,
and obtain the estimated scale function as
.
The stabilized / standardized version of the series
is then , to which
a purely parametric volatility model following the remaining function arguments
is then
fitted. The estimated volatility at a given time point is then
the product of the estimate of the corresponding scale function value
and of the estimated conditional standard deviation (following the parametric
model part) for that same time point. See for example Feng et al. (2022)
or Letmathe et al. (2023) for more information on the semiparametric extension
of volatility models.
The order for manual settings of start_pars, LB and UB
is crucial. The correct order is: , ,
,,,
, , , shape parameter,
skewness parameter. Depending on the exact model specification,
parameters irrelevant for the specification at hand should be dropped
in start_pars, LB and UB.
An object of S4-class "fEGarch_fit_figarch"
is returned. It contains the following elements.
pars:a named numeric vector with the parameter estimates.
se:a named numeric vector with the obtained standard errors in accordance with the parameter estimates.
vcov_mat:the variance-covariance matrix of the parameter estimates with named columns and rows.
rt:the input object rt (or at least the training data, if n_test is greater than zero);
if rt was a "zoo" object, the formatting is kept.
cmeans:the estimated conditional means; if rt was a "zoo" or "ts" object, the formatting is also applied to cmeans.
sigt:the estimated conditional standard deviations (or for use_nonpar = TRUE the estimated total
volatilities, i.e. scale function value times conditional standard deviation); if rt was a "zoo" object, the formatting is also applied to sigt.
etat:the obtained residuals; if rt was a "zoo" object, the formatting is also applied to etat.
orders:a two-element numeric vector stating the considered model orders.
cond_dist:a character value stating the conditional distribution considered in the model fitting.
long_memo:a logical value stating whether or not long memory was considered in the model fitting.
llhood:the log-likelihood value obtained at the optimal parameter combination.
inf_criteria:a named two-element numeric vector with the corresponding AIC (first element) and BIC (second element) of the fitted parametric model part; for purely parametric models, these criteria are valid for the entire model; for semiparametric models, they are only valid for the parametric step and are not valid for the entire model.
meanspec:the settings for the model in the conditional mean; is an object
of class "mean_spec" that is identical to the object passed to the input argument
meanspec.
test_obs:the observations at the end up the input rt reserved for
testing following n_test.
scale_fun:the estimated scale function values, if use_nonpar = TRUE, otherwise
NULL; formatting of rt is reused.
nonpar_model:the estimation object returned by tsmoothlm for
use_nonpar = TRUE.
trunc:the input argument trunc.
Baillie, R., Bollerslev, T., & Mikkelsen, H. O. (1996). Fractionally integrated generalized autoregressive conditional heteroskedasticity. Journal of Econometrics, 74(1), 3-30. DOI: 10.1016/S0304-4076(95)01749-6.
Bollerslev, T., & Mikkelsen, H. O. (1996). Modeling and pricing long memory in stock market volatility. Journal of Econometrics, 73(1): 151-184. DOI: 10.1016/0304-4076(95)01736-4.
Conrad, C., & Haag, B. R. (2006). Inequality constraints in the fractionally integrated GARCH model. Journal of Financial Econometrics, 4(3): 413-449. DOI: 10.1093/jjfinec/nbj015.
Conrad, C., & Karanasos, M. (2006). The impulse response function of the long memory GARCH process. Economics Letters, 90(1): 34-41. DOI: 10.1016/j.econlet.2005.07.001.
Feng, Y., Gries, T., Letmathe, S., & Schulz, D. (2022). The smoots Package in R for Semiparametric Modeling of Trend Stationary Time Series. The R Journal, 14(1), 182-195. URL: https://journal.r-project.org/articles/RJ-2022-017/.
Karanasos, M., Psaradakis, Z., & Sola, M. (2004). On the autocorrelation properties of long-memory GARCH processes. Journal of Time Series Analysis, 25(2): 265-281. DOI: 10.1046/j.0143-9782.2003.00349.x.
Letmathe, S., Beran, J., & Feng, Y. (2023). An extended exponential SEMIFAR model with application in R. Communications in Statistics - Theory and Methods, 53(22), 7914–7926. DOI: 10.1080/03610926.2023.2276049.
Nielsen, M. O., & Noel, A. L. (2021). To infinity and beyond: Efficient computation of ARCH()
models. Journal of Time Series Analysis,
42(3), 338–354. DOI: 10.1111/jtsa.12570.
window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") model <- figarch(rt) modelwindow.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") model <- figarch(rt) model
A streamlined simulation function to simulate from fractionally integrated generalized autoregressive conditional heteroskedasticity (FIGARCH) models.
figarch_sim( pars = list(mu = 0, ar = numeric(0), ma = numeric(0), D = 0, omega = 4e-04, phi = 0.2, beta = 0.4, d = 0.25, df = 10, shape = 2, P = 3, skew = 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), n = 1000, nstart = 5000, trunc = "none" )figarch_sim( pars = list(mu = 0, ar = numeric(0), ma = numeric(0), D = 0, omega = 4e-04, phi = 0.2, beta = 0.4, d = 0.25, df = 10, shape = 2, P = 3, skew = 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), n = 1000, nstart = 5000, trunc = "none" )
pars |
a named list with the parameter specifications; the user can provide a named list with only the settings they would like to adjust relative to the default settings. |
cond_dist |
a one-element character vector specifying the conditional distribution to consider. |
n |
the number of observations to return. |
nstart |
the number of burn-in observations to simulate before
the final |
trunc |
a truncation for the finite-order coefficient series
in long-memory models; can either be the character |
See the documentation on figarch for information
on the FIGARCH model. This function provides
an easy way to simulate from these models.
A list with four elements is returned: rt are the simulated
observations, etat are the underlying innovations,
sigt are the correspondingly simulated conditional
standard deviations, and cmeans are the simulated
conditional means. These four elements are formatted as
"ts" class time series objects.
sim <- figarch_sim(n = 1000) mat <- do.call(cbind, sim) plot(mat, main = "")sim <- figarch_sim(n = 1000) mat <- do.call(cbind, sim) plot(mat, main = "")
Fit a fractionally integrated GJR-GARCH model under the six most common and further conditional distributions to observed data using quasi maximum-likelihood estimation.
figjrgarch( rt, orders = c(1, 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), drange = c(0, 1), meanspec = mean_spec(), Drange = c(0, 1), nonparspec = locpol_spec(), use_nonpar = FALSE, n_test = 0, start_pars = NULL, LB = NULL, UB = NULL, control = list(), control_nonpar = list(), mean_after_nonpar = FALSE, parallel = TRUE, ncores = max(1, future::availableCores() - 1), trunc = "none", presample = 50, Prange = c(1, 5), skip_vcov = FALSE )figjrgarch( rt, orders = c(1, 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), drange = c(0, 1), meanspec = mean_spec(), Drange = c(0, 1), nonparspec = locpol_spec(), use_nonpar = FALSE, n_test = 0, start_pars = NULL, LB = NULL, UB = NULL, control = list(), control_nonpar = list(), mean_after_nonpar = FALSE, parallel = TRUE, ncores = max(1, future::availableCores() - 1), trunc = "none", presample = 50, Prange = c(1, 5), skip_vcov = FALSE )
rt |
the observed series ordered from past to present; can be
a numeric vector, a |
orders |
a two-element numeric vector containing the two model
orders |
cond_dist |
the conditional distribution to consider as a
character object; the default is a conditional normal distribution
|
drange |
a two-element numeric vector that gives the boundaries of the
search interval for the fractional differencing parameter |
meanspec |
an object of class "mean_spec"; indicates the specifications for the model in the conditional mean. |
Drange |
a two-element numeric vector that indicates the boundaries
of the interval over which to search for the fractional differencing
parameter |
nonparspec |
an object of class |
use_nonpar |
a logical indicating whether or not to implement a
semiparametric extension of the volatility model defined through |
n_test |
a single numerical value indicating, how many observations
at the end of |
start_pars |
the starting parameters for the numerical optimization
routine; should be of the same length as the parameter output vector
within the output object (also keeping the same order); for |
LB |
the lower boundaries of the parameters in the numerical optimization
routine; should be of the same length as the parameter output vector
within the output object (also keeping the same order); for |
UB |
the upper boundaries of the parameters in the numerical optimization
routine; should be of the same length as the parameter output vector
within the output object (also keeping the same order); for |
control |
a list that is passed to |
control_nonpar |
a list containing changes to the arguments
for the hyperparameter estimation algorithm in the nonparametric
scale function estimation for
|
mean_after_nonpar |
only for |
parallel |
only relevant for a (skewed) average Laplace (AL)
distribution, i.e.
if |
ncores |
only relevant for a (skewed) average Laplace (AL)
distribution, i.e.
if |
trunc |
a positive integer indicating the finite truncation length of the
infinite-order polynomials of the infinite-order representations of the
long-memory model parts; the character |
presample |
the presample length for initialization (for extended EGARCH- / Log-GARCH-type models only relevant for the FARIMA-part, as series in log-transformed conditional variance are initialized by zero). |
Prange |
a two-element vector that indicates the search boundaries for
the parameter |
skip_vcov |
a logical indicating whether or not to skip the computation of the variance-covariance matrix of the parameter estimators and therefore also standard error computation. |
Consider a FIGJR-GARCH() (Ayensu et al., 2025) with constant asymmetry term regardless
of the lag. Let , with as the
time index, be a theoretical time series that follows
Here, means that the innovations
are independent and identically distributed (iid) with mean zero
and variance one, whereas are the conditional standard
deviations in .
Moreover, is the backshift operator and
, where
, , are real-valued coefficients. Furthermore,
, where
, , are real-valued coefficients.
and are the model orders definable through the argument orders,
where is the first element and is the second element in the
argument. In addition, we have as a
real-valued parameter, and as the
parameter for the level of integration. With the model reduces
to a short-memory GJR-GARCH, for we have a full integration, and for
, we have fractional integration, where is
considered to describe a long-memory process. is the intercept. It is assumed that
all and are non-negative.
The pre-sample values of
are replaced by the in-sample arithmetic mean of
where
are considered as the observations and is the sample
mean of . An initial value
for as initial guess for is obtained
from a previous fitting of a short-memory GJR-GARCH.
The truncated infinite order polynomial is computed following the idea by Nielsen and Noel (2021) as is the series of conditional variances for most computational efficiency. To ensure stability of the first fitted in-sample conditional standard deviations, we however use a small, but also adjustable (also to length zero) presample, which may introduce biases into the parameter estimators.
Currently, only a model of orders with can be fitted;
to ensure the non-negativity of all of the infinite-order coefficient series
, which in combination
with ensures that all the conditional volatilities
are greater than zero, we employ inequality constraints ensuring that the first
50 coefficients of the infinite-order ARCH-representation are non-negative as an
approximation to ensuring that all of the coefficients are non-negative. To ensure
that they are non-negative, one may in theory consider the sufficient conditions
mentioned in Bollerslev and Mikkelsen (1996) or Tse (1998), which are however
sometimes restrictive, or the simultaneously necessary and sufficient conditions
by Conrad and Haag (2006), which are however complex to implement properly.
See also the reference section for sources on the GJR-GARCH (Glosten et al., 1993), the more general APARCH (Ding et al., 1993) and the FIAPARCH (Tse, 1998) models.
In the current package version, standard errors of parameter estimates are
computed from the Hessian at the optimum of the log-likelihood using
hessian. To ensure numerical stability and
applicability to a huge variety of differently scaled data, parametric
models are first fitted to data that is scaled to have sample variance
1. Parameter estimates and other quantities are then either
retransformed or recalculated afterwards for the original data.
For a conditional average Laplace distribution, an optimal model for each
distribution parameter from 1 to 5 is estimated (assuming that
is then fixed to the corresponding value). Afterwards, is then
estimated by selecting the estimated model among the five fitted models that
has the largest log-likelihood. The five models are, by default, fitted
simultaneously using parallel programming techniques (see also the arguments
parallel and ncores, which are only relevant for a conditional
average Laplace distribution). After the optimal model (including
the estimate of called ) has been determined,
is seen as fixed to obtain the standard errors via the Hessian matrix for the
estimates of the continuous parameters. A standard error for is therefore
not obtained and the ones obtained for the remaining estimates do not account
for .
An ARMA-FIGJR-GARCH or a FARIMA-FIGJR-GARCH can be fitted by adjusting the
argument meanspec correspondingly.
As an alternative, a semiparametric extension of the pure models
in the conditional variance can be implemented. If use_nonpar = TRUE,
meanspec is omitted and before fitting a zero-mean model in the
conditional volatility following the remaining function arguments, a smooth scale function,
i.e. a function representing the unconditional standard deviation over time,
is being estimated following the specifications in nonparspec and
control_nonpar. This preliminary step stabilizes the input
series rt, as long-term changes in the unconditional variance
are being estimated and removed before the parametric step using
tsmoothlm. control_nonpar can be adjusted following
to make changes to the arguments of tsmoothlm
for long-memory specifications. These arguments specify settings
for the automated bandwidth selection algorithms implemented by this
function. By default, we use the settings
pmin = 0, pmax = 1, qmin = 0,
qmax = 1, InfR = "Nai",
bStart = 0.15, cb = 0.05, and
method = "lpr" for tsmoothlm.
locpol_spec passed to nonparspec handles
more direct settings of the local polynomial smoother itself. See
the documentation for these functions to get a detailed overview
of these settings. Assume to be the observed series, where
,
then , with being the arithmetic
mean over the observed , is computed and subsequently
. The subtraction of
is necessary so that are all different from zero
almost surely. Once are available, its trend ,
with as the rescaled time on the interval , is
being estimated using
tsmoothlm and denoted here by
. Then from
obtain ,
and obtain the estimated scale function as
.
The stabilized / standardized version of the series
is then , to which
a purely parametric volatility model following the remaining function arguments
is then
fitted. The estimated volatility at a given time point is then
the product of the estimate of the corresponding scale function value
and of the estimated conditional standard deviation (following the parametric
model part) for that same time point. See for example Feng et al. (2022)
or Letmathe et al. (2023) for more information on the semiparametric extension
of volatility models.
The order for manual settings of start_pars, LB and UB
is crucial. The correct order is: , ,
,,,
, , , ,
shape parameter,
skewness parameter. Depending on the exact model specification,
parameters irrelevant for the specification at hand should be dropped
in start_pars, LB and UB.
An object of S4-class "fEGarch_fit_figjrgarch"
is returned. It contains the following elements.
pars:a named numeric vector with the parameter estimates.
se:a named numeric vector with the obtained standard errors in accordance with the parameter estimates.
vcov_mat:the variance-covariance matrix of the parameter estimates with named columns and rows.
rt:the input object rt (or at least the training data, if n_test is greater than zero);
if rt was a "zoo" or "ts" object, the formatting is kept.
cmeans:the estimated conditional means; if rt was a "zoo" or "ts" object, the formatting is also applied to cmeans.
sigt:the estimated conditional standard deviations (or for use_nonpar = TRUE the estimated total
volatilities, i.e. scale function value times conditional standard deviation); if rt was a "zoo" or "ts" object, the formatting is also applied to sigt.
etat:the obtained residuals; if rt was a "zoo" or "ts" object, the formatting is also applied to etat.
orders:a two-element numeric vector stating the considered model orders.
cond_dist:a character value stating the conditional distribution considered in the model fitting.
long_memo:a logical value stating whether or not long memory was considered in the model fitting.
llhood:the log-likelihood value obtained at the optimal parameter combination.
inf_criteria:a named two-element numeric vector with the corresponding AIC (first element) and BIC (second element) of the fitted parametric model part; for purely parametric models, these criteria are valid for the entire model; for semiparametric models, they are only valid for the parametric step and are not valid for the entire model.
meanspec:the settings for the model in the conditional mean; is an object
of class "mean_spec" that is identical to the object passed to the input argument
meanspec.
test_obs:the observations at the end up the input rt reserved for
testing following n_test.
scale_fun:the estimated scale function values, if use_nonpar = TRUE, otherwise
NULL; formatting of rt is reused.
nonpar_model:the estimation object returned by tsmoothlm for
use_nonpar = TRUE.
trunc:the input argument trunc.
Ayensu, O. K., Feng, Y., & Schulz, D. (2025). Recent Extensions of Exponential GARCH Models: Theory and Application. Forthcoming preprint, Paderborn University.
Bollerslev, T., & Mikkelsen, H. O. (1996). Modeling and pricing long memory in stock market volatility. Journal of Econometrics, 73(1): 151-184. DOI: 10.1016/0304-4076(95)01736-4.
Conrad, C., & Haag, B. R. (2006). Inequality constraints in the fractionally integrated GARCH model. Journal of Financial Econometrics, 4(3): 413-449. DOI: 10.1093/jjfinec/nbj015.
Ding, Z., Granger, C. W. J., & Engle, R. F. (1993). A long memory property of stock market returns and a new model. Journal of Empirical Finance, 1(1): 83-106. DOI: 10.1016/0927-5398(93)90006-D.
Feng, Y., Gries, T., Letmathe, S., & Schulz, D. (2022). The smoots Package in R for Semiparametric Modeling of Trend Stationary Time Series. The R Journal, 14(1), 182-195. URL: https://journal.r-project.org/articles/RJ-2022-017/.
Glosten, L. R., Jagannathan, R., & Runkle, D. E. (1993). On The Relation between The Expected Value and The Volatility of Nominal Excess Return on stocks. Journal of Finance 48(5), 1779-1801. DOI: 10.1111/j.1540-6261.1993.tb05128.x.
Letmathe, S., Beran, J., & Feng, Y. (2023). An extended exponential SEMIFAR model with application in R. Communications in Statistics - Theory and Methods, 53(22), 7914–7926. DOI: 10.1080/03610926.2023.2276049.
Nielsen, M. O., & Noel, A. L. (2021). To infinity and beyond: Efficient
computation of ARCH() models. Journal of Time Series Analysis,
42(3), 338-354. DOI: 10.1111/jtsa.12570.
Tse, Y. K. (1998). The conditional heteroskedasticity of the yen-dollar exchange rate. Journal of Applied Econometrics, 13(1): 49-55. DOI: 10.1002/(SICI)1099-1255(199801/02)13:1<49::AID-JAE459>3.0.CO;2-O.
window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") model <- figjrgarch(rt) modelwindow.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") model <- figjrgarch(rt) model
A streamlined simulation function to simulate from FIGJR-GARCH models.
figjrgarch_sim( pars = list(mu = 0, ar = numeric(0), ma = numeric(0), D = 0, omega = 4e-04, phi = 0.2, beta = 0.4, gamma = 0.1, d = 0.25, df = 10, shape = 2, P = 3, skew = 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), n = 1000, nstart = 5000, trunc = "none" )figjrgarch_sim( pars = list(mu = 0, ar = numeric(0), ma = numeric(0), D = 0, omega = 4e-04, phi = 0.2, beta = 0.4, gamma = 0.1, d = 0.25, df = 10, shape = 2, P = 3, skew = 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), n = 1000, nstart = 5000, trunc = "none" )
pars |
a named list with the parameter specifications; the user can provide a named list with only the settings they would like to adjust relative to the default settings. |
cond_dist |
a one-element character vector specifying the conditional distribution to consider. |
n |
the number of observations to return. |
nstart |
the number of burn-in observations to simulate before
the final |
trunc |
a truncation for the finite-order coefficient series
in long-memory models; can either be the character |
See the documentation on figjrgarch for information
on the FIGJR-GARCH model. This function provides
an easy way to simulate from these models.
A list with four elements is returned: rt are the simulated
observations, etat are the underlying innovations,
sigt are the correspondingly simulated conditional
standard deviations, and cmeans are the simulated
conditional means. These four elements are formatted as
"ts" class time series objects.
sim <- figjrgarch_sim(n = 1000) mat <- do.call(cbind, sim) plot(mat, main = "")sim <- figjrgarch_sim(n = 1000) mat <- do.call(cbind, sim) plot(mat, main = "")
Given a series supposed to be from independent and identically distributed (iid) random variables, fit all eight distributions of this package to the data using maximum-likelihood estimation (MLE) and select the best one following either the BIC (the default) or the AIC.
find_dist( x, dists = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), fix_mean = NULL, fix_sdev = NULL, Prange = c(1, 5), criterion = c("bic", "aic"), skip_vcov = FALSE )find_dist( x, dists = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), fix_mean = NULL, fix_sdev = NULL, Prange = c(1, 5), criterion = c("bic", "aic"), skip_vcov = FALSE )
x |
the vector of iid values to fit distributions to. |
dists |
a vector with all the distribution abbreviations which should be considered in the selection process; by default, all eight distributions of this package are considered. |
fix_mean |
a value to fix the unconditional mean of the distribution to;
with the default |
fix_sdev |
a value to fix the unconditional standard deviation of the distribution to;
with the default |
Prange |
a two-element vector giving the search range for the shape parameter
|
criterion |
either |
skip_vcov |
a logical indicating whether or not the computation of the variance-covariance matrix should be skipped. |
For information on the method and distributions, we refer the reader to
distr_est.
Returns an object of class "fEGarch_distr_est" with various slots
representing the estimation results of the selected fitted distribution.
x <- rnorm(2000) * 2.1 + 10.5 find_dist(x)x <- rnorm(2000) * 2.1 + 10.5 find_dist(x)
Apply a collection of fit-tests, including a weighted Ljung-Box test for the simple and the squared standardized residuals, a sign-bias test, and an adjusted Pearson goodness-of-fit test.
## S4 method for signature 'fEGarch_fit' fit_test_suite( object, args_lbt = list(), args_sbt = list(), args_goft = list(), silent = FALSE, ... )## S4 method for signature 'fEGarch_fit' fit_test_suite( object, args_lbt = list(), args_sbt = list(), args_goft = list(), silent = FALSE, ... )
object |
an object of class |
args_lbt |
a list of changes to make to the default argument settings in
|
args_sbt |
a list of changes to make to the default argument settings in
|
args_goft |
a list of changes to make to the default argument settings in
|
silent |
a logical indicating whether or not to print the test results in a well-formatted manner to the console. |
... |
currently without purpose. |
Returns a list with the four test results invisibly.
window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") spec <- fEGarch_spec() model <- fEGarch(spec, rt) fit_test_suite(model)window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") spec <- fEGarch_spec() model <- fEGarch(spec, rt) fit_test_suite(model)
Fit a fractionally integrated TGARCH model under the six most common and further conditional distributions to observed data using quasi maximum-likelihood estimation.
fitgarch( rt, orders = c(1, 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), drange = c(0, 1), meanspec = mean_spec(), Drange = c(0, 1), nonparspec = locpol_spec(), use_nonpar = FALSE, n_test = 0, start_pars = NULL, LB = NULL, UB = NULL, control = list(), control_nonpar = list(), mean_after_nonpar = FALSE, parallel = TRUE, ncores = max(1, future::availableCores() - 1), trunc = "none", presample = 50, Prange = c(1, 5), skip_vcov = FALSE )fitgarch( rt, orders = c(1, 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), drange = c(0, 1), meanspec = mean_spec(), Drange = c(0, 1), nonparspec = locpol_spec(), use_nonpar = FALSE, n_test = 0, start_pars = NULL, LB = NULL, UB = NULL, control = list(), control_nonpar = list(), mean_after_nonpar = FALSE, parallel = TRUE, ncores = max(1, future::availableCores() - 1), trunc = "none", presample = 50, Prange = c(1, 5), skip_vcov = FALSE )
rt |
the observed series ordered from past to present; can be
a numeric vector, a |
orders |
a two-element numeric vector containing the two model
orders |
cond_dist |
the conditional distribution to consider as a
character object; the default is a conditional normal distribution
|
drange |
a two-element numeric vector that gives the boundaries of the
search interval for the fractional differencing parameter |
meanspec |
an object of class "mean_spec"; indicates the specifications for the model in the conditional mean. |
Drange |
a two-element numeric vector that indicates the boundaries
of the interval over which to search for the fractional differencing
parameter |
nonparspec |
an object of class |
use_nonpar |
a logical indicating whether or not to implement a
semiparametric extension of the volatility model defined through |
n_test |
a single numerical value indicating, how many observations
at the end of |
start_pars |
the starting parameters for the numerical optimization
routine; should be of the same length as the parameter output vector
within the output object (also keeping the same order); for |
LB |
the lower boundaries of the parameters in the numerical optimization
routine; should be of the same length as the parameter output vector
within the output object (also keeping the same order); for |
UB |
the upper boundaries of the parameters in the numerical optimization
routine; should be of the same length as the parameter output vector
within the output object (also keeping the same order); for |
control |
a list that is passed to |
control_nonpar |
a list containing changes to the arguments
for the hyperparameter estimation algorithm in the nonparametric
scale function estimation for
|
mean_after_nonpar |
only for |
parallel |
only relevant for a (skewed) average Laplace (AL)
distribution, i.e.
if |
ncores |
only relevant for a (skewed) average Laplace (AL)
distribution, i.e.
if |
trunc |
a positive integer indicating the finite truncation length of the
infinite-order polynomials of the infinite-order representations of the
long-memory model parts; the character |
presample |
the presample length for initialization (for extended EGARCH- / Log-GARCH-type models only relevant for the FARIMA-part, as series in log-transformed conditional variance are initialized by zero). |
Prange |
a two-element vector that indicates the search boundaries for
the parameter |
skip_vcov |
a logical indicating whether or not to skip the computation of the variance-covariance matrix of the parameter estimators and therefore also standard error computation. |
Consider a FITGARCH() (Ayensu et al., 2025) with constant asymmetry term regardless
of the lag. Let , with as the
time index, be a theoretical time series that follows
Here, means that the innovations
are independent and identically distributed (iid) with mean zero
and variance one, whereas are the conditional standard
deviations in .
Moreover, is the backshift operator and
, where
, , are real-valued coefficients. Furthermore,
, where
, , are real-valued coefficients.
and are the model orders definable through the argument orders,
where is the first element and is the second element in the
argument. In addition, we have as a
real-valued parameter, and as the
parameter for the level of integration. With the model reduces
to a short-memory TGARCH, for we have a full integration, and for
, we have fractional integration, where is
considered to describe a long-memory process. is the intercept. It is assumed that
all and are non-negative.
The pre-sample values of
are replaced by the in-sample arithmetic mean of
where
are considered as the observations and is the sample
mean of . An initial value
for as initial guess for is obtained
from a previous fitting of a short-memory TGARCH.
The truncated infinite order polynomial is computed following the idea by Nielsen and Noel (2021) as is the series of conditional variances for most computational efficiency. To ensure stability of the first fitted in-sample conditional standard deviations, we however use a small, but also adjustable (also to length zero) presample, which may introduce biases into the parameter estimators.
Currently, only a model of orders with can be fitted;
to ensure the non-negativity of all of the infinite-order coefficient series
, which in combination
with ensures that all the conditional volatilities
are greater than zero, we employ inequality constraints ensuring that the first
50 coefficients of the infinite-order ARCH-representation are non-negative as an
approximation to ensuring that all of the coefficients are non-negative. To ensure
that they are non-negative, one may in theory consider the sufficient conditions
mentioned in Bollerslev and Mikkelsen (1996) or Tse (1998), which are however
sometimes restrictive, or the simultaneously necessary and sufficient conditions
by Conrad and Haag (2006), which are however complex to implement properly.
See also the reference section for sources on the TGARCH model (Zakoian, 1994), the more general APARCH (Ding et al., 1993) and the FIAPARCH (Tse, 1998) models.
In the current package version, standard errors of parameter estimates are
computed from the Hessian at the optimum of the log-likelihood using
hessian. To ensure numerical stability and
applicability to a huge variety of differently scaled data, parametric
models are first fitted to data that is scaled to have sample variance
1. Parameter estimates and other quantities are then either
retransformed or recalculated afterwards for the original data.
For a conditional average Laplace distribution, an optimal model for each
distribution parameter from 1 to 5 is estimated (assuming that
is then fixed to the corresponding value). Afterwards, is then
estimated by selecting the estimated model among the five fitted models that
has the largest log-likelihood. The five models are, by default, fitted
simultaneously using parallel programming techniques (see also the arguments
parallel and ncores, which are only relevant for a conditional
average Laplace distribution). After the optimal model (including
the estimate of called ) has been determined,
is seen as fixed to obtain the standard errors via the Hessian matrix for the
estimates of the continuous parameters. A standard error for is therefore
not obtained and the ones obtained for the remaining estimates do not account
for .
An ARMA-FITGARCH or a FARIMA-FITGARCH can be fitted by adjusting the
argument meanspec correspondingly.
As an alternative, a semiparametric extension of the pure models
in the conditional variance can be implemented. If use_nonpar = TRUE,
meanspec is omitted and before fitting a zero-mean model in the
conditional volatility following the remaining function arguments, a smooth scale function,
i.e. a function representing the unconditional standard deviation over time,
is being estimated following the specifications in nonparspec and
control_nonpar. This preliminary step stabilizes the input
series rt, as long-term changes in the unconditional variance
are being estimated and removed before the parametric step using
tsmoothlm. control_nonpar can be adjusted following
to make changes to the arguments of tsmoothlm
for long-memory specifications. These arguments specify settings
for the automated bandwidth selection algorithms implemented by this
function. By default, we use the settings
pmin = 0, pmax = 1, qmin = 0,
qmax = 1, InfR = "Nai",
bStart = 0.15, cb = 0.05, and
method = "lpr" for tsmoothlm.
locpol_spec passed to nonparspec handles
more direct settings of the local polynomial smoother itself. See
the documentation for these functions to get a detailed overview
of these settings. Assume to be the observed series, where
,
then , with being the arithmetic
mean over the observed , is computed and subsequently
. The subtraction of
is necessary so that are all different from zero
almost surely. Once are available, its trend ,
with as the rescaled time on the interval , is
being estimated using
tsmoothlm and denoted here by
. Then from
obtain ,
and obtain the estimated scale function as
.
The stabilized / standardized version of the series
is then , to which
a purely parametric volatility model following the remaining function arguments
is then
fitted. The estimated volatility at a given time point is then
the product of the estimate of the corresponding scale function value
and of the estimated conditional standard deviation (following the parametric
model part) for that same time point. See for example Feng et al. (2022)
or Letmathe et al. (2023) for more information on the semiparametric extension
of volatility models.
The order for manual settings of start_pars, LB and UB
is crucial. The correct order is: , ,
,,,
, , , ,
shape parameter,
skewness parameter. Depending on the exact model specification,
parameters irrelevant for the specification at hand should be dropped
in start_pars, LB and UB.
An object of S4-class "fEGarch_fit_fitgarch"
is returned. It contains the following elements.
pars:a named numeric vector with the parameter estimates.
se:a named numeric vector with the obtained standard errors in accordance with the parameter estimates.
vcov_mat:the variance-covariance matrix of the parameter estimates with named columns and rows.
rt:the input object rt (or at least the training data, if n_test is greater than zero);
if rt was a "zoo" or "ts" object, the formatting is kept.
cmeans:the estimated conditional means; if rt was a "zoo" or "ts" object, the formatting is also applied to cmeans.
sigt:the estimated conditional standard deviations (or for use_nonpar = TRUE the estimated total
volatilities, i.e. scale function value times conditional standard deviation); if rt was a "zoo" or "ts" object, the formatting is also applied to sigt.
etat:the obtained residuals; if rt was a "zoo" or "ts" object, the formatting is also applied to etat.
orders:a two-element numeric vector stating the considered model orders.
cond_dist:a character value stating the conditional distribution considered in the model fitting.
long_memo:a logical value stating whether or not long memory was considered in the model fitting.
llhood:the log-likelihood value obtained at the optimal parameter combination.
inf_criteria:a named two-element numeric vector with the corresponding AIC (first element) and BIC (second element) of the fitted parametric model part; for purely parametric models, these criteria are valid for the entire model; for semiparametric models, they are only valid for the parametric step and are not valid for the entire model.
meanspec:the settings for the model in the conditional mean; is an object
of class "mean_spec" that is identical to the object passed to the input argument
meanspec.
test_obs:the observations at the end up the input rt reserved for
testing following n_test.
scale_fun:the estimated scale function values, if use_nonpar = TRUE, otherwise
NULL; formatting of rt is reused.
nonpar_model:the estimation object returned by tsmoothlm for
use_nonpar = TRUE.
trunc:the input argument trunc.
Ayensu, O. K., Feng, Y., & Schulz, D. (2025). Recent Extensions of Exponential GARCH Models: Theory and Application. Forthcoming preprint, Paderborn University.
Bollerslev, T., & Mikkelsen, H. O. (1996). Modeling and pricing long memory in stock market volatility. Journal of Econometrics, 73(1): 151-184. DOI: 10.1016/0304-4076(95)01736-4.
Conrad, C., & Haag, B. R. (2006). Inequality constraints in the fractionally integrated GARCH model. Journal of Financial Econometrics, 4(3): 413-449. DOI: 10.1093/jjfinec/nbj015.
Ding, Z., Granger, C. W. J., & Engle, R. F. (1993). A long memory property of stock market returns and a new model. Journal of Empirical Finance, 1(1): 83-106. DOI: 10.1016/0927-5398(93)90006-D.
Feng, Y., Gries, T., Letmathe, S., & Schulz, D. (2022). The smoots Package in R for Semiparametric Modeling of Trend Stationary Time Series. The R Journal, 14(1), 182-195. URL: https://journal.r-project.org/articles/RJ-2022-017/.
Letmathe, S., Beran, J., & Feng, Y. (2023). An extended exponential SEMIFAR model with application in R. Communications in Statistics - Theory and Methods, 53(22), 7914–7926. DOI: 10.1080/03610926.2023.2276049.
Nielsen, M. O., & Noel, A. L. (2021). To infinity and beyond: Efficient
computation of ARCH() models. Journal of Time Series Analysis,
42(3), 338-354. DOI: 10.1111/jtsa.12570.
Tse, Y. K. (1998). The conditional heteroskedasticity of the yen-dollar exchange rate. Journal of Applied Econometrics, 13(1): 49-55. DOI: 10.1002/(SICI)1099-1255(199801/02)13:1<49::AID-JAE459>3.0.CO;2-O.
Zakoian, J.-M. (1994). Threshold heteroskedastic models. Journal of Economic Dynamics and Control, 18(5): 931-955. DOI: 10.1016/0165-1889(94)90039-6.
window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") model <- fitgarch(rt) modelwindow.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") model <- fitgarch(rt) model
A streamlined simulation function to simulate from FITGARCH models.
fitgarch_sim( pars = list(mu = 0, ar = numeric(0), ma = numeric(0), D = 0, omega = 4e-04, phi = 0.2, beta = 0.4, gamma = 0.1, d = 0.25, df = 10, shape = 2, P = 3, skew = 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), n = 1000, nstart = 5000, trunc = "none" )fitgarch_sim( pars = list(mu = 0, ar = numeric(0), ma = numeric(0), D = 0, omega = 4e-04, phi = 0.2, beta = 0.4, gamma = 0.1, d = 0.25, df = 10, shape = 2, P = 3, skew = 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), n = 1000, nstart = 5000, trunc = "none" )
pars |
a named list with the parameter specifications; the user can provide a named list with only the settings they would like to adjust relative to the default settings. |
cond_dist |
a one-element character vector specifying the conditional distribution to consider. |
n |
the number of observations to return. |
nstart |
the number of burn-in observations to simulate before
the final |
trunc |
a truncation for the finite-order coefficient series
in long-memory models; can either be the character |
See the documentation on fitgarch for information
on the FITGARCH model. This function provides
an easy way to simulate from these models.
A list with four elements is returned: rt are the simulated
observations, etat are the underlying innovations,
sigt are the correspondingly simulated conditional
standard deviations, and cmeans are the simulated
conditional means. These four elements are formatted as
"ts" class time series objects.
sim <- fitgarch_sim(n = 1000) mat <- do.call(cbind, sim) plot(mat, main = "")sim <- fitgarch_sim(n = 1000) mat <- do.call(cbind, sim) plot(mat, main = "")
Accessors for the output returned by the main fitting functions of
the fEGarch package. The generics themselves are without use.
sigt(x) cmeans(x) etat(x) llhood(x) inf_criteria(x) pars(x) se(x) vcov_mat(x)sigt(x) cmeans(x) etat(x) llhood(x) inf_criteria(x) pars(x) se(x) vcov_mat(x)
x |
an object returned by either |
These generics are without direct use. Consider the specific methods based on them.
These generics do not return anything. Inspect the methods based on them for practical purpose.
An alternative to cmeans,fEGarch_fit-method to extract
fitted conditional means from an estimation object
in this package.
## S4 method for signature 'fEGarch_fit' fitted(object) ## S4 method for signature 'fEGarch_forecast' fitted(object)## S4 method for signature 'fEGarch_fit' fitted(object) ## S4 method for signature 'fEGarch_forecast' fitted(object)
object |
an object either of class |
Extract fitted conditional means from an estimation object in this package.
The element within the input object with name cmeans is returned.
Depending on the element that can be a numeric vector, an object of
class "zoo" or a numeric matrix.
window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") model <- fEGarch(egarch_spec(), rt, n_test = 250) fitted(model)window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") model <- fEGarch(egarch_spec(), rt, n_test = 250) fitted(model)
Fit a standard GARCH model under the six most common conditional distributions (and more) to observed data using quasi maximum-likelihood estimation.
garch( rt, orders = c(1, 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), meanspec = mean_spec(), Drange = c(0, 1), nonparspec = locpol_spec(), use_nonpar = FALSE, n_test = 0, start_pars = NULL, LB = NULL, UB = NULL, control = list(), control_nonpar = list(), mean_after_nonpar = FALSE, parallel = TRUE, ncores = max(1, future::availableCores() - 1), trunc = "none", presample = 50, Prange = c(1, 5), skip_vcov = FALSE )garch( rt, orders = c(1, 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), meanspec = mean_spec(), Drange = c(0, 1), nonparspec = locpol_spec(), use_nonpar = FALSE, n_test = 0, start_pars = NULL, LB = NULL, UB = NULL, control = list(), control_nonpar = list(), mean_after_nonpar = FALSE, parallel = TRUE, ncores = max(1, future::availableCores() - 1), trunc = "none", presample = 50, Prange = c(1, 5), skip_vcov = FALSE )
rt |
the observed series ordered from past to present; can be
a numeric vector, a |
orders |
a two-element numeric vector containing the two model
orders |
cond_dist |
the conditional distribution to consider as a
character object; the default is a conditional normal distribution
|
meanspec |
an object of class "mean_spec"; indicates the specifications for the model in the conditional mean. |
Drange |
a two-element numeric vector that indicates the boundaries
of the interval over which to search for the fractional differencing
parameter |
nonparspec |
an object of class |
use_nonpar |
a logical indicating whether or not to implement a
semiparametric extension of the volatility model defined through |
n_test |
a single numerical value indicating, how many observations
at the end of |
start_pars |
the starting parameters for the numerical optimization
routine; should be of the same length as the parameter output vector
within the output object (also keeping the same order); for |
LB |
the lower boundaries of the parameters in the numerical optimization
routine; should be of the same length as the parameter output vector
within the output object (also keeping the same order); for |
UB |
the upper boundaries of the parameters in the numerical optimization
routine; should be of the same length as the parameter output vector
within the output object (also keeping the same order); for |
control |
a list that is passed to |
control_nonpar |
a list containing changes to the arguments
for the hyperparameter estimation algorithm in the nonparametric
scale function estimation for
|
mean_after_nonpar |
only for |
parallel |
only relevant for a (skewed) average Laplace (AL)
distribution, i.e.
if |
ncores |
only relevant for a (skewed) average Laplace (AL)
distribution, i.e.
if |
trunc |
a positive integer indicating the finite truncation length of the
infinite-order polynomials of the infinite-order representations of the
long-memory model parts; the character |
presample |
the presample length for initialization (for extended EGARCH- / Log-GARCH-type models only relevant for the FARIMA-part, as series in log-transformed conditional variance are initialized by zero). |
Prange |
a two-element vector that indicates the search boundaries for
the parameter |
skip_vcov |
a logical indicating whether or not to skip the computation of the variance-covariance matrix of the parameter estimators and therefore also standard error computation. |
Let , with as the
time index, be a theoretical time series that follows
Here, means that the innovations
are independent and identically distributed (iid) with mean zero
and variance one, whereas are the conditional standard
deviations in .
, , and , ,
are non-negative coefficients.
and are the model orders definable through the argument orders,
where is the first element and is the second element in the
argument. In addition, we have as a
real-valued parameter. is the intercept. This overall
definition is in accordance with Bollerslev (1986).
In the current package version, standard errors of parameter estimates are
computed from the Hessian at the optimum of the log-likelihood using
hessian. To ensure numerical stability and
applicability to a huge variety of differently scaled data, parametric
models are first fitted to data that is scaled to have sample variance
1. Parameter estimates and other quantities are then either
retransformed or recalculated afterwards for the original data.
For a conditional average Laplace distribution, an optimal model for each
distribution parameter from 1 to 5 is estimated (assuming that
is then fixed to the corresponding value). Afterwards, is then
estimated by selecting the estimated model among the five fitted models that
has the largest log-likelihood. The five models are, by default, fitted
simultaneously using parallel programming techniques (see also the arguments
parallel and ncores, which are only relevant for a conditional
average Laplace distribution). After the optimal model (including
the estimate of called ) has been determined,
is seen as fixed to obtain the standard errors via the Hessian matrix for the
estimates of the continuous parameters. A standard error for is therefore
not obtained and the ones obtained for the remaining estimates do not account
for .
An ARMA-GARCH or a FARIMA-GARCH can be fitted by adjusting the
argument meanspec correspondingly.
As an alternative, a semiparametric extension of the pure models
in the conditional variance can be implemented. If use_nonpar = TRUE,
meanspec is omitted and before fitting a model in the
conditional volatility following the remaining function arguments, a smooth scale function,
i.e. a function representing the unconditional standard deviation over time,
is being estimated following the specifications in nonparspec and
control_nonpar. This preliminary step stabilizes the input
series rt, as long-term changes in the unconditional variance
are being estimated and removed before the parametric step using
tsmooth. control_nonpar can be adjusted following
to make changes to the arguments of tsmooth
for short-memory specifications. These arguments specify settings
for the automated bandwidth selection algorithms implemented by this
function. By default, we use the settings
InfR = "Nai",
bStart = 0.15, cb = 0.05, and
method = "lpr" for tsmooth.
locpol_spec passed to nonparspec handles
more direct settings of the local polynomial smoother itself. See
the documentation for these functions to get a detailed overview
of these settings. Assume to be the observed series, where
,
then , with being the arithmetic
mean over the observed , is computed and subsequently
. The subtraction of
is necessary so that are all different from zero
almost surely. Once are available, its trend ,
with as the rescaled time on the interval , is
being estimated using
tsmooth and denoted here by
. Then from
obtain ,
and obtain the estimated scale function as
.
The stabilized / standardized version of the series
is then , to which
a purely parametric volatility model following the remaining function arguments
is then
fitted. The estimated volatility at a given time point is then
the product of the estimate of the corresponding scale function value
and of the estimated conditional standard deviation (following the parametric
model part) for that same time point. See for example Feng et al. (2022)
or Letmathe et al. (2023) for more information on the semiparametric extension
of volatility models.
The order for manual settings of start_pars, LB and UB
is crucial. The correct order is: , ,
,,,
, ,
shape parameter,
skewness parameter. Depending on the exact model specification,
parameters irrelevant for the specification at hand should be dropped
in start_pars, LB and UB.
An object of S4-class "fEGarch_fit_garch"
is returned. It contains the following elements.
pars:a named numeric vector with the parameter estimates.
se:a named numeric vector with the obtained standard errors in accordance with the parameter estimates.
vcov_mat:the variance-covariance matrix of the parameter estimates with named columns and rows.
rt:the input object rt (or at least the training data, if n_test is greater than zero);
if rt was a "zoo" or "ts" object, the formatting is kept.
cmeans:the estimated conditional means; if rt was a "zoo" or "ts" object, the formatting is also applied to cmeans.
sigt:the estimated conditional standard deviations (or for use_nonpar = TRUE the estimated total
volatilities, i.e. scale function value times conditional standard deviation); if rt was a "zoo" or "ts" object, the formatting is also applied to sigt.
etat:the obtained residuals; if rt was a "zoo" or "ts" object, the formatting is also applied to etat.
orders:a two-element numeric vector stating the considered model orders.
cond_dist:a character value stating the conditional distribution considered in the model fitting.
long_memo:a logical value stating whether or not long memory was considered in the model fitting.
llhood:the log-likelihood value obtained at the optimal parameter combination.
inf_criteria:a named two-element numeric vector with the corresponding AIC (first element) and BIC (second element) of the fitted parametric model part; for purely parametric models, these criteria are valid for the entire model; for semiparametric models, they are only valid for the parametric step and are not valid for the entire model.
meanspec:the settings for the model in the conditional mean; is an object
of class "mean_spec" that is identical to the object passed to the input argument
meanspec.
test_obs:the observations at the end up the input rt reserved for
testing following n_test.
scale_fun:the estimated scale function values, if use_nonpar = TRUE, otherwise
NULL; formatting of rt is reused.
nonpar_model:the estimation object returned by tsmooth for
use_nonpar = TRUE.
trunc:the input argument trunc.
Bollerslev, T. (1986). Generalized autoregressive conditional heteroskedasticity. Journal of Econometrics, 31(3): 307-327. DOI: 10.1016/0304-4076(86)90063-1.
Feng, Y., Gries, T., Letmathe, S., & Schulz, D. (2022). The smoots Package in R for Semiparametric Modeling of Trend Stationary Time Series. The R Journal, 14(1), 182-195. URL: https://journal.r-project.org/articles/RJ-2022-017/.
Letmathe, S., Beran, J., & Feng, Y. (2023). An extended exponential SEMIFAR model with application in R. Communications in Statistics - Theory and Methods, 53(22), 7914–7926. DOI: 10.1080/03610926.2023.2276049.
window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") model <- garch(rt) modelwindow.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") model <- garch(rt) model
A streamlined simulation function to simulate from generalized autoregressive conditional heteroskedasticity (GARCH) models.
garch_sim( pars = list(mu = 0, ar = numeric(0), ma = numeric(0), D = 0, omega = 4e-04, phi = 0.05, beta = 0.8, df = 10, shape = 2, P = 3, skew = 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), n = 1000, nstart = 5000, trunc = "none" )garch_sim( pars = list(mu = 0, ar = numeric(0), ma = numeric(0), D = 0, omega = 4e-04, phi = 0.05, beta = 0.8, df = 10, shape = 2, P = 3, skew = 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), n = 1000, nstart = 5000, trunc = "none" )
pars |
a named list with the parameter specifications; the user can provide a named list with only the settings they would like to adjust relative to the default settings. |
cond_dist |
a one-element character vector specifying the conditional distribution to consider. |
n |
the number of observations to return. |
nstart |
the number of burn-in observations to simulate before
the final |
trunc |
a truncation for the finite-order coefficient series
in long-memory models; can either be the character |
See the documentation on garch for information
on the GARCH model. This function provides
an easy way to simulate from these models.
A list with four elements is returned: rt are the simulated
observations, etat are the underlying innovations,
sigt are the correspondingly simulated conditional
standard deviations, and cmeans are the simulated
conditional means. These four elements are formatted as
"ts" class time series objects.
sim <- garch_sim(n = 1000) mat <- do.call(cbind, sim) plot(mat, main = "")sim <- garch_sim(n = 1000) mat <- do.call(cbind, sim) plot(mat, main = "")
Fit any of the additional short- or long-memory GARCH-type
models from the fEGarch package aside from those
of the extended EGARCH family.
garchm_estim( rt, model = c("garch", "gjrgarch", "tgarch", "aparch", "figarch", "figjrgarch", "fitgarch", "fiaparch"), orders = c(1, 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), drange = c(0, 1), meanspec = mean_spec(), Drange = c(0, 1), nonparspec = locpol_spec(), use_nonpar = FALSE, n_test = 0, start_pars = NULL, LB = NULL, UB = NULL, control = list(), control_nonpar = list(), mean_after_nonpar = FALSE, parallel = TRUE, ncores = max(1, future::availableCores() - 1), trunc = "none", presample = 50, Prange = c(1, 5), skip_vcov = FALSE )garchm_estim( rt, model = c("garch", "gjrgarch", "tgarch", "aparch", "figarch", "figjrgarch", "fitgarch", "fiaparch"), orders = c(1, 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), drange = c(0, 1), meanspec = mean_spec(), Drange = c(0, 1), nonparspec = locpol_spec(), use_nonpar = FALSE, n_test = 0, start_pars = NULL, LB = NULL, UB = NULL, control = list(), control_nonpar = list(), mean_after_nonpar = FALSE, parallel = TRUE, ncores = max(1, future::availableCores() - 1), trunc = "none", presample = 50, Prange = c(1, 5), skip_vcov = FALSE )
rt |
the observed series ordered from past to present; can be
a numeric vector, a |
model |
any character object among |
orders |
a two-element numeric vector containing the two model
orders |
cond_dist |
the conditional distribution to consider as a
character object; the default is a conditional normal distribution
|
drange |
a two-element numeric vector that gives the boundaries of the
search interval for the fractional differencing parameter |
meanspec |
an object of class "mean_spec"; indicates the specifications for the model in the conditional mean. |
Drange |
a two-element numeric vector that indicates the boundaries
of the interval over which to search for the fractional differencing
parameter |
nonparspec |
an object of class |
use_nonpar |
a logical indicating whether or not to implement a
semiparametric extension of the volatility model defined through |
n_test |
a single numerical value indicating, how many observations
at the end of |
start_pars |
the starting parameters for the numerical optimization
routine; should be of the same length as the parameter output vector
within the output object (also keeping the same order); for |
LB |
the lower boundaries of the parameters in the numerical optimization
routine; should be of the same length as the parameter output vector
within the output object (also keeping the same order); for |
UB |
the upper boundaries of the parameters in the numerical optimization
routine; should be of the same length as the parameter output vector
within the output object (also keeping the same order); for |
control |
a list that is passed to |
control_nonpar |
a list containing changes to the arguments
for the hyperparameter estimation algorithm in the nonparametric
scale function estimation for
|
mean_after_nonpar |
only for |
parallel |
only relevant for a (skewed) average Laplace (AL)
distribution, i.e.
if |
ncores |
only relevant for a (skewed) average Laplace (AL)
distribution, i.e.
if |
trunc |
a positive integer indicating the finite truncation length of the
infinite-order polynomials of the infinite-order representations of the
long-memory model parts; the character |
presample |
the presample length for initialization (for extended EGARCH- / Log-GARCH-type models only relevant for the FARIMA-part, as series in log-transformed conditional variance are initialized by zero). |
Prange |
a two-element vector that indicates the search boundaries for
the parameter |
skip_vcov |
a logical indicating whether or not to skip the computation of the variance-covariance matrix of the parameter estimators and therefore also standard error computation. |
See the documentation on garch, gjrgarch,
tgarch, aparch, figarch,
figjrgarch, fitgarch and fiaparch for more detailed
information on the corresponding models and functions selectable through this
wrapper function.
An object of S4-class "fEGarch_fit_garch", "fEGarch_fit_gjrgarch",
"fEGarch_fit_tgarch",
"fEGarch_fit_aparch", "fEGarch_fit_figarch", "fEGarch_fit_figjrgarch",
"fEGarch_fit_fitgarch" or "fEGarch_fit_fiaparch"
is returned depending on the selected input for the argument
model. The object then contains the following elements.
pars:a named numeric vector with the parameter estimates.
se:a named numeric vector with the obtained standard errors in accordance with the parameter estimates.
vcov_mat:the variance-covariance matrix of the parameter estimates with named columns and rows.
rt:the input object rt (or at least the training data, if n_test is greater than zero);
if rt was a "zoo" or "ts" object, the formatting is kept.
cmeans:the estimated conditional means; if rt was a "zoo" or "ts" object, the formatting is also applied to cmeans.
sigt:the estimated conditional standard deviations (or for use_nonpar = TRUE the estimated total
volatilities, i.e. scale function value times conditional standard deviation); if rt was a "zoo" or "ts" object, the formatting is also applied to sigt.
etat:the obtained residuals; if rt was a "zoo" or "ts" object, the formatting is also applied to etat.
orders:a two-element numeric vector stating the considered model orders.
cond_dist:a character value stating the conditional distribution considered in the model fitting.
long_memo:a logical value stating whether or not long memory was considered in the model fitting.
llhood:the log-likelihood value obtained at the optimal parameter combination.
inf_criteria:a named two-element numeric vector with the corresponding AIC (first element) and BIC (second element) of the fitted parametric model part; for purely parametric models, these criteria are valid for the entire model; for semiparametric models, they are only valid for the parametric step and are not valid for the entire model.
meanspec:the settings for the model in the conditional mean; is an object
of class "mean_spec" that is identical to the object passed to the input argument
meanspec.
test_obs:the observations at the end up the input rt reserved for
testing following n_test.
scale_fun:the estimated scale function values, if use_nonpar = TRUE, otherwise
NULL; formatting of rt is reused.
nonpar_model:the estimation object returned by tsmooth or tsmoothlm for
use_nonpar = TRUE.
trunc:the input argument trunc.
window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") model <- garchm_estim(rt, model = "garch") modelwindow.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") model <- garchm_estim(rt, model = "garch") model
Fit a GJR-GARCH model under the six most common and further conditional distributions to observed data using quasi maximum-likelihood estimation.
gjrgarch( rt, orders = c(1, 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), meanspec = mean_spec(), Drange = c(0, 1), nonparspec = locpol_spec(), use_nonpar = FALSE, n_test = 0, start_pars = NULL, LB = NULL, UB = NULL, control = list(), control_nonpar = list(), mean_after_nonpar = FALSE, parallel = TRUE, ncores = max(1, future::availableCores() - 1), trunc = "none", presample = 50, Prange = c(1, 5), skip_vcov = FALSE )gjrgarch( rt, orders = c(1, 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), meanspec = mean_spec(), Drange = c(0, 1), nonparspec = locpol_spec(), use_nonpar = FALSE, n_test = 0, start_pars = NULL, LB = NULL, UB = NULL, control = list(), control_nonpar = list(), mean_after_nonpar = FALSE, parallel = TRUE, ncores = max(1, future::availableCores() - 1), trunc = "none", presample = 50, Prange = c(1, 5), skip_vcov = FALSE )
rt |
the observed series ordered from past to present; can be
a numeric vector, a |
orders |
a two-element numeric vector containing the two model
orders |
cond_dist |
the conditional distribution to consider as a
character object; the default is a conditional normal distribution
|
meanspec |
an object of class "mean_spec"; indicates the specifications for the model in the conditional mean. |
Drange |
a two-element numeric vector that indicates the boundaries
of the interval over which to search for the fractional differencing
parameter |
nonparspec |
an object of class |
use_nonpar |
a logical indicating whether or not to implement a
semiparametric extension of the volatility model defined through |
n_test |
a single numerical value indicating, how many observations
at the end of |
start_pars |
the starting parameters for the numerical optimization
routine; should be of the same length as the parameter output vector
within the output object (also keeping the same order); for |
LB |
the lower boundaries of the parameters in the numerical optimization
routine; should be of the same length as the parameter output vector
within the output object (also keeping the same order); for |
UB |
the upper boundaries of the parameters in the numerical optimization
routine; should be of the same length as the parameter output vector
within the output object (also keeping the same order); for |
control |
a list that is passed to |
control_nonpar |
a list containing changes to the arguments
for the hyperparameter estimation algorithm in the nonparametric
scale function estimation for
|
mean_after_nonpar |
only for |
parallel |
only relevant for a (skewed) average Laplace (AL)
distribution, i.e.
if |
ncores |
only relevant for a (skewed) average Laplace (AL)
distribution, i.e.
if |
trunc |
a positive integer indicating the finite truncation length of the
infinite-order polynomials of the infinite-order representations of the
long-memory model parts; the character |
presample |
the presample length for initialization (for extended EGARCH- / Log-GARCH-type models only relevant for the FARIMA-part, as series in log-transformed conditional variance are initialized by zero). |
Prange |
a two-element vector that indicates the search boundaries for
the parameter |
skip_vcov |
a logical indicating whether or not to skip the computation of the variance-covariance matrix of the parameter estimators and therefore also standard error computation. |
Let , with as the
time index, be a theoretical time series that follows
Here, means that the innovations
are independent and identically distributed (iid) with mean zero
and variance one, whereas are the conditional standard
deviations in .
Moreover, , , , ,
are real-valued coefficients.
and are the model orders definable through the argument orders,
where is the first element and is the second element in the
argument. In addition, we have as a
real-valued parameter and . is the intercept. It is assumed that
all and are non-negative.
See also the reference section for sources on the GJR-GARCH (Glosten et al., 1993), the more general APARCH (Ding et al., 1993) and the FIAPARCH (Tse, 1998) models.
In the current package version, standard errors of parameter estimates are
computed from the Hessian at the optimum of the log-likelihood using
hessian. To ensure numerical stability and
applicability to a huge variety of differently scaled data, parametric
models are first fitted to data that is scaled to have sample variance
1. Parameter estimates and other quantities are then either
retransformed or recalculated afterwards for the original data.
For a conditional average Laplace distribution, an optimal model for each
distribution parameter from 1 to 5 is estimated (assuming that
is then fixed to the corresponding value). Afterwards, is then
estimated by selecting the estimated model among the five fitted models that
has the largest log-likelihood. The eight models are, by default, fitted
simultaneously using parallel programming techniques (see also the arguments
parallel and ncores, which are only relevant for a conditional
average Laplace distribution). After the optimal model (including
the estimate of called ) has been determined,
is seen as fixed to obtain the standard errors via the Hessian matrix for the
estimates of the continuous parameters. A standard error for is therefore
not obtained and the ones obtained for the remaining estimates do not account
for .
An ARMA-GJR-GARCH or a FARIMA-GJR-GARCH can be fitted by adjusting the
argument meanspec correspondingly.
As an alternative, a semiparametric extension of the pure models
in the conditional variance can be implemented. If use_nonpar = TRUE,
meanspec is omitted and before fitting a model in the
conditional volatility following the remaining function arguments, a smooth scale function,
i.e. a function representing the unconditional standard deviation over time,
is being estimated following the specifications in nonparspec and
control_nonpar. This preliminary step stabilizes the input
series rt, as long-term changes in the unconditional variance
are being estimated and removed before the parametric step using
tsmooth. control_nonpar can be adjusted following
to make changes to the arguments of tsmooth
for long-memory specifications. These arguments specify settings
for the automated bandwidth selection algorithms implemented by this
function. By default, we use the settings
InfR = "Nai",
bStart = 0.15, cb = 0.05, and
method = "lpr" for tsmooth.
locpol_spec passed to nonparspec handles
more direct settings of the local polynomial smoother itself. See
the documentation for these functions to get a detailed overview
of these settings. Assume to be the observed series, where
,
then , with being the arithmetic
mean over the observed , is computed and subsequently
. The subtraction of
is necessary so that are all different from zero
almost surely. Once are available, its trend ,
with as the rescaled time on the interval , is
being estimated using
tsmoothlm and denoted here by
. Then from
obtain ,
and obtain the estimated scale function as
.
The stabilized / standardized version of the series
is then , to which
a purely parametric volatility model following the remaining function arguments
is then
fitted. The estimated volatility at a given time point is then
the product of the estimate of the corresponding scale function value
and of the estimated conditional standard deviation (following the parametric
model part) for that same time point. See for example Feng et al. (2022)
or Letmathe et al. (2023) for more information on the semiparametric extension
of volatility models.
The order for manual settings of start_pars, LB and UB
is crucial. The correct order is: , ,
,,,
, ,
, shape parameter,
skewness parameter. Depending on the exact model specification,
parameters irrelevant for the specification at hand should be dropped
in start_pars, LB and UB.
An object of S4-class "fEGarch_fit_gjrgarch"
is returned. It contains the following elements.
pars:a named numeric vector with the parameter estimates.
se:a named numeric vector with the obtained standard errors in accordance with the parameter estimates.
vcov_mat:the variance-covariance matrix of the parameter estimates with named columns and rows.
rt:the input object rt (or at least the training data, if n_test is greater than zero);
if rt was a "zoo" or "ts" object, the formatting is kept.
cmeans:the estimated conditional means; if rt was a "zoo" or "ts" object, the formatting is also applied to cmeans.
sigt:the estimated conditional standard deviations (or for use_nonpar = TRUE the estimated total
volatilities, i.e. scale function value times conditional standard deviation); if rt was a "zoo" or "ts" object, the formatting is also applied to sigt.
etat:the obtained residuals; if rt was a "zoo" or "ts" object, the formatting is also applied to etat.
orders:a two-element numeric vector stating the considered model orders.
cond_dist:a character value stating the conditional distribution considered in the model fitting.
long_memo:a logical value stating whether or not long memory was considered in the model fitting.
llhood:the log-likelihood value obtained at the optimal parameter combination.
inf_criteria:a named two-element numeric vector with the corresponding AIC (first element) and BIC (second element) of the fitted parametric model part; for purely parametric models, these criteria are valid for the entire model; for semiparametric models, they are only valid for the parametric step and are not valid for the entire model.
meanspec:the settings for the model in the conditional mean; is an object
of class "mean_spec" that is identical to the object passed to the input argument
meanspec.
test_obs:the observations at the end up the input rt reserved for
testing following n_test.
scale_fun:the estimated scale function values, if use_nonpar = TRUE, otherwise
NULL; formatting of rt is reused.
nonpar_model:the estimation object returned by tsmooth for
use_nonpar = TRUE.
trunc:the input argument trunc.
Ding, Z., Granger, C. W. J., & Engle, R. F. (1993). A long memory property of stock market returns and a new model. Journal of Empirical Finance, 1(1): 83-106. DOI: 10.1016/0927-5398(93)90006-D.
Feng, Y., Gries, T., Letmathe, S., & Schulz, D. (2022). The smoots Package in R for Semiparametric Modeling of Trend Stationary Time Series. The R Journal, 14(1), 182-195. URL: https://journal.r-project.org/articles/RJ-2022-017/.
Glosten, L. R., Jagannathan, R., & Runkle, D. E. (1993). On The Relation between The Expected Value and The Volatility of Nominal Excess Return on stocks. Journal of Finance 48(5), 1779-1801. DOI: 10.1111/j.1540-6261.1993.tb05128.x.
Letmathe, S., Beran, J., & Feng, Y. (2023). An extended exponential SEMIFAR model with application in R. Communications in Statistics - Theory and Methods, 53(22), 7914–7926. DOI: 10.1080/03610926.2023.2276049.
Tse, Y. K. (1998). The conditional heteroskedasticity of the yen-dollar exchange rate. Journal of Applied Econometrics, 13(1): 49-55. DOI: 10.1002/(SICI)1099-1255(199801/02)13:1<49::AID-JAE459>3.0.CO;2-O.
window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") model <- gjrgarch(rt) modelwindow.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") model <- gjrgarch(rt) model
A streamlined simulation function to simulate from GJR-GARCH models.
gjrgarch_sim( pars = list(mu = 0, ar = numeric(0), ma = numeric(0), D = 0, omega = 4e-04, phi = 0.05, beta = 0.8, gamma = 0.1, df = 10, shape = 2, P = 3, skew = 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), n = 1000, nstart = 5000, trunc = "none" )gjrgarch_sim( pars = list(mu = 0, ar = numeric(0), ma = numeric(0), D = 0, omega = 4e-04, phi = 0.05, beta = 0.8, gamma = 0.1, df = 10, shape = 2, P = 3, skew = 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), n = 1000, nstart = 5000, trunc = "none" )
pars |
a named list with the parameter specifications; the user can provide a named list with only the settings they would like to adjust relative to the default settings. |
cond_dist |
a one-element character vector specifying the conditional distribution to consider. |
n |
the number of observations to return. |
nstart |
the number of burn-in observations to simulate before
the final |
trunc |
a truncation for the finite-order coefficient series
in long-memory models; can either be the character |
See the documentation on gjrgarch for information
on the GJR-GARCH model. This function provides
an easy way to simulate from these models.
A list with four elements is returned: rt are the simulated
observations, etat are the underlying innovations,
sigt are the correspondingly simulated conditional
standard deviations, and cmeans are the simulated
conditional means. These four elements are formatted as
"ts" class time series objects.
sim <- gjrgarch_sim(n = 1000) mat <- do.call(cbind, sim) plot(mat, main = "")sim <- gjrgarch_sim(n = 1000) mat <- do.call(cbind, sim) plot(mat, main = "")
Consider a probability integral transform on the standardized residuals of a fitted model and apply a Pearson goodness-of-fit test to the binned data using a selection of predefined number of bins.
## S4 method for signature 'fEGarch_fit' goodn_of_fit_test(object, n_bins = c(20, 30, 40, 50), silent = FALSE, ...)## S4 method for signature 'fEGarch_fit' goodn_of_fit_test(object, n_bins = c(20, 30, 40, 50), silent = FALSE, ...)
object |
an object of class |
n_bins |
a numeric vector giving the number of bins to use. |
silent |
a logical indicating whether or not to print the test results in a well-formatted manner to the console. |
... |
currently without purpose. |
Use a probability integral transform on the standardized residuals of a fitted model. This is then the basis to conduct a Pearson goodness-of-fit chi-square test.
Returns a numeric matrix invisibly.
window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") spec <- fEGarch_spec() model <- fEGarch(spec, rt) goodn_of_fit_test(model)window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") spec <- fEGarch_spec() model <- fEGarch(spec, rt) goodn_of_fit_test(model)
Accessors to access the elements of the same name in
output objects returned by either distr_est or
its various wrappers like norm_est.
## S4 method for signature 'fEGarch_distr_est' inf_criteria(x) ## S4 method for signature 'fEGarch_distr_est' llhood(x) ## S4 method for signature 'fEGarch_distr_est' pars(x) ## S4 method for signature 'fEGarch_distr_est' se(x) ## S4 method for signature 'fEGarch_distr_est' vcov_mat(x)## S4 method for signature 'fEGarch_distr_est' inf_criteria(x) ## S4 method for signature 'fEGarch_distr_est' llhood(x) ## S4 method for signature 'fEGarch_distr_est' pars(x) ## S4 method for signature 'fEGarch_distr_est' se(x) ## S4 method for signature 'fEGarch_distr_est' vcov_mat(x)
x |
an object returned by either |
Convenience methods to access the elements of the same name
that can otherwise be accessed via the operator @ within
objects that inherit from class "fEGarch_distr_est", which covers
objects returned by either distr_est or
its various wrappers like norm_est.
The element within the input object of the same name as the method is returned.
x <- rged_s(4000, shape = 1.5) * 2.1 + 3.3 est <- ged_est(x) inf_criteria(est) pars(est)x <- rged_s(4000, shape = 1.5) * 2.1 + 3.3 est <- ged_est(x) inf_criteria(est) pars(est)
Generics for different goodness-of-fit tests. Currently without use.
ljung_box_test( object, m_max = 20, weight_f = function(lag) { m <- max(lag) (m + 1 - lag)/m }, adj_df = NULL, silent = FALSE, ... ) sign_bias_test(object, silent = FALSE, ...) goodn_of_fit_test(object, n_bins = c(20, 30, 40, 50), silent = FALSE, ...) fit_test_suite( object, args_lbt = list(), args_sbt = list(), args_goft = list(), silent = FALSE, ... )ljung_box_test( object, m_max = 20, weight_f = function(lag) { m <- max(lag) (m + 1 - lag)/m }, adj_df = NULL, silent = FALSE, ... ) sign_bias_test(object, silent = FALSE, ...) goodn_of_fit_test(object, n_bins = c(20, 30, 40, 50), silent = FALSE, ...) fit_test_suite( object, args_lbt = list(), args_sbt = list(), args_goft = list(), silent = FALSE, ... )
object |
currently without use. |
m_max |
currently without use. |
weight_f |
currently without use. |
adj_df |
currently without use. |
silent |
currently without use. |
... |
currently without use. |
n_bins |
currently without use. |
args_lbt |
currently without use. |
args_sbt |
currently without use. |
args_goft |
currently without use. |
The generics are currently without use and do not return anything.
Apply a (weighted) Ljung-Box test (through the Gamma approximation) to check the standardized residuals of a fitted model from this package for remaining autocorrelation. Two different options allow to check either the simple residuals or the squared residuals.
## S4 method for signature 'fEGarch_fit' ljung_box_test( object, m_max = 20, weight_f = function(lag) { m <- max(lag) (m + 1 - lag)/m }, adj_df = NULL, silent = FALSE, type = c("simple", "squared"), ... )## S4 method for signature 'fEGarch_fit' ljung_box_test( object, m_max = 20, weight_f = function(lag) { m <- max(lag) (m + 1 - lag)/m }, adj_df = NULL, silent = FALSE, type = c("simple", "squared"), ... )
object |
an object |
m_max |
the maximum lag; tests will be conducted for 1 up to
|
weight_f |
a function with argument |
adj_df |
degrees of freedom to adjust for as a number or the default
|
silent |
a logical value reflecting whether or not test results should be printed in a well-formatted manner to the console. |
type |
either |
... |
currently without use. |
Returns a numeric matrix invisibly.
window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") spec <- fEGarch_spec() model <- fEGarch(spec, rt) ljung_box_test(model)window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") spec <- fEGarch_spec() model <- fEGarch(spec, rt) ljung_box_test(model)
Specify the nonparametric local polynomial model part in a semiparametric volatility model.
locpol_spec( poly_order = c(3, 1), kernel_order = c(1, 0, 2, 3), boundary_method = c("extend", "shorten"), bwidth = NULL )locpol_spec( poly_order = c(3, 1), kernel_order = c(1, 0, 2, 3), boundary_method = c("extend", "shorten"), bwidth = NULL )
poly_order |
a single numeric value, in detail either |
kernel_order |
a single numeric value representing
the smoothness of the underlying kernel function;
available are |
boundary_method |
a single character value indicating
the smoothing concept to use at boundary points; for
|
bwidth |
the smoothing bandwidth; for NULL, i.e. the default, an automated bandwidth selection is employed; otherwise a single numeric value between 0 and 0.5 must be provided. |
Assume that a time series , , follows
where and are independent and identically
distributed random variables with mean zero and variance one.
are total volatilities composed of , a smooth, deterministic
scale function in the unconditional variance over time (with being
the rescaled time on the interval ), and of ,
the conditional standard deviation in , so that
, or alternatively .
It is assumed that the unconditional variance of the is one.
The package's estimation of is based on the following relations:
,
,
,
,
, so that
where describes a smooth, deterministic trend in .
Nonparametric estimation of and subsequent retransformation
allows to obtain a suitable estimate of the scale function
in . Following Feng et al. (2022) and Letmathe et al. (2023),
we employ local polynomial regression with automatically selected
bandwidth (specially for the time-series context). The function
locpol_spec allows to set the basic characteristics of the
local polynomial estimator considered, like the order of polynomial
used in the local regressions, and the kernel function order. After
the scale function has been estimated, a zero-mean GARCH-type model
can be fitted to the estimated .
Depending on whether is assumed to follow a short-memory
or a long-memory model, the bandwidth selection algorithm in the
local polynomial regression step differs and follows either
Feng et al. (2022) and Letmathe et al. (2023). The algorithm
selection is done automatically based on the remaining model
specifications in the call to the estimation functions like
fEGarch.
An object of class "locpol_spec" is returned.
Feng, Y., Gries, T., Letmathe, S., & Schulz, D. (2022). The smoots Package in R for Semiparametric Modeling of Trend Stationary Time Series. The R Journal, 14(1), 182-195. URL: https://journal.r-project.org/articles/RJ-2022-017/.
Letmathe, S., Beran, J., & Feng, Y. (2023). An extended exponential SEMIFAR model with application in R. Communications in Statistics - Theory and Methods, 53(22), 7914–7926. DOI: 10.1080/03610926.2023.2276049.
locpol_spec() locpol_spec(poly_order = 1) locpol_spec(kernel_order = 2)locpol_spec() locpol_spec(poly_order = 1) locpol_spec(kernel_order = 2)
"locpol_spec"
Access and change elements in objects of class "locpol_spec".
The method names represent the name of the element to access /
manipulate.
## S4 method for signature 'locpol_spec' poly_order(x) ## S4 method for signature 'locpol_spec' kernel_order(x) ## S4 method for signature 'locpol_spec' boundary_method(x) ## S4 method for signature 'locpol_spec' bwidth(x) ## S4 replacement method for signature 'locpol_spec' poly_order(x) <- value ## S4 replacement method for signature 'locpol_spec' kernel_order(x) <- value ## S4 replacement method for signature 'locpol_spec' boundary_method(x) <- value ## S4 replacement method for signature 'locpol_spec' bwidth(x) <- value## S4 method for signature 'locpol_spec' poly_order(x) ## S4 method for signature 'locpol_spec' kernel_order(x) ## S4 method for signature 'locpol_spec' boundary_method(x) ## S4 method for signature 'locpol_spec' bwidth(x) ## S4 replacement method for signature 'locpol_spec' poly_order(x) <- value ## S4 replacement method for signature 'locpol_spec' kernel_order(x) <- value ## S4 replacement method for signature 'locpol_spec' boundary_method(x) <- value ## S4 replacement method for signature 'locpol_spec' bwidth(x) <- value
x |
the input object or object to modify. |
value |
the value to modify the object |
These methods are intended to be used for accessing or manipulating
individual elements of objects of class "locpol_spec".
These methods return an object of class "locpol_spec".
test_obj <- locpol_spec() poly_order(test_obj) poly_order(test_obj) <- 1 poly_order(test_obj)test_obj <- locpol_spec() poly_order(test_obj) poly_order(test_obj) <- 1 poly_order(test_obj)
Currently without use. Use the methods derived from this generic.
loss_functions(object, penalty = 1e-04, ...)loss_functions(object, penalty = 1e-04, ...)
object |
currently without use. |
penalty |
currently without use. |
... |
currently without use. |
The generic itself is currently without use and thus does not return anything.
Compute loss function values given log-returns and corresponding value at risk (VaR) and expected shortfall (ES) series.
## S4 method for signature 'fEGarch_risk' loss_functions(object, penalty = 1e-04, ...)## S4 method for signature 'fEGarch_risk' loss_functions(object, penalty = 1e-04, ...)
object |
an object of class |
penalty |
the penalty term to use in the opportunity cost terms. |
... |
currently without use. |
Let be the number of observations of a (log-)return
series , , and let and
be the
estimated or forecasted VaR and ES (at some confidence level ) at time
, respectively. Such series are included in an object of class
"fEGarch_risk". In the following, a risk measure at time is
simply denoted by and can either mean
or
.
Based on a calculated VaR and / or expected shortfall (ES), capital needs
to be held back following regulatory rules. Commonly, among many models
used for forecasting risk measures that fulfill regulatory conditions,
loss functions are computed that also consider opportunity costs in to
assess, what model that fulfills regulatory rules minimizes such loss
functions. Let be the penalty term.
For all loss functions we have
as the loss function with
for . They differ in how the case
is treated.
The regulatory loss function (rlf) uses .
The firm's loss function (Sarma et al., 2003) (flf) considers
.
The adjusted loss function (Abad et al., 2015) (alf) makes use
of .
The corrected loss function (Feng, forthcoming) (clf) has
.
Returns a list with the four elements rlf, flf,
alf and clf, each lists with numeric vector
elements VaR and ES. The four elements correspond
to the regulatory loss function, the firm's loss function,
the adjusted loss function and the corrected 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. DOI: 10.21314/JRMV.2015.132.
Sarma, M., Thomas, S., & Shah, A. (2003). Selection of Value-at-Risk models. Journal of Forecasting, 22(4): 337-358. DOI: 10.1002/for.868.
window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") model <- fEGarch(egarch_spec(), rt, n_test = 250) fcast <- predict_roll(model) risk <- measure_risk(fcast, measure = c("VaR", "ES"), level = c(0.95, 0.975, 0.99)) loss_functions(risk)window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") model <- fEGarch(egarch_spec(), rt, n_test = 250) fcast <- predict_roll(model) risk <- measure_risk(fcast, measure = c("VaR", "ES"), level = c(0.95, 0.975, 0.99)) loss_functions(risk)
Specify the model for the conditional mean in a dual model, where the conditional mean is modelled through an ARMA or a FARIMA model and the conditional standard deviations through a GARCH-type model simultaneously.
mean_spec(orders = c(0, 0), long_memo = FALSE, include_mean = TRUE)mean_spec(orders = c(0, 0), long_memo = FALSE, include_mean = TRUE)
orders |
a two-element numeric vector with the model
orders; the first element is the autoregressive order |
long_memo |
a logical value that indicates whether the long-memory version of the model should be considered or not. |
include_mean |
a logical value indicating whether or
not to include the constant unconditional mean in the estimation
procedure; for |
Let , with as the time index,
be a theoretical time series that follows
where and
are the AR- and MA-polynomials
of orders and , respectively, with real coefficients
, , and , .
is the backshift operator. and are
commonly assumed to be without common roots and to have roots outside of
the unit circle.
Furthermore, is a real-valued coefficient representing the unconditional
mean in . is the fractional
differencing parameter. is a zero-mean (weak) white
noise process, for example a member of the GARCH-models (with mean set to zero)
presented in this package (see the
descriptions in fEGarch_spec, fiaparch, figarch, etc.).
The for , which can be achieved through long_memo = FALSE,
the formulas above describe an autoregressive moving-average (ARMA) model.
For , they describe a fractionally integrated ARMA (FARIMA)
model.
An object of class "mean_spec" is returned.
mean_spec() mean_spec(orders = c(1, 1))mean_spec() mean_spec(orders = c(1, 1))
"mean_spec"
Access and change elements in objects of class "mean_spec".
The method names represent the name of the element to access /
manipulate.
## S4 method for signature 'mean_spec' orders(x) ## S4 method for signature 'mean_spec' long_memo(x) ## S4 method for signature 'mean_spec' include_mean(x) ## S4 replacement method for signature 'mean_spec' orders(x) <- value ## S4 replacement method for signature 'mean_spec' long_memo(x) <- value ## S4 replacement method for signature 'mean_spec' include_mean(x) <- value## S4 method for signature 'mean_spec' orders(x) ## S4 method for signature 'mean_spec' long_memo(x) ## S4 method for signature 'mean_spec' include_mean(x) ## S4 replacement method for signature 'mean_spec' orders(x) <- value ## S4 replacement method for signature 'mean_spec' long_memo(x) <- value ## S4 replacement method for signature 'mean_spec' include_mean(x) <- value
x |
the input object or object to modify. |
value |
the value to modify the object |
These methods are intended to be used for accessing or manipulating
individual elements of objects of class "mean_spec".
These methods return an object of class "mean_spec".
test_obj <- mean_spec() orders(test_obj) orders(test_obj) <- c(1, 1) orders(test_obj)test_obj <- mean_spec() orders(test_obj) orders(test_obj) <- c(1, 1) orders(test_obj)
Provides easy access to value-at-risk (VaR) and expected shortfall (ES) computation for available models in this package. VaR and ES can either be computed based on (a) fitted conditional means and conditional standard deviations for a training period, or following (b) point forecasts (one-step rolling) of the conditional means and conditional standard deviations.
measure_risk(object, measure = c("VaR", "ES"), level = c(0.975, 0.99), ...) ## S4 method for signature 'fEGarch_fit' measure_risk(object, measure = c("VaR", "ES"), level = c(0.975, 0.99), ...) ## S4 method for signature 'fEGarch_forecast' measure_risk(object, measure = c("VaR", "ES"), level = c(0.975, 0.99), ...) ## S4 method for signature 'fEGarch_distr_est' measure_risk( object, measure = c("VaR", "ES"), level = c(0.975, 0.99), test_obs, sigt, cmeans, ... )measure_risk(object, measure = c("VaR", "ES"), level = c(0.975, 0.99), ...) ## S4 method for signature 'fEGarch_fit' measure_risk(object, measure = c("VaR", "ES"), level = c(0.975, 0.99), ...) ## S4 method for signature 'fEGarch_forecast' measure_risk(object, measure = c("VaR", "ES"), level = c(0.975, 0.99), ...) ## S4 method for signature 'fEGarch_distr_est' measure_risk( object, measure = c("VaR", "ES"), level = c(0.975, 0.99), test_obs, sigt, cmeans, ... )
object |
either an object of class |
measure |
a character vector with element |
level |
a numeric vector of arbitrary length indicating the confidence
levels to compute the VaR and the ES at; by default, the levels
|
... |
currently without use. |
test_obs |
a series of test observations (only required when |
sigt |
a series of forecasted conditional standard deviations for the
same time points as |
cmeans |
a series of forecasted conditional means for the
same time points as |
Given a fitted model with fitted conditional means and conditional standard deviations or given point forecasts of such series based on a fitted model, the risk measures VaR and ES can be computed (at arbitrary confidence levels) following the conditional loss distribution defined through the estimated / forecasted conditional mean value, the estimated / forecasted conditional standard deviation value, and the assumed conditional distribution (including potential estimates of distribution parameters).
Let be the estimated / forecasted conditional mean and be the
estimated / forecasted conditional standard deviation at some time point . Furthermore,
define and be
the time-invariant VaR and ES, respectively, of some identically but independently
distributed random variables with mean zero and variance one. Given that
the relationship , where and
are the true conditional mean and conditional standard deviation at time , is assumed
for some return series , the estimated / forecasted conditional VaR and ES of are simply
This definition holds, when losses and therefore also
and (for common such as
or ) are considered
to be negative in sign.
Define
which also need to be estimated for some distributions, if a distribution parameter needed to be estimated. in the previous formula
is the cumulative distribution function of the random variables . Therefore,
returns the quantile of the innovation distribution at level
.
In some cases, when rolling
one-step forecasts of the conditional standard deviations and the conditional means
were obtained following a nonparametric approach, for example through
neural networks or similar approaches, VaR and ES are not directly to be calculated
because distribution assumptions have not been made. If an object that
is a fitted distribution to the model's standardized in-sample residuals is provided,
and if also test observations as well as forecasted conditional standard deviations
and conditional means for the test time points are passed to the method, VaR
and ES will be computed using the fitted distribution in object. Note
that object must be of class "fEGarch_distr_est". A natural
selection of object is the output of find_dist, which returns
the best fitted model among a normal distribution, a -distribution, a
generalized error distribution, an average Laplace distribution, and their skewed
variants, following either BIC (the default) or AIC. It is recommended to then
set fix_mean = 0 and fix_sdev = 1 in the call to
find_dist to reflect the known property that the residuals are assumed
to be estimated from innovations with mean zero and variance one.
The S4 methods all return an object of class "fEGarch_risk" with elements measures,
observations and model.
observations is the observed series at the time points, for which the
risk measures are calculated. measures is a list with elements
VaR and ES, distinguishing between computed VaR and ES values.
These elements again are list with named elements representing the various
computed series. model is the fitted model or a list of multiple fitted model objects.
# In-sample window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") model <- fEGarch(egarch_spec(), rt) risk <- measure_risk(model, measure = c("VaR", "ES"), level = c(0.95, 0.975, 0.99)) risk # Out-of-sample rolling point forecasts window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") model2 <- fEGarch(egarch_spec(), rt, n_test = 250) # parallel = FALSE only for better compatibility with CRAN checks; # should be set to TRUE for speed boost fcast <- predict_roll(model2, parallel = FALSE) risk2 <- measure_risk(fcast, measure = c("VaR", "ES"), level = c(0.95, 0.975, 0.99)) risk2 # Use some model to obtain rolling point forecasts of # the conditional mean and the conditional standard deviation for # some test period; in practice, this will not be from a GARCH-type # model, because it is parametric and includes a distribution assumption, # but instead from some nonparametric model window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2005-12-31") model <- fEGarch(egarch_spec(), rt, n_test = 250) # parallel = FALSE only for better compatibility with CRAN checks; # should be set to TRUE for speed boost fc <- model %>% predict_roll(refit_after = 50, parallel = FALSE) test_obs <- model@test_obs # Test observations sigt <- fc@sigt # Conditional volatility forecasts cmeans <- fc@cmeans # Conditional mean forecasts resids <- model@etat # In-sample standardized residuals # Given 'test_obs', 'sigt', 'cmeans' and 'resids', we can now # compute the VaR and ES forecasts for the test period dist <- find_dist(resids, fix_mean = 0, fix_sdev = 1) dist risk <- dist %>% measure_risk(test_obs = test_obs, sigt = sigt, cmeans = cmeans) plot(risk, which = 0.975)# In-sample window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") model <- fEGarch(egarch_spec(), rt) risk <- measure_risk(model, measure = c("VaR", "ES"), level = c(0.95, 0.975, 0.99)) risk # Out-of-sample rolling point forecasts window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") model2 <- fEGarch(egarch_spec(), rt, n_test = 250) # parallel = FALSE only for better compatibility with CRAN checks; # should be set to TRUE for speed boost fcast <- predict_roll(model2, parallel = FALSE) risk2 <- measure_risk(fcast, measure = c("VaR", "ES"), level = c(0.95, 0.975, 0.99)) risk2 # Use some model to obtain rolling point forecasts of # the conditional mean and the conditional standard deviation for # some test period; in practice, this will not be from a GARCH-type # model, because it is parametric and includes a distribution assumption, # but instead from some nonparametric model window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2005-12-31") model <- fEGarch(egarch_spec(), rt, n_test = 250) # parallel = FALSE only for better compatibility with CRAN checks; # should be set to TRUE for speed boost fc <- model %>% predict_roll(refit_after = 50, parallel = FALSE) test_obs <- model@test_obs # Test observations sigt <- fc@sigt # Conditional volatility forecasts cmeans <- fc@cmeans # Conditional mean forecasts resids <- model@etat # In-sample standardized residuals # Given 'test_obs', 'sigt', 'cmeans' and 'resids', we can now # compute the VaR and ES forecasts for the test period dist <- find_dist(resids, fix_mean = 0, fix_sdev = 1) dist risk <- dist %>% measure_risk(test_obs = test_obs, sigt = sigt, cmeans = cmeans) plot(risk, which = 0.975)
Imported from base R.
plot(x, y, ...)plot(x, y, ...)
x |
see base R |
y |
see base R |
... |
see base R |
Returns nothing to the console but creates a plot in the plot window.
This is method for producing various plots of the estimation results returned by this package.
## S4 method for signature 'fEGarch_fit,ANY' plot(x, y = NULL, which = NULL, ...)## S4 method for signature 'fEGarch_fit,ANY' plot(x, y = NULL, which = NULL, ...)
x |
an object returned by the fitting functions of this package,
for example by |
y |
for compatibility but without use. |
which |
various plots can be selected either via a keyword or a number;
enter |
... |
further arguments to pass to |
Create predefined standard plots of the estimation objects returned by the
fEGarch package.
Plots are created in the base R plot style. The type of plot can be chosen
either interactively from the console, or the argument which can be
used to directly select the kind of plot to create (see also the description
of the argument which) within the function call.
A graphic is created in the plots windows, the function itself, however,
returns NULL.
Dominik Schulz (Research Assistant) (Department of Economics, Paderborn
University),
Author and Package Creator
window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") # Pure conditional volatility model spec <- fEGarch_spec() model <- fEGarch(spec, rt) plot(model, which = 3)window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") # Pure conditional volatility model spec <- fEGarch_spec() model <- fEGarch(spec, rt) plot(model, which = 3)
Plot risk measure results returned by measure_risk
as a points-over-threshold plot in style of base R plots.
## S4 method for signature 'fEGarch_risk,ANY' plot(x, y = NULL, which = NULL, ...)## S4 method for signature 'fEGarch_risk,ANY' plot(x, y = NULL, which = NULL, ...)
x |
an object returned by |
y |
for compatibility but without use. |
which |
one of the levels of VaR and ES saved in
|
... |
without use. |
Returns nothing but produces a base R plot in the plot window.
window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2003-12-31") egarch_spec() %>% fEGarch(rt = rt, n_test = 250) %>% predict_roll() %>% measure_risk() %>% plot(which = 0.99)window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2003-12-31") egarch_spec() %>% fEGarch(rt = rt, n_test = 250) %>% predict_roll() %>% measure_risk() %>% plot(which = 0.99)
Generics to build methods on for adjusting certain settings in context of nonparametric smoothing. The generics are currently without use.
poly_order(x) kernel_order(x) boundary_method(x) bwidth(x) poly_order(x) <- value kernel_order(x) <- value boundary_method(x) <- value bwidth(x) <- valuepoly_order(x) kernel_order(x) boundary_method(x) bwidth(x) poly_order(x) <- value kernel_order(x) <- value boundary_method(x) <- value bwidth(x) <- value
x |
the generics are currently without use. |
value |
the generics are currently without use. |
The generics do not work on their own and thus do not return anything.
The generics are themselves without use.
predict_roll( object, step_size = 1, trunc = NULL, refit_after = NULL, steady_window = FALSE, parallel = TRUE, ncores = max(1, future::availableCores() - 1), fitting_args = list(), ... )predict_roll( object, step_size = 1, trunc = NULL, refit_after = NULL, steady_window = FALSE, parallel = TRUE, ncores = max(1, future::availableCores() - 1), fitting_args = list(), ... )
object |
the generics are currently without use. |
step_size |
the generics are currently without use. |
trunc |
the generics are currently without use. |
refit_after |
the generics are currently without use. |
steady_window |
the generics are currently without use. |
parallel |
the generics are currently without use. |
ncores |
the generics are currently without use. |
fitting_args |
the generics are currently without use. |
... |
the generics are currently without use. |
The generics do not work themselves and therefore do not return anything.
Given a fitted model object from this package, conduct either multistep point forecasts of the conditional means and the conditional standard deviations into the future or rolling point forecasts of arbitrary step size of these quantities for a future test set.
## S4 method for signature 'fEGarch_fit' predict(object, n.ahead = 10, trunc = NULL, ...) ## S4 method for signature 'fEGarch_fit' predict_roll( object, step_size = 1, trunc = NULL, refit_after = NULL, steady_window = FALSE, parallel = TRUE, ncores = max(1, future::availableCores() - 1), fitting_args = list(), ... )## S4 method for signature 'fEGarch_fit' predict(object, n.ahead = 10, trunc = NULL, ...) ## S4 method for signature 'fEGarch_fit' predict_roll( object, step_size = 1, trunc = NULL, refit_after = NULL, steady_window = FALSE, parallel = TRUE, ncores = max(1, future::availableCores() - 1), fitting_args = list(), ... )
object |
an object of class |
n.ahead |
a single numeric value indicating how far into the future the multistep point forecasts should be produced. |
trunc |
the truncation setting for the infinite-order
polynomial of long-memory model parts; the default uses
the setting from the fitted input object |
... |
currently without use and included for compatibility with generics. |
step_size |
the step size of the rolling point
forecasts; by default, |
refit_after |
a positive integer indicatinmg the number
of observations of the test
set, after which the model should be refitted regularly; for the
default |
steady_window |
a logical; if |
parallel |
a logical, indicating whether the models and forecasts should be produced in parallel for a speed boost. |
ncores |
the number of cores to use for parallel computations. |
fitting_args |
a list with further fitting arguments for any of the main fitting functions from this package; useful in the refitting, when other settings than the default need to be implemented. |
Use predict to compute multistep point forecasts
(of the conditional mean and of the conditional standard deviation)
into the future. Let n be the number of observations
of the data, to which a model was fitted. Then multistep
point forecasts are produced for all future time points
from n + 1 to n + n.ahead.
Otherwise, if data was reserved for testing when creating
object, e.g. through the use of the argument
n_test in the corresponding functions, compute
rolling point forecasts over the test set using predict_roll.
step_size then determines the forecasting horizon for
the rolling point forecasts. For example, step_size = 1, i.e.
the default, computes one-step rolling point forecasts, whereas for
example step_size = 10 computes ten-step rolling point
forecasts (starting at the tenth test time point).
Refitting of models during the rolling point forecast procedure
is available with package version 1.0.4 for GARCH-type models.
refit_after defines
after how many test observations the model should be refitted every time.
steady_window addresses whether in refitting models the training
observations should always start at the very first observation time
point available, i.e. steady_window = FALSE, or whether the initial
number of training observations should be kept throughout when refitting, so
that the window width of training observations is kept but shifted when
refitting, i.e. steady_window = TRUE. The behavior of
predict_roll from package version 1.0.3 or earlier, i.e. obtaining
rolling forecasts without model refitting, can be reproduced
by setting refit_after = NULL.
Returns an object of class "fEGarch_forecast" that has the
two slots @sigt and @cmeans representing the
forecasted conditional standard deviations and conditional
means, respectively. If the training series saved in object
has a special time series formatting like "zoo" or "ts",
the formatting is adopted accordingly to these numeric
output series. A third slot @model is either the fitted model
input object object (when refitting is disabled) or a list as a
collection of fitted model objects of class "fEGarch_fit"
(when refitting is enabled).
window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") # Multistep forecasting (EGARCH with cond. normal distr.) model1 <- fEGarch(spec = egarch_spec(), rt) fcast1 <- predict(model1, n.ahead = 10) fcast1 # Rolling one-step forecasts (EGARCH with cond. normal distr.) # (Parallel computation disabled for better compatibility with # CRAN checks) model2 <- fEGarch(spec = egarch_spec(), rt, n_test = 250) fcast2 <- predict_roll(model2, step_size = 1, refit_after = 50, parallel = FALSE) fcast2window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") # Multistep forecasting (EGARCH with cond. normal distr.) model1 <- fEGarch(spec = egarch_spec(), rt) fcast1 <- predict(model1, n.ahead = 10) fcast1 # Rolling one-step forecasts (EGARCH with cond. normal distr.) # (Parallel computation disabled for better compatibility with # CRAN checks) model2 <- fEGarch(spec = egarch_spec(), rt, n_test = 250) fcast2 <- predict_roll(model2, step_size = 1, refit_after = 50, parallel = FALSE) fcast2
An alternative to etat,fEGarch_fit-method to extract
standardized residuals from an estimation object
in this package.
## S4 method for signature 'fEGarch_fit' residuals(object)## S4 method for signature 'fEGarch_fit' residuals(object)
object |
an object either of class |
Extract fitted standardized residuals from an estimation object in this package.
The element within the input object with name etat is returned.
Depending on the element that can be a numeric vector, an object of
class "zoo" or a numeric matrix.
window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") model <- fEGarch(egarch_spec(), rt, n_test = 250) residuals(model)window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") model <- fEGarch(egarch_spec(), rt, n_test = 250) residuals(model)
rugarch GARCH ModelsEasy to use functions for fitting selected GARCH-type models from
the widely-known rugarch package by Ghalanos (2024). These
functions are meant as an easy to use way to compare the main results from
rugarch to the newly established models in the fEGarch package
and are by no means considered to be a replacement of rugarch.
aparch_ru( rt, orders = c(1, 1), cond_dist = c("norm", "std", "ged", "snorm", "sstd", "sged"), meanspec = mean_spec(), nonparspec = locpol_spec(), use_nonpar = FALSE, n_test = 0, start_pars = NULL, control_nonpar = list() ) gjrgarch_ru( rt, orders = c(1, 1), cond_dist = c("norm", "std", "ged", "snorm", "sstd", "sged"), meanspec = mean_spec(), nonparspec = locpol_spec(), use_nonpar = FALSE, n_test = 0, start_pars = NULL, control_nonpar = list() ) egarch_ru( rt, orders = c(1, 1), cond_dist = c("norm", "std", "ged", "snorm", "sstd", "sged"), meanspec = mean_spec(), nonparspec = locpol_spec(), use_nonpar = FALSE, n_test = 0, start_pars = NULL, control_nonpar = list() )aparch_ru( rt, orders = c(1, 1), cond_dist = c("norm", "std", "ged", "snorm", "sstd", "sged"), meanspec = mean_spec(), nonparspec = locpol_spec(), use_nonpar = FALSE, n_test = 0, start_pars = NULL, control_nonpar = list() ) gjrgarch_ru( rt, orders = c(1, 1), cond_dist = c("norm", "std", "ged", "snorm", "sstd", "sged"), meanspec = mean_spec(), nonparspec = locpol_spec(), use_nonpar = FALSE, n_test = 0, start_pars = NULL, control_nonpar = list() ) egarch_ru( rt, orders = c(1, 1), cond_dist = c("norm", "std", "ged", "snorm", "sstd", "sged"), meanspec = mean_spec(), nonparspec = locpol_spec(), use_nonpar = FALSE, n_test = 0, start_pars = NULL, control_nonpar = list() )
rt |
the input time series to fit the model to ordered from
past to present; can also be a |
orders |
the ARCH and GARCH orders of the model as a two-element numeric vector. |
cond_dist |
a single-element character vector with the conditional distribution to consider. |
meanspec |
an object of class "mean_spec"; indicates the specifications for the model in the conditional mean. |
nonparspec |
an object of class |
use_nonpar |
a logical indicating whether or not to implement a
semiparametric extension of the volatility model defined through |
n_test |
a single numerical value indicating, how many observations
at the end of |
start_pars |
a named list with starting parameters. |
control_nonpar |
a list containing changes to the arguments
for the hyperparameter estimation algorithm in the nonparametric
scale function estimation for
|
For most details, please see the documentation of the rugarch package
(Ghalanos, 2024).
These functions also provide an extension, so that a nonparametric,
smooth scale function in the unconditional standard deviation
can be estimated before the parametric step.
If use_nonpar = TRUE,
meanspec is omitted and before fitting a zero-mean model in the
conditional volatility following the remaining function arguments, a smooth scale function,
i.e. a function representing the unconditional standard deviation over time,
is being estimated following the specifications in nonparspec and
control_nonpar. This preliminary step stabilizes the input
series rt, as long-term changes in the unconditional variance
are being estimated and removed before the parametric step using
tsmooth. control_nonpar can be adjusted following
to make changes to the arguments of tsmooth
for short-memory specifications. These arguments specify settings
for the automated bandwidth selection algorithms implemented by this
function. By default, we use the settings
Mcf = "NP", InfR = "Nai",
bStart = 0.15, bvc = "Y", cb = 0.05, and
method = "lpr" for tsmooth.
locpol_spec passed to nonparspec handles
more direct settings of the local polynomial smoother itself. See
the documentation for these functions to get a detailed overview
of these settings. Assume to be the observed series, where
,
then , with being the arithmetic
mean over the observed , is computed and subsequently
. The subtraction of
is necessary so that are all different from zero
almost surely. Once are available, its trend ,
with as the rescaled time on the interval , is
being estimated using
tsmoothlm and denoted here by
. Then from
obtain ,
and obtain the estimated scale function as
.
The stabilized / standardized version of the series
is then , to which
a purely parametric volatility model following the remaining function arguments
is then
fitted. The estimated volatility at a given time point is then
the product of the estimate of the corresponding scale function value
and of the estimated conditional standard deviation (following the parametric
model part) for that same time point. See for example Feng et al. (2022)
or Letmathe et al. (2023) for more information on the semiparametric extension
of volatility models.
A list with the following named elements is returned.
pars:a named numeric vector with the parameter estimates.
se:a named numeric vector with the obtained standard errors in accordance with the parameter estimates.
vcov_mat:the variance-covariance matrix of the parameter estimates with named columns and rows.
rt:the input object rt (or at least the training data, if n_test is greater than zero); if rt was a "zoo" or "ts" object, the formatting is kept.
cmeans:the estimated conditional means; if rt was a "zoo" or "ts" object, the formatting is also applied to cmeans.
sigt:the estimated conditional standard deviations (or for use_nonpar = TRUE the estimated total
volatilities, i.e. scale function value times conditional standard deviation); if rt was a "zoo" or "ts" object, the formatting is also applied to sigt.
etat:the obtained residuals; if rt was a "zoo" or "ts" object, the formatting is also applied to etat.
orders:a two-element numeric vector stating the considered model orders.
cond_dist:a character value stating the conditional distribution considered in the model fitting.
llhood:the log-likelihood value obtained at the optimal parameter combination.
inf_criteria:a named two-element numeric vector with the corresponding AIC (first element) and BIC (second element) of the fitted model.
rugarch_model:the estimation object returned by ugarchfit() of the rugarch package (Ghalanos, 2024).
meanspec:the settings for the model in the conditional mean; is an object
of class "mean_spec" that is identical to the object passed to the input argument
meanspec.
test_obs:the observations at the end up the input rt reserved for
testing following n_test.
scale_fun:the estimated scale function values, if use_nonpar = TRUE, otherwise
NULL; formatting of rt is reused.
nonpar_model:the estimation object returned by tsmoothlm for
use_nonpar = TRUE.
Feng, Y., Gries, T., Letmathe, S., & Schulz, D. (2022). The smoots Package in R for Semiparametric Modeling of Trend Stationary Time Series. The R Journal, 14(1), 182-195. URL: https://journal.r-project.org/articles/RJ-2022-017/.
Ghalanos, A. (2024). rugarch: Univariate GARCH models. R package
version 1.5-3. DOI: 10.32614/CRAN.package.rugarch.
Letmathe, S., Beran, J., & Feng, Y. (2023). An extended exponential SEMIFAR model with application in R. Communications in Statistics - Theory and Methods, 53(22), 7914–7926. DOI: 10.1080/03610926.2023.2276049.
est <- gjrgarch_ru(SP500) est@pars est@se plot(est@sigt)est <- gjrgarch_ru(SP500) est@pars est@se plot(est@sigt)
Display estimation results from the EGARCH family in a convenient way in the console.
## S4 method for signature 'fEGarch_fit_egarch' show(object) ## S4 method for signature 'fEGarch_fit_loggarch' show(object) ## S4 method for signature 'fEGarch_fit_aparch' show(object) ## S4 method for signature 'fEGarch_fit_gjrgarch' show(object) ## S4 method for signature 'fEGarch_fit_tgarch' show(object) ## S4 method for signature 'fEGarch_fit_garch' show(object) ## S4 method for signature 'fEGarch_fit_fiaparch' show(object) ## S4 method for signature 'fEGarch_fit_figjrgarch' show(object) ## S4 method for signature 'fEGarch_fit_fitgarch' show(object) ## S4 method for signature 'fEGarch_fit_figarch' show(object) ## S4 method for signature 'fEGarch_fit_rugarch_wrapper' show(object) ## S4 method for signature 'fEGarch_distr_est' show(object)## S4 method for signature 'fEGarch_fit_egarch' show(object) ## S4 method for signature 'fEGarch_fit_loggarch' show(object) ## S4 method for signature 'fEGarch_fit_aparch' show(object) ## S4 method for signature 'fEGarch_fit_gjrgarch' show(object) ## S4 method for signature 'fEGarch_fit_tgarch' show(object) ## S4 method for signature 'fEGarch_fit_garch' show(object) ## S4 method for signature 'fEGarch_fit_fiaparch' show(object) ## S4 method for signature 'fEGarch_fit_figjrgarch' show(object) ## S4 method for signature 'fEGarch_fit_fitgarch' show(object) ## S4 method for signature 'fEGarch_fit_figarch' show(object) ## S4 method for signature 'fEGarch_fit_rugarch_wrapper' show(object) ## S4 method for signature 'fEGarch_distr_est' show(object)
object |
an object returned by one of this package's fitting functions,
for example |
Nothing is returned. Results are printed in the R-console.
An alternative to sigt,fEGarch_fit-method to extract
fitted conditional standard deviations from an estimation object
in this package.
## S4 method for signature 'fEGarch_fit' sigma(object) ## S4 method for signature 'fEGarch_forecast' sigma(object)## S4 method for signature 'fEGarch_fit' sigma(object) ## S4 method for signature 'fEGarch_forecast' sigma(object)
object |
an object either of class |
Extract fitted conditional standard deviations from an estimation object in this package.
The element within the input object with name sigt is returned.
Depending on the element that can be a numeric vector, an object of
class "zoo" or a numeric matrix.
window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") model <- fEGarch(egarch_spec(), rt, n_test = 250) sigma(model)window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") model <- fEGarch(egarch_spec(), rt, n_test = 250) sigma(model)
Apply a sign bias test to check the standardized residuals of a fitted model from this package for remaining significant sign effects.
## S4 method for signature 'fEGarch_fit' sign_bias_test(object, silent = FALSE, ...)## S4 method for signature 'fEGarch_fit' sign_bias_test(object, silent = FALSE, ...)
object |
an object |
silent |
a logical value reflecting whether or not test results should be printed in a well-formatted manner to the console. |
... |
currently without use. |
Returns a numeric matrix invisibly.
window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") spec <- fEGarch_spec() model <- fEGarch(spec, rt) sign_bias_test(model)window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") spec <- fEGarch_spec() model <- fEGarch(spec, rt) sign_bias_test(model)
Draw random samples from a normal distribution, -distribution,
generalized error distribution, or their skewed variants (all standardized
to have mean zero and variance one).
rnorm_s(n) rstd_s(n, df = 10000) rged_s(n, shape = 2) rsged_s(n, shape = 2, skew = 1) rald_s(n, P = 8) rsnorm_s(n, skew = 1) rsstd_s(n, df = 10000, skew = 1) rsald_s(n, P = 8, skew = 1)rnorm_s(n) rstd_s(n, df = 10000) rged_s(n, shape = 2) rsged_s(n, shape = 2, skew = 1) rald_s(n, P = 8) rsnorm_s(n, skew = 1) rsstd_s(n, df = 10000, skew = 1) rsald_s(n, P = 8, skew = 1)
n |
the number of observations to draw. |
df |
the degrees of freedom for a (skewed) |
shape |
the shape parameter for a (skewed) generalized error distribution. |
skew |
the skewness parameter in the skewed distributions. |
P |
the number of Laplace distributions (minus 1) to derive the arithmetic mean from as the basis for a (skewed) average Laplace (AL) distribution distribution. |
Draw random samples from a normal distribution, -distribution,
generalized error distribution, an average Laplace distribution,
or their skewed variants (all standardized to have mean zero and
variance one).
These functions return a numeric vector of length n.
rnorm_s(10) rsstd_s(10, df = 7, skew = 0.9)rnorm_s(10) rsstd_s(10, df = 7, skew = 0.9)
A "zoo" object that contains the daily log-returns of the
S&P 500 (Standard and Poor's 500) index from January 04, 2000,
until November 30, 2024.
SP500SP500
An object of class zoo of length 6267.
The data was obtained from Yahoo Finance
(accessed: 2024-12-01) and then transformed into a time series
"zoo" object using R.
https://finance.yahoo.com/quote/^GSPC/
A collection of generics for accessors of the model specification objects.
orders(x) powers(x) long_memo(x) modulus(x) cond_dist(x) include_mean(x) orders(x) <- value powers(x) <- value long_memo(x) <- value modulus(x) <- value cond_dist(x) <- value include_mean(x) <- valueorders(x) powers(x) long_memo(x) modulus(x) cond_dist(x) include_mean(x) orders(x) <- value powers(x) <- value long_memo(x) <- value modulus(x) <- value cond_dist(x) <- value include_mean(x) <- value
x |
the input object or object to modify. |
value |
the value to modify the object |
These generics are intended to provide a basis to construct methods
for adjusting the the output of model specification objects like
egarch_spec().
These generics themselves do not return anything and are just the foundation for more sophisticated methods.
"base_garch_spec" and "egarch_spec"
Access and change elements in objects of class "egarch_spec".
The method names represent the name of the element to access /
manipulate.
## S4 method for signature 'base_garch_spec' orders(x) ## S4 method for signature 'egarch_type_spec' powers(x) ## S4 method for signature 'base_garch_spec' long_memo(x) ## S4 method for signature 'egarch_type_spec' modulus(x) ## S4 method for signature 'base_garch_spec' cond_dist(x) ## S4 replacement method for signature 'base_garch_spec' orders(x) <- value ## S4 replacement method for signature 'egarch_type_spec' powers(x) <- value ## S4 replacement method for signature 'base_garch_spec' long_memo(x) <- value ## S4 replacement method for signature 'egarch_type_spec' modulus(x) <- value ## S4 replacement method for signature 'base_garch_spec' cond_dist(x) <- value## S4 method for signature 'base_garch_spec' orders(x) ## S4 method for signature 'egarch_type_spec' powers(x) ## S4 method for signature 'base_garch_spec' long_memo(x) ## S4 method for signature 'egarch_type_spec' modulus(x) ## S4 method for signature 'base_garch_spec' cond_dist(x) ## S4 replacement method for signature 'base_garch_spec' orders(x) <- value ## S4 replacement method for signature 'egarch_type_spec' powers(x) <- value ## S4 replacement method for signature 'base_garch_spec' long_memo(x) <- value ## S4 replacement method for signature 'egarch_type_spec' modulus(x) <- value ## S4 replacement method for signature 'base_garch_spec' cond_dist(x) <- value
x |
the input object or object to modify. |
value |
the value to modify the object |
These methods are intended to be used for accessing or manipulating
individual elements of objects of class "egarch_spec".
These methods either return an object of class "egarch_type_spec"
or "loggarch_type_spec" or the corresponding element of
object of such class objects.
test_obj <- egarch_spec() orders(test_obj) orders(test_obj) <- c(2, 1) orders(test_obj)test_obj <- egarch_spec() orders(test_obj) orders(test_obj) <- c(2, 1) orders(test_obj)
Wrappers of fEGarch_spec() that create
specifications of specific submodels of the broad
EGARCH family.
megarch_spec( orders = c(1, 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald") ) fimegarch_spec( orders = c(1, 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald") ) egarch_spec( orders = c(1, 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald") ) fiegarch_spec( orders = c(1, 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald") ) mloggarch_spec( orders = c(1, 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald") ) fimloggarch_spec( orders = c(1, 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald") ) loggarch_spec( orders = c(1, 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald") ) filoggarch_spec( orders = c(1, 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald") )megarch_spec( orders = c(1, 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald") ) fimegarch_spec( orders = c(1, 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald") ) egarch_spec( orders = c(1, 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald") ) fiegarch_spec( orders = c(1, 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald") ) mloggarch_spec( orders = c(1, 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald") ) fimloggarch_spec( orders = c(1, 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald") ) loggarch_spec( orders = c(1, 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald") ) filoggarch_spec( orders = c(1, 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald") )
orders |
a two-element numeric vector with the model orders. |
cond_dist |
a character value stating the underlying
conditional distribution to consider; available are a normal
distribution ( |
Available are shortcut specification functions for
EGARCH egarch_spec(), FIEGARCH fiegarch_spec(),
MEGARCH megarch_spec(), Log-GARCH loggarch_spec(),
FILog-GARCH filoggarch_spec(), MLog-GARCH mloggarch_spec(),
FIMEGARCH fimegarch_spec() and
FIMLog-GARCH fimloggarch_spec().
The following descriptions are following the descriptions in the
documentation of the more general fEGarch_spec(). Please go there
first to understand the following descriptions on the arguments of
fEGarch_spec() to obtain these wrappers.
model_type = "egarch", long_memo = FALSE,
powers = c(1, 1), modulus = c(FALSE, FALSE)
model_type = "egarch", long_memo = TRUE,
powers = c(1, 1), modulus = c(FALSE, FALSE)
model_type = "egarch", long_memo = FALSE,
powers = c(0, 1), modulus = c(TRUE, FALSE)
model_type = "loggarch", long_memo = FALSE
model_type = "loggarch", long_memo = TRUE
model_type = "egarch", long_memo = FALSE,
powers = c(0, 0), modulus = c(TRUE, TRUE)
model_type = "egarch", long_memo = TRUE,
powers = c(0, 0), modulus = c(TRUE, TRUE)
model_type = "egarch", long_memo = TRUE,
powers = c(0, 1), modulus = c(TRUE, FALSE)
Depending on the spec-fun function, either an object of class
"egarch-type-spec" or "loggarch-type-spec" is returned.
spec <- megarch_spec(cond_dist = "std")spec <- megarch_spec(cond_dist = "std")
Fit a TGARCH model under the six most common and further conditional distributions to observed data using quasi maximum-likelihood estimation.
tgarch( rt, orders = c(1, 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), meanspec = mean_spec(), Drange = c(0, 1), nonparspec = locpol_spec(), use_nonpar = FALSE, n_test = 0, start_pars = NULL, LB = NULL, UB = NULL, control = list(), control_nonpar = list(), mean_after_nonpar = FALSE, parallel = TRUE, ncores = max(1, future::availableCores() - 1), trunc = "none", presample = 50, Prange = c(1, 5), skip_vcov = FALSE )tgarch( rt, orders = c(1, 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), meanspec = mean_spec(), Drange = c(0, 1), nonparspec = locpol_spec(), use_nonpar = FALSE, n_test = 0, start_pars = NULL, LB = NULL, UB = NULL, control = list(), control_nonpar = list(), mean_after_nonpar = FALSE, parallel = TRUE, ncores = max(1, future::availableCores() - 1), trunc = "none", presample = 50, Prange = c(1, 5), skip_vcov = FALSE )
rt |
the observed series ordered from past to present; can be
a numeric vector, a |
orders |
a two-element numeric vector containing the two model
orders |
cond_dist |
the conditional distribution to consider as a
character object; the default is a conditional normal distribution
|
meanspec |
an object of class "mean_spec"; indicates the specifications for the model in the conditional mean. |
Drange |
a two-element numeric vector that indicates the boundaries
of the interval over which to search for the fractional differencing
parameter |
nonparspec |
an object of class |
use_nonpar |
a logical indicating whether or not to implement a
semiparametric extension of the volatility model defined through |
n_test |
a single numerical value indicating, how many observations
at the end of |
start_pars |
the starting parameters for the numerical optimization
routine; should be of the same length as the parameter output vector
within the output object (also keeping the same order); for |
LB |
the lower boundaries of the parameters in the numerical optimization
routine; should be of the same length as the parameter output vector
within the output object (also keeping the same order); for |
UB |
the upper boundaries of the parameters in the numerical optimization
routine; should be of the same length as the parameter output vector
within the output object (also keeping the same order); for |
control |
a list that is passed to |
control_nonpar |
a list containing changes to the arguments
for the hyperparameter estimation algorithm in the nonparametric
scale function estimation for
|
mean_after_nonpar |
only for |
parallel |
only relevant for a (skewed) average Laplace (AL)
distribution, i.e.
if |
ncores |
only relevant for a (skewed) average Laplace (AL)
distribution, i.e.
if |
trunc |
a positive integer indicating the finite truncation length of the
infinite-order polynomials of the infinite-order representations of the
long-memory model parts; the character |
presample |
the presample length for initialization (for extended EGARCH- / Log-GARCH-type models only relevant for the FARIMA-part, as series in log-transformed conditional variance are initialized by zero). |
Prange |
a two-element vector that indicates the search boundaries for
the parameter |
skip_vcov |
a logical indicating whether or not to skip the computation of the variance-covariance matrix of the parameter estimators and therefore also standard error computation. |
Let , with as the
time index, be a theoretical time series that follows
Here, means that the innovations
are independent and identically distributed (iid) with mean zero
and variance one, whereas are the conditional standard
deviations in .
Moreover, , , , ,
are real-valued coefficients.
and are the model orders definable through the argument orders,
where is the first element and is the second element in the
argument. In addition, we have as a
real-valued parameter and . is the intercept. It is assumed that
all and are non-negative.
See also the reference section for sources on the TGARCH model (Zakoian, 1994), the more general APARCH (Ding et al., 1993) and the FIAPARCH (Tse, 1998) models.
In the current package version, standard errors of parameter estimates are
computed from the Hessian at the optimum of the log-likelihood using
hessian. To ensure numerical stability and
applicability to a huge variety of differently scaled data, parametric
models are first fitted to data that is scaled to have sample variance
1. Parameter estimates and other quantities are then either
retransformed or recalculated afterwards for the original data.
For a conditional average Laplace distribution, an optimal model for each
distribution parameter from 1 to 5 is estimated (assuming that
is then fixed to the corresponding value). Afterwards, is then
estimated by selecting the estimated model among the five fitted models that
has the largest log-likelihood. The eight models are, by default, fitted
simultaneously using parallel programming techniques (see also the arguments
parallel and ncores, which are only relevant for a conditional
average Laplace distribution). After the optimal model (including
the estimate of called ) has been determined,
is seen as fixed to obtain the standard errors via the Hessian matrix for the
estimates of the continuous parameters. A standard error for is therefore
not obtained and the ones obtained for the remaining estimates do not account
for .
An ARMA-TGARCH or a FARIMA-TGARCH can be fitted by adjusting the
argument meanspec correspondingly.
As an alternative, a semiparametric extension of the pure models
in the conditional variance can be implemented. If use_nonpar = TRUE,
meanspec is omitted and before fitting a model in the
conditional volatility following the remaining function arguments, a smooth scale function,
i.e. a function representing the unconditional standard deviation over time,
is being estimated following the specifications in nonparspec and
control_nonpar. This preliminary step stabilizes the input
series rt, as long-term changes in the unconditional variance
are being estimated and removed before the parametric step using
tsmooth. control_nonpar can be adjusted following
to make changes to the arguments of tsmooth
for long-memory specifications. These arguments specify settings
for the automated bandwidth selection algorithms implemented by this
function. By default, we use the settings
InfR = "Nai",
bStart = 0.15, cb = 0.05, and
method = "lpr" for tsmooth.
locpol_spec passed to nonparspec handles
more direct settings of the local polynomial smoother itself. See
the documentation for these functions to get a detailed overview
of these settings. Assume to be the observed series, where
,
then , with being the arithmetic
mean over the observed , is computed and subsequently
. The subtraction of
is necessary so that are all different from zero
almost surely. Once are available, its trend ,
with as the rescaled time on the interval , is
being estimated using
tsmoothlm and denoted here by
. Then from
obtain ,
and obtain the estimated scale function as
.
The stabilized / standardized version of the series
is then , to which
a purely parametric volatility model following the remaining function arguments
is then
fitted. The estimated volatility at a given time point is then
the product of the estimate of the corresponding scale function value
and of the estimated conditional standard deviation (following the parametric
model part) for that same time point. See for example Feng et al. (2022)
or Letmathe et al. (2023) for more information on the semiparametric extension
of volatility models.
The order for manual settings of start_pars, LB and UB
is crucial. The correct order is: , ,
,,,
, ,
, shape parameter,
skewness parameter. Depending on the exact model specification,
parameters irrelevant for the specification at hand should be dropped
in start_pars, LB and UB.
An object of S4-class "fEGarch_fit_tgarch"
is returned. It contains the following elements.
pars:a named numeric vector with the parameter estimates.
se:a named numeric vector with the obtained standard errors in accordance with the parameter estimates.
vcov_mat:the variance-covariance matrix of the parameter estimates with named columns and rows.
rt:the input object rt (or at least the training data, if n_test is greater than zero);
if rt was a "zoo" or "ts" object, the formatting is kept.
cmeans:the estimated conditional means; if rt was a "zoo" or "ts" object, the formatting is also applied to cmeans.
sigt:the estimated conditional standard deviations (or for use_nonpar = TRUE the estimated total
volatilities, i.e. scale function value times conditional standard deviation); if rt was a "zoo" or "ts" object, the formatting is also applied to sigt.
etat:the obtained residuals; if rt was a "zoo" or "ts" object, the formatting is also applied to etat.
orders:a two-element numeric vector stating the considered model orders.
cond_dist:a character value stating the conditional distribution considered in the model fitting.
long_memo:a logical value stating whether or not long memory was considered in the model fitting.
llhood:the log-likelihood value obtained at the optimal parameter combination.
inf_criteria:a named two-element numeric vector with the corresponding AIC (first element) and BIC (second element) of the fitted parametric model part; for purely parametric models, these criteria are valid for the entire model; for semiparametric models, they are only valid for the parametric step and are not valid for the entire model.
meanspec:the settings for the model in the conditional mean; is an object
of class "mean_spec" that is identical to the object passed to the input argument
meanspec.
test_obs:the observations at the end up the input rt reserved for
testing following n_test.
scale_fun:the estimated scale function values, if use_nonpar = TRUE, otherwise
NULL; formatting of rt is reused.
nonpar_model:the estimation object returned by tsmooth for
use_nonpar = TRUE.
trunc:the input argument trunc.
Ding, Z., Granger, C. W. J., & Engle, R. F. (1993). A long memory property of stock market returns and a new model. Journal of Empirical Finance, 1(1): 83-106. DOI: 10.1016/0927-5398(93)90006-D.
Feng, Y., Gries, T., Letmathe, S., & Schulz, D. (2022). The smoots Package in R for Semiparametric Modeling of Trend Stationary Time Series. The R Journal, 14(1), 182-195. URL: https://journal.r-project.org/articles/RJ-2022-017/.
Letmathe, S., Beran, J., & Feng, Y. (2023). An extended exponential SEMIFAR model with application in R. Communications in Statistics - Theory and Methods, 53(22), 7914–7926. DOI: 10.1080/03610926.2023.2276049.
Tse, Y. K. (1998). The conditional heteroskedasticity of the yen-dollar exchange rate. Journal of Applied Econometrics, 13(1): 49-55. DOI: 10.1002/(SICI)1099-1255(199801/02)13:1<49::AID-JAE459>3.0.CO;2-O.
Zakoian, J.-M. (1994). Threshold heteroskedastic models. Journal of Economic Dynamics and Control, 18(5): 931-955. DOI: 10.1016/0165-1889(94)90039-6.
window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") model <- tgarch(rt) modelwindow.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") model <- tgarch(rt) model
A streamlined simulation function to simulate from TGARCH models.
tgarch_sim( pars = list(mu = 0, ar = numeric(0), ma = numeric(0), D = 0, omega = 4e-04, phi = 0.05, beta = 0.8, gamma = 0.1, df = 10, shape = 2, P = 3, skew = 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), n = 1000, nstart = 5000, trunc = "none" )tgarch_sim( pars = list(mu = 0, ar = numeric(0), ma = numeric(0), D = 0, omega = 4e-04, phi = 0.05, beta = 0.8, gamma = 0.1, df = 10, shape = 2, P = 3, skew = 1), cond_dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), n = 1000, nstart = 5000, trunc = "none" )
pars |
a named list with the parameter specifications; the user can provide a named list with only the settings they would like to adjust relative to the default settings. |
cond_dist |
a one-element character vector specifying the conditional distribution to consider. |
n |
the number of observations to return. |
nstart |
the number of burn-in observations to simulate before
the final |
trunc |
a truncation for the finite-order coefficient series
in long-memory models; can either be the character |
See the documentation on tgarch for information
on the TGARCH model. This function provides
an easy way to simulate from these models.
A list with four elements is returned: rt are the simulated
observations, etat are the underlying innovations,
sigt are the correspondingly simulated conditional
standard deviations, and cmeans are the simulated
conditional means. These four elements are formatted as
"ts" class time series objects.
sim <- tgarch_sim(n = 1000) mat <- do.call(cbind, sim) plot(mat, main = "")sim <- tgarch_sim(n = 1000) mat <- do.call(cbind, sim) plot(mat, main = "")
Generic functions to build backtesting methods from.
trafflight_test(object, ...) uncond_cov_test(object, ...) indep_test(object, ...) cond_cov_test(object, ...) cov_tests(object, ...) backtest_suite(object, ...) WAD(object, ...)trafflight_test(object, ...) uncond_cov_test(object, ...) indep_test(object, ...) cond_cov_test(object, ...) cov_tests(object, ...) backtest_suite(object, ...) WAD(object, ...)
object |
the generics are currently without use. |
... |
the generics are currently without use. |
The generics are currently without use.
The generics are currently without use, can therefore not be called and thus don't produce results.
Run traffic light tests for value at risk (VaR) and expected shortfall (ES) as well as a selection of coverage and independence tests for VaR.
## S4 method for signature 'fEGarch_risk' trafflight_test(object, silent = FALSE, ...) ## S4 method for signature 'fEGarch_risk' uncond_cov_test(object, silent = FALSE, ...) ## S4 method for signature 'fEGarch_risk' indep_test(object, silent = FALSE, ...) ## S4 method for signature 'fEGarch_risk' cond_cov_test(object, silent = FALSE, ...) ## S4 method for signature 'fEGarch_risk' cov_tests(object, silent = FALSE, ...) ## S4 method for signature 'fEGarch_risk' backtest_suite(object, silent = FALSE, ...) ## S4 method for signature 'fEGarch_risk' WAD(object, silent = FALSE, ...)## S4 method for signature 'fEGarch_risk' trafflight_test(object, silent = FALSE, ...) ## S4 method for signature 'fEGarch_risk' uncond_cov_test(object, silent = FALSE, ...) ## S4 method for signature 'fEGarch_risk' indep_test(object, silent = FALSE, ...) ## S4 method for signature 'fEGarch_risk' cond_cov_test(object, silent = FALSE, ...) ## S4 method for signature 'fEGarch_risk' cov_tests(object, silent = FALSE, ...) ## S4 method for signature 'fEGarch_risk' backtest_suite(object, silent = FALSE, ...) ## S4 method for signature 'fEGarch_risk' WAD(object, silent = FALSE, ...)
object |
an object of class |
silent |
a logical value indicating whether or not to print test results in a nicely formatted manner to the console. |
... |
currently without use. |
backtest_suite runs all the other backtesting methods.
cov_tests runs all of uncond_cov_test,
indep_test and cond_cov_test.
Traffic light tests (trafflight_test):
Given an input object object of class "fEGarch_risk",
traffic light tests for value at risk (VaR) and expected shortfall (ES)
are applied to the individual risk measure series in the object. Note
that in order for a traffic light test in context of ES being applicable,
the corresponding VaR series of the same confidence level must also
be present in object. If this is not fulfilled,
messages will be printed to the console, making the user aware of
this issue.
Let the number of test observations be denoted by
and let , ,
be the test returns. are the (one-step rolling) VaR point forecasts
for the same period with confidence level . Denote by
an indicator that equals 1, whenever , and
0 otherwise, and define . are assumed
to follow a binomial distribution with probability for any .
Then is computed as the cumulative probability of observing
under . The forecasted VaR series is then classified following . If
, then it is sorted into the green zone, if ,
then the series belongs to the yellow zone, and if ,
then the class of the VaR series is the red zone (Basel Committee on Banking Supervision, 1996).
The traffic light test for the ES (Costanzino and Curran, 2018) uses a similar classification system based on the severity of breaches
where is the (fitted) cumulative distribution function of the
standardized innovations and with as the standardized residuals
of a fitted GARCH-type model (or of its semiparametric extension).
Then with
and
. The cumulative
probability of observing a severity of breaches of or less can
be computed and classified in the same way as for the VaR traffic light test
using this asymptotic distribution.
Weighted Absolute Deviation (WAD) (WAD):
Following the standard computation of the 99%-VaR, the 97.5%-VaR and the
97.5%-ES for the traffic light tests, the WAD criterion takes all of these
into account and summarizes them into one numeric value. Let be the
observed breaches for the 99%-VaR for the test set and let be the
corresponding expected number of breaches. and are to
understood analogously for the 97.5%-VaR. is then the severity of
breaches of the 97.5%-ES (i.e. it is equal to from before) and
is from before. Then
See also Letmathe et al. (2022) for further information.
Coverage and independence tests (cov_tests):
Following Christoffersen (1998), the backtesting suite also includes
a selection of coverage and independence tests regarding the VaR. Let the number of test
observations be denoted by and let , ,
be the test returns. are the (one-step rolling) VaR point forecasts
for the same period with confidence level . Furthermore, define
to be an indicator that equals , whenever and
zero otherwise. Let and . Furthermore,
and as well as
and
In addition, we require , and ,
to be other indicators that equal 1, whenever and
simultaneously . Per consequence,
and .
Moreover, and
. Now,
and
Ultimately,
The three test statistics following Christoffersen (1998) are then
where is the test statistic of the unconditional coverage test,
is that of the independence test and
is that of the conditional coverage test.
All methods return a list invisibly. The elements of the list differ
slightly depending on the method. Moreover, for silent = FALSE,
the default, test results are printed to the console.
Basel Committee on Banking Supervision (1996). Supervisory Framework For The Use of "Backtesting" in Conjunction With The Internal Models Approach to Market Risk Capital Requirements. URL: https://www.bis.org/publ/bcbs22.pdf.
Christoffersen, P. F. (1998). Evaluating Interval Forecasts. International Economic Review, 39(4): 841-862. DOI: 10.2307/2527341.
Costanzino, N., & Curran, M. (2018). A Simple Traffic Light Approach to Backtesting Expected Shortfall. Risks, 6(1). DOI: 10.3390/risks6010002.
Letmathe, S., Feng, Y., & Uhde, A. (2022). Semiparametric GARCH models with long memory applied to Value at Risk and Expected Shortfall. Journal of Risk, 25(2). DOI: 10.21314/JOR.2022.044.
window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") model <- fEGarch(egarch_spec(), rt, n_test = 250) # parallel = FALSE for better compatibility with CRAN checks; # should be set to TRUE for speed boost fcast <- predict_roll(model, refit_after = 50, parallel = FALSE) risk <- measure_risk(fcast, measure = c("VaR", "ES"), level = c(0.95, 0.975, 0.99)) trafflight_test(risk) cov_tests(risk) backtest_suite(risk)window.zoo <- get("window.zoo", envir = asNamespace("zoo")) rt <- window.zoo(SP500, end = "2002-12-31") model <- fEGarch(egarch_spec(), rt, n_test = 250) # parallel = FALSE for better compatibility with CRAN checks; # should be set to TRUE for speed boost fcast <- predict_roll(model, refit_after = 50, parallel = FALSE) risk <- measure_risk(fcast, measure = c("VaR", "ES"), level = c(0.95, 0.975, 0.99)) trafflight_test(risk) cov_tests(risk) backtest_suite(risk)
A "ts" object that contains the monthly inflation rate of
the UK from January 1956 to December 2000. It is the growth rate
of the consumer price index from the previous period.
UKinflationUKinflation
An object of class ts of length 540.
The data was obtained from the databank of the Federal
Reserve Bank of St. Louis
(accessed: 2025-06-17) and then transformed into a time series
"ts" object using R.
https://fred.stlouisfed.org/series/CPALTT01GBM657N
Compute the value at risk (VaR) and the expected shortfall (ES) numerically for the standardized distributions available in this package. These quantiles can then be used to obtain the conditional VaR and ES following GARCH-type models.
VaR_calc( level = 0.99, dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), ... ) ES_calc( level = 0.975, dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), ... )VaR_calc( level = 0.99, dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), ... ) ES_calc( level = 0.975, dist = c("norm", "std", "ged", "ald", "snorm", "sstd", "sged", "sald"), ... )
level |
a numeric vector with the confidence level(s) to calculate
the VaR or ES for; the quantiles are the VaR or ES
computed at one minus the input level; the result is thus with negative sign
for common |
dist |
a single character value (or the default vector) that specifies the distribution to consider (all distributions are considered to be standardized with mean zero and variance one). |
... |
further arguments to consider for the distributions;
for |
The VaR is found numerically using numerical root finding
via uniroot (of the stats package), whereas the ES is obtained through
numerical integration, where firstly the VaR at the corresponding
confidence level is computed using VaR_calc, and where
subsequently integrate (of the stats package) is
used at the tail of the distribution.
In detail, let be the probability density function (pdf) of a standardized random
variable with mean zero and variance one. Without the need to state a
cumulative distribution function (cdf) mathematically, we can define it in R numerically
by integrating over from -Inf to some quantile x using
integrate. To then find a quantile for a given cumulative
probability, we can use uniroot to find the quantile,
where the numerical cdf function minus the set cumulative probability equals
zero. This way, a numerical VaR can be found.
On the other hand, a numerical ES for a (continuous) random variable with mean zero and variance one follows the alternative definition of the ES
where , usually 0.99 or 0.975, is the confidence level,
is the VaR at the same . Using the previous
approach, can be easily identified. Then, in R,
a function can also be defined easily. Ultimately, only
integrate needs to be applied from -Inf to the
corresponding VaR as the upper bound to the function . The resulting numerical
integral is then divided by .
Returns a numeric vector of the same length as the input
argument level.
# 99-percent VaR, normal distribution VaR_calc(level = 0.99, dist = "norm") # 99-percent VaR, t-distribution with df = 10 VaR_calc(level = 0.99, dist = "std", df = 10) # 97.5-percent ES, normal distribution ES_calc(level = 0.975, dist = "norm") # 97.5-percent ES, t-distribution with df = 10 ES_calc(level = 0.975, dist = "std", df = 10)# 99-percent VaR, normal distribution VaR_calc(level = 0.99, dist = "norm") # 99-percent VaR, t-distribution with df = 10 VaR_calc(level = 0.99, dist = "std", df = 10) # 97.5-percent ES, normal distribution ES_calc(level = 0.975, dist = "norm") # 97.5-percent ES, t-distribution with df = 10 ES_calc(level = 0.975, dist = "std", df = 10)