naginterfaces.library.tsa.uni_​smooth_​exp

naginterfaces.library.tsa.uni_smooth_exp(mode, itype, p, param, y, k, init, nf, comm)[source]

uni_smooth_exp performs exponential smoothing using either single exponential, double exponential or a Holt–Winters method.

For full information please refer to the NAG Library document for g13am

https://www.nag.com/numeric/nl/nagdoc_27.1/flhtml/g13/g13amf.html

Parameters
modeint

Indicates if uni_smooth_exp is continuing from a previous call or, if not, how the initial values are computed.

Required values for , and , for , are supplied in .

uni_smooth_exp continues from a previous call using values that are supplied in [‘r’].

Required values for , and , for , are estimated using the first observations.

itypeint

The smoothing function.

Single exponential.

Brown double exponential.

Linear Holt.

Additive Holt–Winters.

Multiplicative Holt–Winters.

pint

If or , the seasonal order, , otherwise is not referenced.

paramfloat, array-like, shape

Note: the required length for this argument is determined as follows: if : ; if : ; if : ; otherwise: .

The smoothing parameters.

If or , and any remaining elements of are not referenced.

If , , , and any remaining elements of are not referenced.

If or , , , and .

yfloat, array-like, shape

The time series.

kint

If , the number of observations used to initialize the smoothing.

If , is not referenced.

initfloat, array-like, shape

Note: the required length for this argument is determined as follows: if : ; if : ; if : ; otherwise: .

If , the initial values for , and , for , used to initialize the smoothing.

If , and the remaining elements of are not referenced.

If or , and and the remaining elements of are not referenced.

If or , , and to hold the values for , for .

The remaining elements of are not referenced.

nfint

The number of forecasts required beyond the end of the series. Note, the one step ahead forecast is always produced.

commdict, communication object, modified in place

Communication structure for the reference vector.

If , this argument must have been initialized by a prior call to uni_smooth_exp.

Returns
initfloat, ndarray, shape

If , the values used to initialize the smoothing. These are in the same order as described above.

fvfloat, ndarray, shape

, for , the next step forecasts. Where , if , else is the total number of smoothed and forecast values already produced.

fsefloat, ndarray, shape

The forecast standard errors for the values given in .

yhatfloat, ndarray, shape

, for , the one step ahead forecast values, with being the one step ahead forecast of .

resfloat, ndarray, shape

The residuals, , for .

dvfloat

The square root of the mean deviation.

adfloat

The mean absolute deviation.

Raises
NagValueError
(errno )

On entry, .

Constraint: , or .

(errno )

On entry, .

Constraint: , , , or .

(errno )

On entry, .

Constraint: if or , .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: if , .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

A multiplicative Holt–Winters model cannot be used with the supplied data.

(errno )

On entry, and .

Constraint: if and or , .

(errno )

On entry, , .

Constraint: if and or , .

(errno )

On entry, .

Constraint: .

(errno )

On entry, the array [‘r’] has not been initialized correctly.

Notes

Exponential smoothing is a relatively simple method of short term forecasting for a time series. uni_smooth_exp provides five types of exponential smoothing; single exponential, Brown’s double exponential, linear Holt (also called double exponential smoothing in some references), additive Holt–Winters and multiplicative Holt–Winters. The choice of smoothing method used depends on the characteristics of the time series. If the mean of the series is only slowly changing then single exponential smoothing may be suitable. If there is a trend in the time series, which itself may be slowly changing, then double exponential smoothing may be suitable. If there is a seasonal component to the time series, e.g., daily or monthly data, then one of the two Holt–Winters methods may be suitable.

For a time series , for , the five smoothing functions are defined by the following:

Single Exponential Smoothing

Brown Double Exponential Smoothing

Linear Holt Smoothing

Additive Holt–Winters Smoothing

Multiplicative Holt–Winters Smoothing

and is defined as in the additive Holt–Winters smoothing,

where is the mean, is the trend and is the seasonal component at time with being the seasonal order. The -step ahead forecasts are given by and their variances by . The term is estimated as the mean deviation.

The parameters, , and control the amount of smoothing. The nearer these parameters are to one, the greater the emphasis on the current data point. Generally these parameters take values in the range to . The linear Holt and two Holt–Winters smoothers include an additional parameter, , which acts as a trend dampener. For the trend is dampened and for the forecast function has an exponential trend, removes the trend term from the forecast function and does not dampen the trend.

For all methods, values for , , and can be chosen by trying different values and then visually comparing the results by plotting the fitted values along side the original data. Alternatively, for single exponential smoothing a suitable value for can be obtained by fitting an model (see multi_inputmod_estim()). For Brown’s double exponential smoothing and linear Holt smoothing with no dampening, (i.e., ), suitable values for and can be obtained by fitting an model. Similarly, the linear Holt method, with , can be expressed as an model and the additive Holt–Winters, with no dampening, (), can be expressed as a seasonal ARIMA model with order of the form . There is no similar procedure for obtaining parameter values for the multiplicative Holt–Winters method, or the additive Holt–Winters method with . In these cases parameters could be selected by minimizing a measure of fit using one of the nonlinear optimization functions in submodule opt.

In addition to values for , , and , initial values, , and , for , are required to start the smoothing process. You can either supply these or they can be calculated by uni_smooth_exp from the first observations. For single exponential smoothing the mean of the observations is used to estimate . For Brown double exponential smoothing and linear Holt smoothing, a simple linear regression is carried out with the series as the dependent variable and the sequence as the independent variable. The intercept is then used to estimate and the slope to estimate . In the case of the additive Holt–Winters method, the same regression is carried out, but a separate intercept is used for each of the seasonal groupings. The slope gives an estimate for and the mean of the intercepts is used as the estimate of . The seasonal parameters , for , are estimated as the intercepts – . A similar approach is adopted for the multiplicative Holt–Winter’s method.

One step ahead forecasts, are supplied along with the residuals computed as . In addition, two measures of fit are provided. The mean absolute deviation,

and the square root of the mean deviation

References

Chatfield, C, 1980, The Analysis of Time Series, Chapman and Hall