g13am performs exponential smoothing using either single exponential, double exponential or a Holt–Winters method.
Syntax
C# |
---|
public static void g13am( int mode, int itype, int p, double[] param, int n, double[] y, int k, double[] init, int nf, double[] fv, double[] fse, double[] yhat, double[] res, out double dv, out double ad, double[] r, out int ifail ) |
Visual Basic |
---|
Public Shared Sub g13am ( _ mode As Integer, _ itype As Integer, _ p As Integer, _ param As Double(), _ n As Integer, _ y As Double(), _ k As Integer, _ init As Double(), _ nf As Integer, _ fv As Double(), _ fse As Double(), _ yhat As Double(), _ res As Double(), _ <OutAttribute> ByRef dv As Double, _ <OutAttribute> ByRef ad As Double, _ r As Double(), _ <OutAttribute> ByRef ifail As Integer _ ) |
Visual C++ |
---|
public: static void g13am( int mode, int itype, int p, array<double>^ param, int n, array<double>^ y, int k, array<double>^ init, int nf, array<double>^ fv, array<double>^ fse, array<double>^ yhat, array<double>^ res, [OutAttribute] double% dv, [OutAttribute] double% ad, array<double>^ r, [OutAttribute] int% ifail ) |
F# |
---|
static member g13am : mode : int * itype : int * p : int * param : float[] * n : int * y : float[] * k : int * init : float[] * nf : int * fv : float[] * fse : float[] * yhat : float[] * res : float[] * dv : float byref * ad : float byref * r : float[] * ifail : int byref -> unit |
Parameters
- mode
- Type: System..::..Int32On entry: indicates if g13am is continuing from a previous call or, if not, how the initial values are computed.Constraint: , or .
- itype
- Type: System..::..Int32On entry: the smoothing function.
- Single exponential.
- Brown double exponential.
- Linear Holt.
- Additive Holt–Winters.
- Multiplicative Holt–Winters.
Constraint: , , , or .
- p
- Type: System..::..Int32On entry: if or , the seasonal order, , otherwise p is not referenced.Constraint: if or , .
- param
- Type: array<System..::..Double>[]()[][]An array of size [_lparam]Note: the dimension of the array param must be at least if or , if and at least if or .On entry: the smoothing parameters.If or , and any remaining elements of param are not referenced.If , , , and any remaining elements of param are not referenced.If or , , , and .Constraints:
- if , ;
- if , ;
- if , and and ;
- if or , and and and .
- n
- Type: System..::..Int32On entry: the number of observations in the series.Constraint: .
- y
- Type: array<System..::..Double>[]()[][]An array of size [n]On entry: the time series.
- k
- Type: System..::..Int32On entry: if , the number of observations used to initialize the smoothing.If , k is not referenced.Constraints:
- if and or , ;
- if and , or , .
- init
- Type: array<System..::..Double>[]()[][]An array of size [_linit]Note: the dimension of the array init must be at least if , if or and at least if or .On entry: if , the initial values for , and , for , used to initialize the smoothing.If , and the remaining elements of init are not referenced.If or , and and the remaining elements of init are not referenced.If or , , and to hold the values for , for . The remaining elements of init are not referenced.On exit: if , the values used to initialize the smoothing. These are in the same order as described above.
- nf
- Type: System..::..Int32On entry: the number of forecasts required beyond the end of the series. Note, the one step ahead forecast is always produced.Constraint: .
- fv
- Type: array<System..::..Double>[]()[][]An array of size [nf]On exit: , for , the next nf step forecasts. Where , if , else is the total number of smoothed and forecast values already produced.
- fse
- Type: array<System..::..Double>[]()[][]An array of size [nf]On exit: the forecast standard errors for the values given in fv.
- yhat
- Type: array<System..::..Double>[]()[][]An array of size [n]On exit: , for , the one step ahead forecast values, with being the one step ahead forecast of .
- res
- Type: array<System..::..Double>[]()[][]An array of size [n]On exit: the residuals, , for .
- dv
- Type: System..::..Double%On exit: the square root of the mean deviation.
- ad
- Type: System..::..Double%On exit: the mean absolute deviation.
- r
- Type: array<System..::..Double>[]()[][]An array of size [_lr]Note: the dimension of the array r must be at least if , or and at least if or .On entry: if , r must contain the values as returned by a previous call to g05pm or g13am, r need not be set otherwise.If , or , only the first elements of r are referenced, otherwise the first elements are referenced.On exit: the information on the current state of the smoothing.
- ifail
- Type: System..::..Int32%On exit: unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).
Description
Exponential smoothing is a relatively simple method of short term forecasting for a time series. g13am 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,
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 g13be). 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 methods in E04 class.
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 g13am 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
Error Indicators and Warnings
Errors or warnings detected by the method:
On entry, , or .
On entry, , or .
On entry, or and .
- On entry, at least one of , or or .On entry, and .On entry, .
On entry, .
- A multiplicative Holt–Winters model cannot be used with the supplied data.
- On entry, and or .On entry, , or and .
On entry, .
- On entry, and the array r has not been initialized correctly.
Accuracy
Not applicable.
Parallelism and Performance
None.
Further Comments
Single exponential, Brown's double exponential and linear Holt smoothing methods are stable, whereas the two Holt–Winters methods can be affected by poor initial values for the seasonal components.
See also the method document for g05pm.
Example
This example smooths a time series relating to the rate of the earth's rotation about its polar axis.
Example program (C#): g13ame.cs