Description Usage Arguments Details Value Author(s) References See Also Examples
The function uses an automatically produced moving average smoother as base
for predicting and returning the next n consecutive values of the provided
univariate time series using an also automatically fitted model
(ets
/stlf
or arima
). It also
evaluates the fitness and prediction accuracy of the produced model.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | fittestMAS(
timeseries,
timeseries.test = NULL,
h = NULL,
order = NULL,
minorder = 1,
maxorder = min(36, length(ts(na.action(timeseries)))/2),
model = c("ets", "arima"),
level = 0.95,
na.action = stats::na.omit,
rank.by = c("MSE", "NMSE", "MAPE", "sMAPE", "MaxError", "AIC", "AICc", "BIC",
"logLik", "errors", "fitness"),
...
)
|
timeseries |
A vector or univariate time series. |
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
|
order |
A numeric integer value corresponding to the order of moving
average smoother to be produced. If |
minorder |
A numeric integer value corresponding to the minimum order
of candidate moving average smoothers to be produced and evaluated. Ignored
if |
maxorder |
A numeric integer value corresponding to the maximal order
of candidate moving average smoothers to be produced and evaluated. Ignored
if |
model |
Character string. Indicates which model is to be used for fitting and prediction of the moving average smoothed series. |
level |
Confidence level for prediction intervals. See the
|
na.action |
A function for treating missing values in |
rank.by |
Character string. Criteria used for ranking candidate models generated. See 'Details'. |
... |
Additional arguments passed to the modeling functions. |
The function produces a moving average smoother of timeseries
with
order order
and uses it as base for model fitting and prediction. If
model="arima"
, an arima model is used and automatically fitted using
the auto.arima
function. If model="ets"
, the
function fits an [forecast]ets
model (if timeseries
is
non-seasonal or the seasonal period is 12 or less) or
stlf
model (if the seasonal period is 13 or more).
For producing the prediction of the next h
consecutive values of the
provided univariate time series, the function mas.rev
is used.
If order
is NULL
, it is automatically selected. For that, a
set with candidate models constructed for moving average smoothers of orders
from minorder
to maxorder
is generated. The default value of
maxorder
is set based on code from the sma
function of
smooth
package. The value option of order
which generate the
best ranked candidate model acoording to the criteria in rank.by
is
selected.
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
). In the former case, the candidate models are used for
time series prediction and the error measures are calculated by means of a
cross-validation process. In the latter case, the candidate models are
fitted and fitness criteria are calculated based on all observations in
timeseries
.
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 |
A list containing information about the best evaluated model. |
order |
The order of moving average smoother provided or automatically selected. |
ma |
The simple moving
average smoother of order |
AICc |
Numeric value of the computed AICc criterion of the best evaluated model. |
AIC |
Numeric value of the computed AIC criterion of the best evaluated model. |
BIC |
Numeric value of the computed BIC criterion of the best evaluated model. |
logLik |
Numeric value of the computed log-likelihood of the best evaluated model. |
pred |
A list
with the components |
MSE |
Numeric value of the resulting MSE error of prediction.
Require |
NMSE |
Numeric value of the resulting
NMSE error of prediction. Require |
MAPE |
Numeric value of the resulting MAPE error of prediction. Require
|
sMAPE |
Numeric value of the resulting sMAPE
error of prediction. Require |
MaxError |
Numeric value of the maximal error of prediction. Require
|
rank.val |
Data.frame with the fitness or
prediction accuracy criteria computed for all candidate models ranked by
|
rank.by |
Ranking criteria used for ranking candidate
models and producing |
Rebecca Pontes Salles
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.
1 2 3 4 5 6 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.