% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/modal_arima.R
\name{fit_modal_arima}
\alias{fit_modal_arima}
\title{Fit a Parametric Modal ARIMA Model using the SKD Family}
\usage{
fit_modal_arima(y, order = c(1, 0, 0), dist = c("normal", "t", "laplace"))
}
\arguments{
\item{y}{numeric vector or time series of observations.}

\item{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.}

\item{dist}{Character string specifying the error distribution from the
SKD family. One of \code{"normal"} (default) for the Skew-Normal,
\code{"t"} for the Skewed Student-t (adds degrees-of-freedom parameter
\code{nu}), or \code{"laplace"} for the Skewed Laplace distribution.}
}
\value{
An object of class \code{modal_arima} containing:
  \describe{
    \item{\code{y}}{The original time series.}
    \item{\code{order}}{The ARIMA order \code{(p,d,q)}.}
    \item{\code{coefficients}}{Named vector of estimated parameters.}
    \item{\code{loglik}}{The maximized log-likelihood.}
    \item{\code{hessian}}{The Hessian matrix at the optimum.}
    \item{\code{convergence}}{Convergence code from \code{optim}.}
    \item{\code{dist}}{The distribution used (\code{"normal"}, \code{"t"}, or \code{"laplace"}).}
  }
}
\description{
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.
}
\note{
GitHub repository: \url{https://github.com/chedgala/ModalForecast}
}
\examples{
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)
}
\references{
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.
}
\seealso{
\code{\link{auto.modal.arima}}
}
