HoltWinters
Holt-Winters Filtering

### Description

Computes the Holt-Winters filtering of a time series. This is an exponentially weighted moving average filter of the level, trend, and seasonal components of a time series. The smoothing parameters are chosen to minimze the sum of the squared one-step-ahead prediction errors.

### 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())
    ## S3 method for class 'HoltWinters':
    print(x, ...)
    ## S3 method for class 'HoltWinters':
    residuals(object, ...)
    ## S3 method for class 'HoltWinters':
    predict(object, n.ahead = 1, prediction.interval = FALSE, level = 0.95, ...)

### Arguments

x | In the HoltWinters function, a time series object or any object can be coerced to time series via as.ts(). It must be numeric and univariate (one column) and missing values (NAs) are not allowed. In the print.HoltWinters function, an object of class "HoltWinters", as produced by the HoltWinters function.
alpha | the alpha parameter of the Holt-Winters filter. Specifies how to smooth the level component. If numeric, it must be within the half-open unit interval (0, 1]. A small value means that older values in x are weighted more heavily. Values near 1.0 mean that the latest value has more weight. NULL means that the HoltWinters function should find the optimal value of alpha. alpha must not be FALSE or 0.
beta | the beta parameter of the Holt-Winters filter. Specifies how to smooth the trend component. If numeric, it must be within the unit interval [0, 1]. A small value means that older values in x are weighted more heavily. Values near 1.0 mean that the latest value has more weight. NULL means that the HoltWinters function should find the optimal value of beta. The trend component is omitted if beta is FALSE.
gamma | the gamma parameter of the Holt-Winters filter. Specifies how to smooth the seasonal component. If numeric, it must be within the unit interval [0, 1]. A small value means that older values in x are weighted more heavily. Values near 1.0 mean that the latest value has more weight. NULL means that the HoltWinters function should find the optimal value of gamma. The seasonal component will be omitted if gamma is FALSE. This must be specified as FALSE if frequency(x) is not an integer greater than 1.
seasonal | a single character string. Specifies how the seasonal component interacts with the other components. "additive" (the default) indicates that x is modeled as level + trend + seasonal "multiplicative" indicates the model is (level + trend) * seasonal. Abbreviations of "additive" and "multiplicative" are accepted.
start.periods | The number of seasonal periods to use to compute start values when a seasonal component is in the model. This should be at least 2.
l.start | The starting value of the level component.
b.start | The starting value of the trend component.
s.start | The starting values of seasonal component, a vector of length frequency(x).
optim.start | a vector with names "alpha", "beta" and "gamma", the values of which are used as the start value for optimization.
optim.control | a list of control parameters used for optimization. It is passed to optim().

object | in the residuals and predict methods, an object of class "HoltWinters", as returned by the HoltWinters function.
n.ahead | in the predict method, the number of time points in the future at which to predict the values of the time series.
prediction.interval | a logical value. If TRUE, prediction intervals for the predicted values will be computed. The default is FALSE.
level | A number between 0 and 1, usually close to 1. Specifies the probability that future values lie within the prediction intervals (given that the model is appropriate).
... | other optional arguments pass to or from methods.

### Details

- HoltWinters computes the Holt-Winters filtering of a time series. The algorithm or formula and other parameter details like alpha, beta, gamma, and so on. See the references listed in the References section. The functions optim and optimize are used for some missing parameters' optimization.
- print.HoltWinters is an invisible method of generic print for class "HoltWinters". It prints the status message of Holt-Winters exponential smoothing with or without trend, and with or without additive or a multiplicative seasonal component, a matched call, or smoothing parameters: alpha, beta and gamma, and fitted coefficients.
- residuals.HoltWinters is an invisible method of generic residuals for class "HoltWinters". It calculates the residuals of "HoltWinters" object, which is the difference between the original time series and the fitted time series.
- Spotfire Enterprise Runtime for R and open-source R return different prediction intervals for multiplicative seasonal models. Spotfire Enterprise Runtime for R assumes that the seasonal and error components are multiplicative in effect and it uses the formula for prediction variance found in section 6.4.2 of Hyndman, et al, 2008.

Value

HoltWinters | returns a list object of class "HoltWinters" with the following named components:
fitted | fitted time series with level, trend and seasonal components.
x | the original time series.
alpha | the alpha parameter used for filtering.
beta | the beta parameter used for filtering.
gamma | the gamma parameter used for filtering.
coefficients | a vector with named components a, b and s, which contains the estimated values for the level, trend and seasonal components.
seasonal | the seasonal argument.
SSE | the final fitted sum of squared errors.
call | the matched call.
predict | method returns a time series matrix. The first column, named "fit" contains the predicted value and, if prediction.interval is TRUE the the upper and lower bounds will be in columns called "upr" and "lwr".
residuals | method returns a times series like the input containing the difference between the actual values and the fitted values.

References
Hyndman, Rob J., et al. 2008. Forecasting with Exponential Smoothing: the State Space Approach. Berlin, GER: Springer.
Hyndman, R. J. and Athanasopoulos, G. 2013. Forecasting: principles and practice. http://otests.com/fpp/7/1.
See Also
ts, optim, optimize, decompose
Examples

    # Seasonal Holt-Winters using monthly data, find optimal smoothing parameters
    earlyCO2 <- window(co2, end=1990)
    hw <- HoltWinters(earlyCO2)
    # Predict two years ahead
    predict(hw, n.ahead=84)
    # Compare to later data
    window(co2, start=1990)
    # Assume there is no trend component, optimize other parameters
    hwTrendless <- HoltWinters(earlyCO2, beta=FALSE)
    predict(hwTrendless, n.ahead=84)
    # Choose your own smoothing parameters
    myhw <- HoltWinters(earlyCO2, alpha=.5, beta=FALSE, gamma=.1)

Package stats version 6.1.5-18
Package Index