fittestLM: Automatically finding fittest linear model for prediction

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

View source: R/fittestLM.r

Description

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.

Usage

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

Arguments

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 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.

level

Confidence level for prediction intervals.

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.

filtered

See fittestArimaKF and fittestPolyRKF.

order

See fittestPolyR and fittestPolyRKF.

minorder

See fittestPolyR and fittestPolyRKF.

maxorder

See fittestPolyR and fittestPolyRKF.

raw

See fittestPolyR.

initQ

See fittestArimaKF and fittestPolyRKF.

rank.by

Character string. Criteria used for ranking candidate models. See 'Details'.

...

See fittestArima and fittestArimaKF.

Details

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.

Value

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 fittestArima, fittestArimaKF, fittestPolyR and fittestPolyRKF.

rank

Data.frame with the fitness and/or prediction accuracy criteria computed for all models considered, ranked by rank.by.

ranked.results

A list of lists containing the ranked results of the functions fittestArima, fittestArimaKF, fittestPolyR and fittestPolyRKF. Also ranked by rank.by.

Author(s)

Rebecca Pontes Salles

See Also

fittestArima, fittestArimaKF, fittestPolyR, fittestPolyRKF

Examples

1
2
3
4
5
6
7
8
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

TSPred documentation built on Jan. 21, 2021, 5:10 p.m.