HoltWinters              package:stats              R Documentation

_H_o_l_t-_W_i_n_t_e_r_s _F_i_l_t_e_r_i_n_g

_D_e_s_c_r_i_p_t_i_o_n:

     Computes Holt-Winters Filtering of a given time series. Unknown
     parameters are determined by minimizing the squared prediction
     error.

_U_s_a_g_e:

     HoltWinters(x, alpha = NULL, beta = NULL, gamma = NULL,
                 seasonal = c("additive", "multiplicative"),
                 start.periods = 3, l.start = NULL, b.start = NULL,
                 s.start = NULL,
                 optim.start = c(alpha = 0.3, beta = 0.1, gamma = 0.1),
                 optim.control = list())

_A_r_g_u_m_e_n_t_s:

       x: An object of class 'ts'

   alpha: alpha parameter of Holt-Winters Filter

    beta: beta parameter of Holt-Winters Filter. If set to 0, the
          function will do exponential smoothing.

   gamma: gamma parameter used for the seasonal component. If set to 0,
          an non-seasonal model is fitted.

seasonal: Character string to select an '"additive"'  (the default) or
          '"multiplicative"' seasonal model. The first few characters
          are sufficient. (Only takes effect if  'gamma' is non-zero).

start.periods: Start periods used in the autodetection of start values.
          Must be at least 3.

 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
          (s_1[0]...s_p[0])

optim.start: Vector with named components 'alpha', 'beta', and 'gamma'
          containing the starting values for the optimizer. Only the
          values needed must be specified.

optim.control: Optional list with additional control parameters passed
          to 'optim'.

_D_e_t_a_i_l_s:

     The additive Holt-Winters prediction function (for time series
     with period length p) is

       Yhat[t+h] = a[t] + h * b[t] + s[t + 1 + (h - 1) mod p],

     where a[t], b[t] and s[t] are given by

     a[t] = alpha (Y[t] - s[t-p])  + (1-alpha) (a[t-1] + b[t-1])


            b[t] = beta (a[t] - a[t-1]) + (1-beta) b[t-1]


            s[t] = gamma (Y[t] - a[t]) + (1-gamma) s[t-p]


     The multiplicative Holt-Winters prediction function (for time
     series with period length p) is

      Yhat[t+h] = (a[t] + h * b[t]) * s[t + 1 + (h - 1) mod p],

     where a[t], b[t] and s[t] are given by

     a[t] = alpha (Y[t] / s[t-p])  + (1-alpha) (a[t-1] + b[t-1])


            b[t] = beta (a[t] - a[t-1]) + (1-beta) b[t-1]


           s[t] = gamma  (Y[t] / a[t])  + (1-gamma) s[t-p]


     The function tries to find the optimal values of alpha and/or beta
     and/or gamma by minimizing the squared one-step prediction error
     if they are omitted.

     For seasonal models, start values for 'a', 'b' and 's' are
     detected 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 a and b are x[2] and x[2] - x[1], respectively. For
     level-only models (ordinary exponential smoothing), the start
     value for a is x[1].

_V_a_l_u_e:

     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

coefficients: A vector with named components 'a, b, s1, ..., sp'
          containing the estimated values for the level, trend and
          seasonal components

seasonal: The specified 'seasonal'-parameter

     SSE: The final sum of squared errors achieved in optimizing

    call: The call used

_A_u_t_h_o_r(_s):

     David Meyer David.Meyer@wu-wien.ac.at

_R_e_f_e_r_e_n_c_e_s:

     C. C. Holt (1957) Forecasting seasonals and trends by
     exponentially weighted moving averages, ONR Research Memorandum,
     Carnigie Institute 52.

     P. R. Winters (1960) Forecasting sales by exponentially weighted
     moving averages, _Management Science_ *6*, 324-342.

_S_e_e _A_l_s_o:

     'predict.HoltWinters','optim'

_E_x_a_m_p_l_e_s:

     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 = 0)
     plot(m)

     ## Exponential Smoothing
     m2 <- HoltWinters(x, gamma = 0, beta = 0)
     lines(fitted(m2)[,1], col = 3)

