HoltWinters {stats}  R Documentation 
HoltWinters Filtering
Description
Computes HoltWinters Filtering of a given time series. Unknown parameters are determined by minimizing the squared prediction error.
Usage
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())
Arguments
x 
An object of class 
alpha 

beta 

gamma 

seasonal 
Character string to select an 
start.periods 
Start periods used in the autodetection of start values. Must be at least 2. 
l.start 
Start value for level (a[0]). 
b.start 
Start value for trend (b[0]). 
s.start 
Vector of start values for the seasonal component
( 
optim.start 
Vector with named components 
optim.control 
Optional list with additional control parameters
passed to 
Details
The additive HoltWinters prediction function (for time series with period length p) is
\hat Y[t+h] = a[t] + h b[t] + s[t  p + 1 + (h  1) \bmod p],
where a[t]
, b[t]
and s[t]
are given by
a[t] = \alpha (Y[t]  s[tp]) + (1\alpha) (a[t1] + b[t1])
b[t] = \beta (a[t] a[t1]) + (1\beta) b[t1]
s[t] = \gamma (Y[t]  a[t]) + (1\gamma) s[tp]
The multiplicative HoltWinters prediction function (for time series with period length p) is
\hat Y[t+h] = (a[t] + h b[t]) \times s[t  p + 1 + (h  1) \bmod p].
where a[t]
, b[t]
and s[t]
are given by
a[t] = \alpha (Y[t] / s[tp]) + (1\alpha) (a[t1] + b[t1])
b[t] = \beta (a[t]  a[t1]) + (1\beta) b[t1]
s[t] = \gamma (Y[t] / a[t]) + (1\gamma) s[tp]
The data in x
are required to be nonzero for a multiplicative
model, but it makes most sense if they are all positive.
The function tries to find the optimal values of \alpha
and/or
\beta
and/or \gamma
by minimizing the squared onestep
prediction error if they are NULL
(the default). optimize
will be used for the singleparameter case, and optim
otherwise.
For seasonal models, start values for a
, b
and 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/trendmodels (no seasonal component), start
values for a
and b
are x[2]
and x[2] 
x[1]
, respectively. For levelonly models (ordinary exponential
smoothing), the start value for a
is x[1]
.
Value
An object of class "HoltWinters"
, a list with components:
fitted 
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). 
x 
The original series 
alpha 
alpha used for filtering 
beta 
beta used for filtering 
gamma 
gamma used for filtering 
coefficients 
A vector with named components 
seasonal 
The specified 
SSE 
The final sum of squared errors achieved in optimizing 
call 
The call used 
Author(s)
David Meyer David.Meyer@wu.ac.at
References
C. C. Holt (1957) Forecasting seasonals and trends by exponentially weighted moving averages, ONR Research Memorandum, Carnegie Institute of Technology 52. (reprint at doi:10.1016/j.ijforecast.2003.09.015).
P. R. Winters (1960). Forecasting sales by exponentially weighted moving averages. Management Science, 6, 324–342. doi:10.1287/mnsc.6.3.324.
See Also
Examples
require(graphics)
## Seasonal HoltWinters
(m < HoltWinters(co2))
plot(m)
plot(fitted(m))
(m < HoltWinters(AirPassengers, seasonal = "mult"))
plot(m)
## NonSeasonal HoltWinters
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)