fittestLM | R Documentation |
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"),
...
)
timeseries |
A vector or univariate time series which contains the values used for fitting the models. |
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
|
level |
Confidence level for prediction intervals. |
na.action |
A function for treating missing values in |
filtered |
See |
order |
See |
minorder |
See |
maxorder |
See |
raw |
See |
initQ |
See |
rank.by |
Character string. Criteria used for ranking candidate models. See 'Details'. |
... |
See |
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.
A list with components:
model |
An object containing the
fittest evaluated linear model. The class of the model object is dependent
on the results of the evaluation (ranking). See |
rank |
Data.frame with the fitness
and/or prediction accuracy criteria computed for all models considered,
ranked by |
ranked.results |
A list of lists containing
the ranked results of the functions |
Rebecca Pontes Salles
fittestArima
, fittestArimaKF
,
fittestPolyR
, fittestPolyRKF
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.