| Title: | Forecasting with GARCH |
|---|---|
| Description: | Forecasting with GARCH, using an interface like the forecast package's. |
| Authors: | T. Moudiki [aut, cre] |
| Maintainer: | T. Moudiki <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-05-16 02:29:55 UTC |
| Source: | https://github.com/thierrymoudiki/garchf |
Combines a mean model and a volatility model to produce probabilistic forecasts. Uncertainty is propagated from two sources: simulated innovation draws and simulated volatility paths derived from the variance model's residuals via bootstrap.
condvolf( y, h = 10L, mean_model = forecast::thetaf, sigma_model = forecast::thetaf, innovation = c("empirical", "gaussian", "student"), level = 95, B = 1000L, bootstrap_vol = TRUE, conformal = FALSE, cal_frac = 0.5, residuals_model = forecast::thetaf, ... )condvolf( y, h = 10L, mean_model = forecast::thetaf, sigma_model = forecast::thetaf, innovation = c("empirical", "gaussian", "student"), level = 95, B = 1000L, bootstrap_vol = TRUE, conformal = FALSE, cal_frac = 0.5, residuals_model = forecast::thetaf, ... )
y |
A numeric vector or time series of class |
h |
Forecasting horizon. |
mean_model |
Function to fit the mean model (default: |
sigma_model |
Function to fit the variance model on squared residuals
(default: |
innovation |
Distribution for standardized innovations. One of
|
level |
Confidence level for prediction intervals (default: 95). |
B |
Number of simulated paths (default: 2000). |
bootstrap_vol |
Whether to bootstrap volatility residuals (default: TRUE). If FALSE, uses parametric normal approximation for volatility. |
conformal |
Logical. If |
cal_frac |
Numeric in |
residuals_model |
A function from package forecast, the model adjusted
to residuals for 2-stage forecasting, and only for |
... |
Additional arguments passed to |
A forecast object with components:
xOriginal time series.
meanPoint forecast (mean of simulations).
lowerLower prediction interval bound.
upperUpper prediction interval bound.
levelConfidence level.
simsMatrix of simulated forecast paths (h x B).
modelList containing mean and sigma model fits.
residualsResiduals from the mean model.
standardized_residualsScaled standardized residuals used for innovation fitting.
methodCharacter string describing the method used.
library(forecast) # Basic usage with Google stock data y <- fpp2::goog200 # Gaussian innovations (fastest, often sufficient) fc1 <- condvolf(y, h = 20, innovation = "gaussian") plot(fc1) # Student-t innovations (heavy-tailed) fc2 <- condvolf(y, h = 20, innovation = "student") plot(fc2) # Empirical innovations (non-parametric) fc3 <- condvolf(y, h = 20, innovation = "empirical") plot(fc3) # Using different mean and volatility models fc4 <- condvolf(y, h = 20, mean_model = forecast::thetaf, sigma_model = forecast::ets, innovation = "gaussian") # Compare prediction intervals par(mfrow = c(2, 2)) plot(fc1, main = "Gaussian innovations") plot(fc2, main = "Student-t innovations") plot(fc3, main = "Empirical innovations") plot(fc4, main = "Different mean and volatility models") par(mfrow = c(1, 1))library(forecast) # Basic usage with Google stock data y <- fpp2::goog200 # Gaussian innovations (fastest, often sufficient) fc1 <- condvolf(y, h = 20, innovation = "gaussian") plot(fc1) # Student-t innovations (heavy-tailed) fc2 <- condvolf(y, h = 20, innovation = "student") plot(fc2) # Empirical innovations (non-parametric) fc3 <- condvolf(y, h = 20, innovation = "empirical") plot(fc3) # Using different mean and volatility models fc4 <- condvolf(y, h = 20, mean_model = forecast::thetaf, sigma_model = forecast::ets, innovation = "gaussian") # Compare prediction intervals par(mfrow = c(2, 2)) plot(fc1, main = "Gaussian innovations") plot(fc2, main = "Student-t innovations") plot(fc3, main = "Empirical innovations") plot(fc4, main = "Different mean and volatility models") par(mfrow = c(1, 1))
Similar spirit to forecast::thetaf(), but using rugarch models.
xgarchf( y, h = 10L, model = c("eGARCH", "sGARCH", "gjrGARCH", "apARCH", "iGARCH"), armaOrder = c(1, 1), garchOrder = c(1, 1), distribution.model = c("norm", "std", "ged"), level = c(80, 95), ... )xgarchf( y, h = 10L, model = c("eGARCH", "sGARCH", "gjrGARCH", "apARCH", "iGARCH"), armaOrder = c(1, 1), garchOrder = c(1, 1), distribution.model = c("norm", "std", "ged"), level = c(80, 95), ... )
y |
numeric vector or ts |
h |
forecast horizon |
model |
mean model ("sGARCH", "eGARCH", "gjrGARCH", ...) |
armaOrder |
ARMA order for the conditional mean |
garchOrder |
GARCH order |
distribution.model |
conditional distribution |
level |
confidence level(s) |
... |
Additional parameters passed to |
object of class forecast
## Not run: y <- fpp2::goog200 fit <- xgarchf(y, h = 20, model = "eGARCH") plot(fit) ## End(Not run)## Not run: y <- fpp2::goog200 fit <- xgarchf(y, h = 20, model = "eGARCH") plot(fit) ## End(Not run)