fittestArima {TSPred} | R Documentation |
Automatic ARIMA fitting, prediction and accuracy evaluation
Description
The function predicts and returns the next n consecutive values of a univariate time series using an automatically best fitted ARIMA model. It also evaluates the fitness of the produced model, using AICc, AIC, BIC and logLik criteria, and its prediction accuracy, using the MSE, NMSE, MAPE, sMAPE and maximal error accuracy measures.
Usage
fittestArima(
timeseries,
timeseries.test = NULL,
h = NULL,
na.action = stats::na.omit,
level = c(80, 95),
...
)
Arguments
timeseries |
A vector or univariate time series which contains the values used for fitting an ARIMA model. |
timeseries.test |
A vector or univariate time series containing a
continuation for |
h |
Number of consecutive values of the time series to be predicted. If
|
na.action |
A function for treating missing values in |
level |
Confidence level for prediction intervals. |
... |
Additional arguments passed to the
|
Details
The ARIMA model is automatically fitted by the
auto.arima
function and it is used for prediction by
the forecast
function both in the forecast
package.
The fitness criteria AICc, AIC (AIC
), BIC (BIC
)
and log-likelihood (logLik
) are extracted from the fitted
ARIMA model. Also, the prediction accuracy of the model is computed by means
of MSE (MSE
), NMSE (NMSE
), MAPE
(MAPE
), sMAPE (sMAPE
) and maximal error
(MAXError
) measures.
Value
A list with components:
model |
A list of class "ARIMA"
containing the best fitted ARIMA model. See the |
parameters |
A list
containing the parameters of the best fitted ARIMA model. See the
|
AICc |
Numeric value of the computed AICc criterion of the fitted model. |
AIC |
Numeric value of the computed AIC criterion of the fitted model. |
BIC |
Numeric value of the computed BIC criterion of the fitted model. |
logLik |
Numeric value of the computed log-likelihood of the fitted model. |
pred |
A list with
the components |
MSE |
Numeric value of the resulting MSE error of prediction. |
NMSE |
Numeric value of the resulting NMSE error of prediction. |
MAPE |
Numeric value of the resulting MAPE error of prediction. |
sMAPE |
Numeric value of the resulting sMAPE error of prediction. |
MaxError |
Numeric value of the maximal error of prediction. |
Author(s)
Rebecca Pontes Salles
References
R.J. Hyndman and G. Athanasopoulos, 2013, Forecasting: principles and practice. OTexts.
R.H. Shumway and D.S. Stoffer, 2010, Time Series Analysis and Its Applications: With R Examples. 3rd ed. 2011 edition ed. New York, Springer.
See Also
fittestArimaKF
, fittestLM
,
marimapred
Examples
data(CATS,CATS.cont)
fArima <- fittestArima(CATS[,1],CATS.cont[,1])
#predicted values
pred <- fArima$pred$mean
#model information
cbind(AICc=fArima$AICc, AIC=fArima$AIC, BIC=fArima$BIC,
logLik=fArima$logLik, MSE=fArima$MSE, NMSE=fArima$NMSE,
MAPE=fArima$MSE, sMAPE=fArima$MSE, MaxError=fArima$MaxError)
#plotting the time series data
plot(c(CATS[,1],CATS.cont[,1]),type='o',lwd=2,xlim=c(960,1000),ylim=c(0,200),
xlab="Time",ylab="ARIMA")
#plotting the predicted values
lines(ts(pred,start=981),lwd=2,col='blue')
#plotting prediction intervals
lines(ts(fArima$pred$upper[,2],start=981),lwd=2,col='light blue')
lines(ts(fArima$pred$lower[,2],start=981),lwd=2,col='light blue')