HoltWintersForecast
Fit a HoltWinters Model from Spotfire

Description

Fit a HoltWinters model from Spotfire and compute forecasts.

Usage

HoltWintersForecast(x, alpha = NULL, beta = NULL, gamma = NULL,
    seasonal = c("additive", "multiplicative"), start = 1, frequency = 1,
    n.ahead = 1, prediction.interval = FALSE, level = 0.95)

Arguments

x a vector object that can be made into a vector time series object with the ts function. Missing values at the start of the series are dropped from the model. Single missing values in the middle of the series are replaced by linearly interpolation. Two or more missing values in a row are not allowed.
alpha alpha parameter of the Holt-Winters filter specifying 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 beta parameter of the Holt-Winters filter specifying 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 or 0.

gamma gamma parameter of the Holt-Winters filter specifying 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 or 0.

This must be specified as FALSE if frequency(x) is not an integer greater than 1.

seasonal a single character string specifying how the seasonal component interacts with the other components.
  • if "additive", the default, x is modeled as level + trend + seasonal
  • if "multiplicative", the model is (level + trend) * seasonal.
Abbreviations of "additive" and "multiplicative" are accepted.
start the starting date for the series. For example, in years, February, 1970 is 1970+(1/12) or 1970.083. If start is a vector with at least two data values, the first is interpreted as the time unit (for example, the year), and the second as the number of positions into the sampling period. For example, February, 1970 could be c(1970,2).
frequency the observations frequency; that is, how many observations per sampling period. For example, monthly data have frequency=12. This must be greater than 1 to fit a seasonal component.
n.ahead 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 numeric value between 0 and 1, (generally close to 1), that specifies the confidence level for the prediction intervals.

Details

See the HoltWinters help file for details on the fitting of HoltWinters models.
Value
returns a list with components:
fitHW the fit component (a matrix) from the object created by calling HoltWinters using data[[xname]] as the time series and the supplied values of alpha, beta, gamma and seasonal.
hwSmoothParam a two column data frame containing the names of the final smoothing parameters (column 1) and their values (column 2). If the beta or gamma parameter was not fit, its value in the data frame will be -1.
predictHW the data frame result from calling the predict method for an object of class "HoltWinters" using the supplied values of n.ahead, prediction.interval and level.
See Also
HoltWinters
Examples
library(SpotfireStats)
library(Sdatasets)

hw1 <- HoltWintersForecast(hstart, start=start(hstart), frequency=frequency(hstart)) names(hw1) hw1[["hwSmoothParam"]] hw1[["fitHW"]][1:10,]

hw2 <- HoltWintersForecast(hstart, start=start(hstart), frequency=frequency(hstart), n.ahead=5, prediction.interval=TRUE) names(hw2) hw2[["predictHW"]]

Package SpotfireStats version 6.1.4-13
Package Index