apaARIMA.AutoFit(Series, maxP, maxD, maxQ, Criterion, IncludeConstant)
=apaARIMA.AutoFit(Series, maxP, maxD, maxQ, Criterion, IncludeConstant)Result
Selects the integration order d with sequential KPSS stationarity tests, then fits the best ARIMA(p,d,q) model over a user-defined grid of AR and MA orders using AIC, AICc or BIC, and returns the selected model and key fit statistics. Model selection by information criterion chooses the model with the lowest criterion value, balancing fit against model complexity.
Syntax
Series: n x 1 or 1 x n range containing the time series
maxP: maximum AR order
maxD: maximum integration order; d is chosen by sequential KPSS tests at the 5% level
maxQ: maximum MA order
Criterion: AIC, AICc, or BIC
IncludeConstant: TRUE to include an intercept (d = 0) or a drift (d = 1) (optional, default TRUE). For d ≥ 2 no constant is estimated regardless of this argument, because a constant in the twice or more differenced series would induce a quadratic or higher-order polynomial trend in the forecasts.
Algorithm
The series is flattened to a vector; at least 10 observations are required.
maxP, maxD and maxQ are rounded to integers and must be non-negative.
The integration order d is determined first. Starting with d = 0, the KPSS level-stationarity statistic of the d-times differenced series is computed; if it exceeds the 5% critical value of 0.463 and d < maxD, d is increased by one and the test is repeated. The long-run variance in the KPSS statistic uses a Bartlett kernel with floor(3·√n / 13) lags.
The grid p = 0, …, maxP and q = 0, …, maxQ is then searched at this fixed d. ARIMA(0,0,0) is excluded.
For each admissible model, the parameters are estimated as in apaARIMA.Estimate, but all candidates condition on the first maxP observations of the differenced series, so that every criterion value is computed on the same sample and the values are comparable. The model with the smallest criterion value is selected and re-estimated on its own sample; the reported statistics refer to this re-estimation.
The result contains the best model, the deterministic term type and value, the innovation variance, the log-likelihood, AIC, AICc, BIC, the number of evaluations and the termination reason.
Two-column result table:
BestModel
DeterministicTermType
DeterministicTermValue
InnovationVariance
LogLikelihood
AIC
AICc
BIC
Evaluations
TerminationReason
