fittestArima: Automatic ARIMA fitting, prediction and accuracy evaluation

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/fittestArima.r

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

1
2
3
4
5
6
7
8
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 timeseries with actual values. It is used as a testing set and base for calculation of prediction error measures. Ignored if NULL.

h

Number of consecutive values of the time series to be predicted. If h is NULL, the number of consecutive values to be predicted is assumed to be equal to the length of timeseries.test. Required when timeseries.test is NULL.

na.action

A function for treating missing values in timeseries and timeseries.test. The default function is na.omit, which omits any missing values found in timeseries or timeseries.test.

level

Confidence level for prediction intervals.

...

Additional arguments passed to the auto.arima modelling function.

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 auto.arima function in the forecast package.

parameters

A list containing the parameters of the best fitted ARIMA model. See the arimaparameters function.

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 mean, lower and upper, containing the predictions and the lower and upper limits for prediction intervals, respectively. All components are time series. See the forecast function in the forecast package.

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
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')

RebeccaSalles/TSPred documentation built on April 6, 2021, 2:44 a.m.