The function automatically applies a maximal overlap discrete wavelet
transform to a provided univariate time series. The resulting components of
the decomposed series are used as base for predicting and returning the next
n consecutive values of the provided univariate time series using also
automatically fitted models (ets
or arima
). It
also evaluates fitness and prediction accuracy of the produced models.
fittestWavelet(
timeseries,
timeseries.test = NULL,
h = 1,
filters = c("haar", "d4", "la8", "bl14", "c6"),
n.levels = NULL,
maxlevel = NULL,
boundary = "periodic",
model = c("ets", "arima"),
conf.level = 0.95,
na.action = stats::na.omit,
rank.by = c("MSE", "NMSE", "MAPE", "sMAPE", "MaxError", "AIC", "AICc", "BIC",
"logLik", "errors", "fitness"),
...
)
A vector or univariate time series.
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
.
A vector containing character strings indicating which
wavelet filter to use in the decomposition. If length(filters)>1
, the
wavelet transform filter used for generating the return of the function is
automatically selected. If NULL
, all supported filters are considered
for automatic selection. See 'Details'. For more details on all the
supported filters and corresponding character strings see
wt.filter
.
An integer specifying the level of the decomposition. If
NULL
, the level of the wavelet decomposition returned by the function
is automatically selected within the interval 1:maxlevel
. See
'Details'.
A numeric integer value corresponding to the maximal level
of candidate wavelet decompositions to be produced and evaluated. If
NULL
, maxlevel
is set as
floor(log(((nobs-1)/(L-1))+1)/log(2))
, where
nobs=length(timeseries)
and L
is the length of the wavelet and
scaling filters. See modwt
and
wt.filter
. Ignored if n.levels
is provided.
See 'Details'.
Character string. Indicates which boundary method to use.
See modwt
.
Character string. Indicates which model is to be used for fitting and prediction of the components of the decomposed series.
Confidence level for prediction intervals. See the
forecast
function of the forecast
package.
~~Describe na.action
here~~
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
.
Character string. Criteria used for ranking candidate decompositions/models/predictions generated during parameter selection. See 'Details'.
Additional arguments passed to the modeling functions.
~~Describe na.action
here~~
A list with components:
An object of class
modwt
containing the wavelet transformed/decomposed
time series.
The level of wavelet decomposition provided or automatically selected.
A character string indicating the (provided or automatically selected) wavelet filter used in the decomposition.
Numeric value of the computed AICc criterion of
the fitted model for the level
th scaling coefficients series.
Numeric value of the computed AIC criterion of the fitted model
for the level
th scaling coefficients series.
Numeric
value of the computed BIC criterion of the fitted model for the
level
th scaling coefficients series.
Numeric value of
the computed log-likelihood of the fitted model for the level
th
scaling coefficients series.
A list with the components
mean
, lower
and upper
, containing the predictions based
on the best evaluated decomposition and the lower and upper limits for
prediction intervals, respectively. All components are time series. See the
forecast
function in the forecast
package.
Numeric value of the resulting MSE error of prediction. Require
timeseries.test
.
Numeric value of the resulting NMSE
error of prediction. Require timeseries.test
.
Numeric
value of the resulting MAPE error of prediction. Require
timeseries.test
.
Numeric value of the resulting sMAPE
error of prediction. Require timeseries.test
.
Numeric value of the maximal error of prediction. Require
timeseries.test
.
Data.frame with the fitness or
prediction accuracy criteria computed based on all candidate decompositions
ranked by rank.by
. It has the attribute "ranked.wt"
, which is
a list of modwt
objects containing all the candidate
decompositions, also ranked by rank.by
. Only provided if
filters
or n.levels
were automatically selected.
Ranking criteria used for ranking candidate decompositions
and producing rank.val
.
The function produces a maximal overlap discrete wavelet transform of
timeseries
. It performs a time series decomposition of level
n.levels
using the wavelet filter filters
. See the
modwt
function. Each component series resulting from
the decomposition (n.levels
wavelet coefficients series and
n.levels
scaling coefficients series) is separately used as base for
model fitting and prediction. If model="arima"
, arima models are used
and automatically fitted using the auto.arima
function. If model="ets"
, the function fits
[forecast]ets
models. The set of predictions for all component
series are then reversed transformed in order to produce the next h
consecutive values of the provided univariate time series in
timeseries
. See the imodwt
function.
If length(filters)>1
or filters=NULL
, it is automatically
selected. For that, a set of candidate wavelet decompositions with different
options of filters is generated and used for model fitting and prediction.
Also, if n.levels
is NULL
, it is automatically set as a value
within the interval 1:maxlevel
(if maxlevel
is not provided,
it is calculated according to the wavelet filter based on code from
modwt
). For that, candidate decompositions are
specified with different levels. The options of filter and/or level of
decomposition which generate the best ranked model fitness/predictions
acoording to the criteria in rank.by
are 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 wavelet
decompositions are used for time series prediction and the error measures
are calculated by means of a cross-validation process. In the latter case,
the component series of the candidate decompositions are modeled and model
fitness criteria are calculated based on all observations in
timeseries
. In particular, the fitness criteria calculated for
ranking the candidate decomposition correspond to the model produced for the
n.levels
th scaling coefficients series as it can be considered the
main component of a decomposition of level n.levels
(Conejo,2005).
If rank.by
is set as "errors"
or "fitness"
, the
candidate decompositions 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 decompositions. The
rank.position.sum
criterion is calculated as the sum of the rank
positions of a decomposition (1 = 1st position = better ranked model, 2 =
2nd position, etc.) on each calculated ranking criteria.
A. J. Conejo, M. A. Plazas, R. Espinola, A. B. Molina, Day-ahead electricity price forecasting using the wavelet transform and ARIMA models, IEEE Transactions on Power Systems 20 (2005) 1035-1042.
T. Joo, S. Kim, Time series forecasting based on wavelet filtering, Expert Systems with Applications 42 (2015) 3868-3874.
C. Stolojescu, I. Railean, S. M. P. Lenca, A. Isar, A wavelet based prediction method for time series. In Proceedings of the 2010 International Conference Stochastic Modeling Techniques and Data Analysis, Chania, Greece (pp. 8-11) (2010).
# NOT RUN {
data(CATS)
# }
# NOT RUN {
fW <- fittestWavelet(CATS[,1],h=20,model="arima")
#plot wavelet transform/decomposition
plot(fW$WT)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab