| Title: | Parametric Modal ARIMA Models using the SKD Family |
|---|---|
| Description: | Implements parametric modal Autoregressive Integrated Moving Average (ARIMA) models utilizing the Skewed Distribution (SKD) family. Current distributions supported are the Skew-Normal, Skewed Student-t, and Skewed Laplace. The conditional mode is parameterized and optimized via maximum likelihood using analytical gradients. Includes comprehensive residual diagnostics, robustness options (heavy tails, asymmetry), robust parametric bootstrap prediction intervals, and classical asymptotic inference via the Fisher Information matrix. Methods are described in Galarza, C.E., Lachos, V.H., Cabral, C.R.B., & Castro, L.M. (2017) <doi:10.1002/sta4.140>. |
| Authors: | Christian Galarza [aut, cre] |
| Maintainer: | Christian Galarza <[email protected]> |
| License: | GPL-3 |
| Version: | 0.1.0 |
| Built: | 2026-05-12 21:23:55 UTC |
| Source: | https://github.com/cran/ModalForecast |
Automatic selection of Parametric Modal ARIMA model
auto.modal.arima( y, d = NA, max.p = 5, max.q = 5, ic = c("aic", "bic"), dist = c("normal", "t", "laplace") )auto.modal.arima( y, d = NA, max.p = 5, max.q = 5, ic = c("aic", "bic"), dist = c("normal", "t", "laplace") )
y |
numeric vector or time series of observations |
d |
Integer, degree of differencing. If NA, it's determined automatically. |
max.p |
Maximum AR order |
max.q |
Maximum MA order |
ic |
Information criterion to be used in model selection ("aic", "bic") |
dist |
Character string specifying the error distribution.
|
This function performs a grid search over AR and MA orders to find the optimal Modal ARIMA model based on the selected information criterion (AIC or BIC).
An object of class modal_arima.
GitHub repository: https://github.com/chedgala/ModalForecast
Galarza, C. E., Lachos, V. H., Cabral, C. R. B., and Castro, L. M. (2017). Robust quantile regression using a generalized class of skewed distributions. Stat, 6(1), 113-130.
library(forecast) # 1. Load Empirical Data (Lynx) data(lynx) y <- log10(lynx) # 2. Find the best SKD Error Distribution (Normal vs T vs Laplace) fit_n <- fit_modal_arima(y, order = c(2, 0, 0), dist = "normal") fit_t <- fit_modal_arima(y, order = c(2, 0, 0), dist = "t") fit_l <- fit_modal_arima(y, order = c(2, 0, 0), dist = "laplace") c(Normal = AIC(fit_n), Student = AIC(fit_t), Laplace = AIC(fit_l)) # 3. Auto Model Selection globally on the winning distribution (Skew-Normal) fit_auto <- auto.modal.arima(y, d=0, max.p=2, max.q=2, dist="normal") # 4. Summary & Inferences summary(fit_auto) # 5. Run residual diagnostics and Envelopes diagnostics(fit_auto) envelope(fit_auto, B=10) # 6. Produce forecasts with multiple prediction bands (alphas) pred <- forecast(fit_auto, h=5, level = c(80, 95)) # 7. Native integration with 'forecast' ecosystem autoplot(pred) accuracy(pred)library(forecast) # 1. Load Empirical Data (Lynx) data(lynx) y <- log10(lynx) # 2. Find the best SKD Error Distribution (Normal vs T vs Laplace) fit_n <- fit_modal_arima(y, order = c(2, 0, 0), dist = "normal") fit_t <- fit_modal_arima(y, order = c(2, 0, 0), dist = "t") fit_l <- fit_modal_arima(y, order = c(2, 0, 0), dist = "laplace") c(Normal = AIC(fit_n), Student = AIC(fit_t), Laplace = AIC(fit_l)) # 3. Auto Model Selection globally on the winning distribution (Skew-Normal) fit_auto <- auto.modal.arima(y, d=0, max.p=2, max.q=2, dist="normal") # 4. Summary & Inferences summary(fit_auto) # 5. Run residual diagnostics and Envelopes diagnostics(fit_auto) envelope(fit_auto, B=10) # 6. Produce forecasts with multiple prediction bands (alphas) pred <- forecast(fit_auto, h=5, level = c(80, 95)) # 7. Native integration with 'forecast' ecosystem autoplot(pred) accuracy(pred)
Provides visual and statistical diagnostics for the residuals of a fitted modal ARIMA model. Produces a comprehensive diagnostic panel including time series plot with fitted modes, ACF/PACF of residuals, QQ-plot for normality, histogram of residuals, and Ljung-Box p-values, all implemented using ggplot2.
diagnostics(object, ...) ## S3 method for class 'modal_arima' diagnostics(object, ...)diagnostics(object, ...) ## S3 method for class 'modal_arima' diagnostics(object, ...)
object |
An object of class |
... |
Additional arguments (unused). |
A list of ggplot objects (invisibly) and draws the panel.
library(forecast) # 1. Load Empirical Data (Lynx) data(lynx) y <- log10(lynx) # 2. Find the best SKD Error Distribution (Normal vs T vs Laplace) fit_n <- fit_modal_arima(y, order = c(2, 0, 0), dist = "normal") fit_t <- fit_modal_arima(y, order = c(2, 0, 0), dist = "t") fit_l <- fit_modal_arima(y, order = c(2, 0, 0), dist = "laplace") c(Normal = AIC(fit_n), Student = AIC(fit_t), Laplace = AIC(fit_l)) # 3. Auto Model Selection globally on the winning distribution (Skew-Normal) fit_auto <- auto.modal.arima(y, d=0, max.p=2, max.q=2, dist="normal") # 4. Summary & Inferences summary(fit_auto) # 5. Run residual diagnostics and Envelopes diagnostics(fit_auto) envelope(fit_auto, B=10) # 6. Produce forecasts with multiple prediction bands (alphas) pred <- forecast(fit_auto, h=5, level = c(80, 95)) # 7. Native integration with 'forecast' ecosystem autoplot(pred) accuracy(pred)library(forecast) # 1. Load Empirical Data (Lynx) data(lynx) y <- log10(lynx) # 2. Find the best SKD Error Distribution (Normal vs T vs Laplace) fit_n <- fit_modal_arima(y, order = c(2, 0, 0), dist = "normal") fit_t <- fit_modal_arima(y, order = c(2, 0, 0), dist = "t") fit_l <- fit_modal_arima(y, order = c(2, 0, 0), dist = "laplace") c(Normal = AIC(fit_n), Student = AIC(fit_t), Laplace = AIC(fit_l)) # 3. Auto Model Selection globally on the winning distribution (Skew-Normal) fit_auto <- auto.modal.arima(y, d=0, max.p=2, max.q=2, dist="normal") # 4. Summary & Inferences summary(fit_auto) # 5. Run residual diagnostics and Envelopes diagnostics(fit_auto) envelope(fit_auto, B=10) # 6. Produce forecasts with multiple prediction bands (alphas) pred <- forecast(fit_auto, h=5, level = c(80, 95)) # 7. Native integration with 'forecast' ecosystem autoplot(pred) accuracy(pred)
Constructs simulation envelopes based on the theoretical distance distributions from the SKD family (Galarza et al., 2017).
envelope(object, ...) ## S3 method for class 'modal_arima' envelope(object, B = 100, ...)envelope(object, ...) ## S3 method for class 'modal_arima' envelope(object, B = 100, ...)
object |
An object of class |
... |
Additional arguments (unused). |
B |
Number of Monte Carlo replications for envelope construction. Default is 100. |
A ggplot object (invisibly) and draws the envelope plot.
Fits a Modal ARIMA model where the conditional mode follows an ARIMA recursion and the innovations follow a member of the SKD (Skewed Distribution) family. Supports the Skew-Normal, Skewed Student-t, and Skewed Laplace distributions.
fit_modal_arima(y, order = c(1, 0, 0), dist = c("normal", "t", "laplace"))fit_modal_arima(y, order = c(1, 0, 0), dist = c("normal", "t", "laplace"))
y |
numeric vector or time series of observations. |
order |
A specification of the non-seasonal part of the ARIMA model: the three components (p, d, q) are the AR order, the degree of differencing, and the MA order. |
dist |
Character string specifying the error distribution from the
SKD family. One of |
An object of class modal_arima containing:
yThe original time series.
orderThe ARIMA order (p,d,q).
coefficientsNamed vector of estimated parameters.
loglikThe maximized log-likelihood.
hessianThe Hessian matrix at the optimum.
convergenceConvergence code from optim.
distThe distribution used ("normal", "t", or "laplace").
GitHub repository: https://github.com/chedgala/ModalForecast
Galarza, C. E., Lachos, V. H., Cabral, C. R. B., and Castro, L. M. (2017). Robust quantile regression using a generalized class of skewed distributions. Stat, 6(1), 113-130.
library(forecast) # 1. Load Empirical Data (Lynx) data(lynx) y <- log10(lynx) # 2. Find the best SKD Error Distribution (Normal vs T vs Laplace) fit_n <- fit_modal_arima(y, order = c(2, 0, 0), dist = "normal") fit_t <- fit_modal_arima(y, order = c(2, 0, 0), dist = "t") fit_l <- fit_modal_arima(y, order = c(2, 0, 0), dist = "laplace") c(Normal = AIC(fit_n), Student = AIC(fit_t), Laplace = AIC(fit_l)) # 3. Auto Model Selection globally on the winning distribution (Skew-Normal) fit_auto <- auto.modal.arima(y, d=0, max.p=2, max.q=2, dist="normal") # 4. Summary & Inferences summary(fit_auto) # 5. Run residual diagnostics and Envelopes diagnostics(fit_auto) envelope(fit_auto, B=10) # 6. Produce forecasts with multiple prediction bands (alphas) pred <- forecast(fit_auto, h=5, level = c(80, 95)) # 7. Native integration with 'forecast' ecosystem autoplot(pred) accuracy(pred)library(forecast) # 1. Load Empirical Data (Lynx) data(lynx) y <- log10(lynx) # 2. Find the best SKD Error Distribution (Normal vs T vs Laplace) fit_n <- fit_modal_arima(y, order = c(2, 0, 0), dist = "normal") fit_t <- fit_modal_arima(y, order = c(2, 0, 0), dist = "t") fit_l <- fit_modal_arima(y, order = c(2, 0, 0), dist = "laplace") c(Normal = AIC(fit_n), Student = AIC(fit_t), Laplace = AIC(fit_l)) # 3. Auto Model Selection globally on the winning distribution (Skew-Normal) fit_auto <- auto.modal.arima(y, d=0, max.p=2, max.q=2, dist="normal") # 4. Summary & Inferences summary(fit_auto) # 5. Run residual diagnostics and Envelopes diagnostics(fit_auto) envelope(fit_auto, B=10) # 6. Produce forecasts with multiple prediction bands (alphas) pred <- forecast(fit_auto, h=5, level = c(80, 95)) # 7. Native integration with 'forecast' ecosystem autoplot(pred) accuracy(pred)
Forecast methodology for Modal ARIMA
## S3 method for class 'modal_arima' forecast( object, h = 10, level = c(80, 95), interval = c("asymptotic", "bootstrap"), npaths = 1000, ... )## S3 method for class 'modal_arima' forecast( object, h = 10, level = c(80, 95), interval = c("asymptotic", "bootstrap"), npaths = 1000, ... )
object |
A modal_arima object. |
h |
The forecast horizon. |
level |
Confidence level for prediction intervals. |
interval |
Method for computing prediction intervals ("asymptotic" or "bootstrap"). |
npaths |
Number of simulated paths for bootstrap intervals. Defaults to 1000. |
... |
Additional arguments. |
A forecast object.
library(forecast) # 1. Load Empirical Data (Lynx) data(lynx) y <- log10(lynx) # 2. Find the best SKD Error Distribution (Normal vs T vs Laplace) fit_n <- fit_modal_arima(y, order = c(2, 0, 0), dist = "normal") fit_t <- fit_modal_arima(y, order = c(2, 0, 0), dist = "t") fit_l <- fit_modal_arima(y, order = c(2, 0, 0), dist = "laplace") c(Normal = AIC(fit_n), Student = AIC(fit_t), Laplace = AIC(fit_l)) # 3. Auto Model Selection globally on the winning distribution (Skew-Normal) fit_auto <- auto.modal.arima(y, d=0, max.p=2, max.q=2, dist="normal") # 4. Summary & Inferences summary(fit_auto) # 5. Run residual diagnostics and Envelopes diagnostics(fit_auto) envelope(fit_auto, B=10) # 6. Produce forecasts with multiple prediction bands (alphas) pred <- forecast(fit_auto, h=5, level = c(80, 95)) # 7. Native integration with 'forecast' ecosystem autoplot(pred) accuracy(pred)library(forecast) # 1. Load Empirical Data (Lynx) data(lynx) y <- log10(lynx) # 2. Find the best SKD Error Distribution (Normal vs T vs Laplace) fit_n <- fit_modal_arima(y, order = c(2, 0, 0), dist = "normal") fit_t <- fit_modal_arima(y, order = c(2, 0, 0), dist = "t") fit_l <- fit_modal_arima(y, order = c(2, 0, 0), dist = "laplace") c(Normal = AIC(fit_n), Student = AIC(fit_t), Laplace = AIC(fit_l)) # 3. Auto Model Selection globally on the winning distribution (Skew-Normal) fit_auto <- auto.modal.arima(y, d=0, max.p=2, max.q=2, dist="normal") # 4. Summary & Inferences summary(fit_auto) # 5. Run residual diagnostics and Envelopes diagnostics(fit_auto) envelope(fit_auto, B=10) # 6. Produce forecasts with multiple prediction bands (alphas) pred <- forecast(fit_auto, h=5, level = c(80, 95)) # 7. Native integration with 'forecast' ecosystem autoplot(pred) accuracy(pred)