The function automatically evaluates and returns the fittest linear model
among ARIMA and polynomial regression, with and without Kalman filtering,
for prediction of a given univariate time series. Wrapper for the
fittestArima, fittestArimaKF,
fittestPolyR and fittestPolyRKF functions for
automatic time series prediction, whose results are also returned.
fittestLM(
timeseries,
timeseries.test = NULL,
h = NULL,
level = 0.95,
na.action = stats::na.omit,
filtered = TRUE,
order = NULL,
minorder = 0,
maxorder = 5,
raw = FALSE,
initQ = NULL,
rank.by = c("MSE", "NMSE", "MAPE", "sMAPE", "MaxError", "AIC", "AICc", "BIC", "logLik",
"errors", "fitness"),
...
)A list with components:
An object containing the
fittest evaluated linear model. The class of the model object is dependent
on the results of the evaluation (ranking). See fittestArima,
fittestArimaKF, fittestPolyR and
fittestPolyRKF.
Data.frame with the fitness
and/or prediction accuracy criteria computed for all models considered,
ranked by rank.by.
A list of lists containing
the ranked results of the functions fittestArima,
fittestArimaKF, fittestPolyR and
fittestPolyRKF. Also ranked by rank.by.
A vector or univariate time series which contains the values used for fitting the models.
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.
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.
Confidence level for prediction intervals.
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.
See fittestArimaKF and
fittestPolyRKF.
See fittestPolyR and
fittestPolyRKF.
See fittestPolyR and
fittestPolyRKF.
See fittestPolyR and
fittestPolyRKF.
See fittestPolyR.
See fittestArimaKF and
fittestPolyRKF.
Character string. Criteria used for ranking candidate models. See 'Details'.
See fittestArima and fittestArimaKF.
Rebecca Pontes Salles
The results of the best evaluated models returned by
fittestArima, fittestArimaKF,
fittestPolyR and fittestPolyRKF are ranked and
the fittest linear model for prediction of the given univariate time series
is selected based on the criteria in rank.by.
The ranking criteria in rank.by may be set as a prediction error
measure (such as MSE, NMSE, MAPE,
sMAPE or MAXError), or as a fitness criteria
(such as AIC, AICc, BIC or
logLik). See fittestArima,
fittestArimaKF, fittestPolyR or
fittestPolyRKF.
If rank.by is set as "errors" or "fitness", the
candidate models are ranked by all the mentioned prediction error measures
or fitness criteria, respectively. The wheight of the ranking criteria is
equally distributed. In this case, a rank.position.sum criterion is
produced for ranking the candidate models. The rank.position.sum
criterion is calculated as the sum of the rank positions of a model (1 = 1st
position = better ranked model, 2 = 2nd position, etc.) on each calculated
ranking criteria.
fittestArima, fittestArimaKF,
fittestPolyR, fittestPolyRKF
# \donttest{
data(CATS,CATS.cont)
fittest <- fittestLM(CATS[,1],CATS.cont[,1])
#fittest model information
fittest$rank[1,]
#predictions of the fittest model
fittest$ranked.results[[1]]$pred
# }
Run the code above in your browser using DataLab