Computes Holt-Winters Filtering of a given time series. Unknown parameters are determined by minimizing the squared prediction error.
HoltWinters(x, alpha = NULL, beta = NULL, gamma = NULL, seasonal = c("additive", "multiplicative"), start.periods = 2, l.start = NULL, b.start = NULL, s.start = NULL, optim.start = c(alpha = 0.3, beta = 0.1, gamma = 0.1), optim.control = list())
- An object of class
- alpha parameter of Holt-Winters Filter.
- beta parameter of Holt-Winters Filter. If set to
FALSE, the function will do exponential smoothing.
- gamma parameter used for the seasonal component. If set to
FALSE, an non-seasonal model is fitted.
- Character string to select an
"additive"(the default) or
"multiplicative"seasonal model. The first few characters are sufficient. (Only takes effect if
- Start periods used in the autodetection of start values. Must be at least 2.
- Start value for level (a).
- Start value for trend (b).
- Vector of start values for the seasonal component (s_1 ... s_p)
- Vector with named components
gammacontaining the starting values for the optimizer. Only the values needed must be specified. Ignored in the one-parameter case.
- Optional list with additional control parameters passed to
optimif this is used. Ignored in the one-parameter case.
The additive Holt-Winters prediction function (for time series with period length p) is where a[t], b[t] and s[t] are given by
The multiplicative Holt-Winters prediction function (for time series with period length p) is where a[t], b[t] and s[t] are given by The data in
x are required to be non-zero for a multiplicative model, but it makes most sense if they are all positive.
The function tries to find the optimal values of α and/or β and/or γ by minimizing the squared one-step prediction error if they are
NULL (the default).
optimize will be used for the single-parameter case, and
For seasonal models, start values for
s are inferred by performing a simple decomposition in trend and seasonal component using moving averages (see function
decompose) on the
start.periods first periods (a simple linear regression on the trend component is used for starting level and trend). For level/trend-models (no seasonal component), start values for
x - x, respectively. For level-only models (ordinary exponential smoothing), the start value for
An object of class
"HoltWinters", a list with components:
- A multiple time series with one column for the filtered series as well as for the level, trend and seasonal components, estimated contemporaneously (that is at time t and not at the end of the series).
- The original series
- alpha used for filtering
- beta used for filtering
- gamma used for filtering
- A vector with named components
a, b, s1, ..., spcontaining the estimated values for the level, trend and seasonal components
- The specified
- The final sum of squared errors achieved in optimizing
- The call used
C. C. Holt (1957) Forecasting trends and seasonals by exponentially weighted moving averages, ONR Research Memorandum, Carnegie Institute of Technology 52.
P. R. Winters (1960) Forecasting sales by exponentially weighted moving averages, Management Science 6, 324--342.
require(graphics) ## Seasonal Holt-Winters (m <- HoltWinters(co2)) plot(m) plot(fitted(m)) (m <- HoltWinters(AirPassengers, seasonal = "mult")) plot(m) ## Non-Seasonal Holt-Winters x <- uspop + rnorm(uspop, sd = 5) m <- HoltWinters(x, gamma = FALSE) plot(m) ## Exponential Smoothing m2 <- HoltWinters(x, gamma = FALSE, beta = FALSE) lines(fitted(m2)[,1], col = 3)
Documentation reproduced from R 3.0.2. License: GPL-2.