StatTimeSerAnalysis.SingleExpSmooth Method

Overload List

#SignatureDescription
1procedure SingleExpSmooth(const Y: TVec; const S: TVec; const Alpha: Double; out MSE: Double; const InitMethod: Integer);In this case a fixed smoothing constant Alpha is used in smoothing equations (no minimization is performed).
2function SingleExpSmooth(const Y: TVec; const S: TVec; var Alpha: Double; const InitMethod: Integer): Double;Single exponential smoothing.

Overload 1: procedure SingleExpSmooth(const Y: TVec; const S: TVec; const Alpha: Double; out MSE: Double; const InitMethod: Integer);

In this case a fixed smoothing constant Alpha is used in smoothing equations (no minimization is performed).

#NameDescription
1MSEReturns MSE, evaluated for constant Alpha.
2YTime series data set.
3SSmoothed values (see above equation). Size and complex properties of S are set automatically.
4AlphaDefines initial estimate for Alpha, returns Alpha which minimizes MSE.
5InitMethodDefines how the initial values for S[0] are calculated.

Result: stored in self (calling object)

Remarks:

C# Example
Load data, perform smoothing with Alpha = 0.33.

using Dew.Math;
using Dew.Stats;
using Dew.Stats.Units;
namespace Dew.Examples
{
  private void Example()
  {
    Vector Data = new Vector(0);
    Vector S = new Vector(0);
    Data.LoadFromFile("aerosol_particles.vec");
    // smooth data with Alpha=0.33
    double MSE;
    StatTimeSerAnalysis.SingleExpSmooth(Data,S,0.33,out MSE,0);
    // results: MSE
  }
}
Examples
#include "MtxExpr.hpp"
#include "Math387.hpp"
#include "StatTimeSerAnalysis.hpp"
void __fastcall Example()
{
    sVector Data,S;
    Data.LoadFromFile("aerosol_particles.vec");
    // smooth data with Alpha=0.33
    double MSE;
    SingleExpSmooth(Data,S,0.33,MSE,0);
    // results: MSE
}
Uses MtxExpr, StatTimeSerAnalysis, Math387;
procedure Example;
var Data,S: Vector;
    MSE: double;
begin
    Data.LoadFromFile('aerosol_particles.vec');
    // smooth data with Alpha=0.33
    SingleExpSmooth(Data,S,0.33,MSE,0);
    // results: MSE
end;
See Also: StatTimeSerAnalysis.SingleExpForecast

Overload 2: function SingleExpSmooth(const Y: TVec; const S: TVec; var Alpha: Double; const InitMethod: Integer): Double;

Single exponential smoothing.

#NameDescription
1YTime series data set.
2SSmoothed values (see above equation). Size and complex properties of S are set automatically.
3AlphaDefines initial estimate for Alpha, returns Alpha which minimizes MSE.
4InitMethodDefines how the initial values for S[0] are calculated.

Returns: Double - MSE, evaluated at minimum.

Remarks:

Performs single exponential smoothing using the following equation:

S[i]=αY[i1]+(1+α)S[i1],i=1,2n,0α1.S[i] = \alpha\cdot Y[i-1] + (1 + \alpha)\cdot S[i-1] \quad , \quad i=1,2\cdots n \qquad , \qquad 0\leq \alpha \leq 1 \quad .

This is the basic equation of exponential smoothing and the variable Alpha is called the smoothing constant. This smoothing scheme begins by setting S[0] to Y[0], where S[i] stands for smoothed observation and Y stands for the original observation. The subscripts refer to the time periods, 0, 1, ..., n. Note that there is no S[0]; the smoothed series starts with the smoothed version of the second observation. Also note that the internal algorithm automatically accounts for this by resizing S vector to Y.Length-1.

Setting S[0] to Y[0] is not mandatory. There are numerous ways to initialize S[0]. Some of the choices are:

S[0]=Y[0]orS[0]=14i=03Y[i]S[0] = Y[0] \quad \text{or} \quad S[0] = \frac{1}{4}\sum _{i=0} ^3 Y[i]

Different initialization methods are controlled by the InitMethod parameter. Default value (0) uses first equation, setting it to (1) means the second equation will be used to initialize S[0].

The smoothing constant alpha determines how fast the weights of the series decays. The value may be chosen either subjectively or objectively. Values near one put almost all weight on the most recent observations. Values of the smoothing constant near zero allow the distant past observations to have a large influence. When selecting the smoothing constant subjectively, you use your own experience with this, and similar, series. Also, specifying the smoothing constant yourself lets you tune the forecast to your own beliefs about the future of the series. If you believe that the mechanism generating the series has recently gone through some fundamental changes, use a smoothing constant value of 0.9 which will cause distant observations to be ignored. If, however, you think the series is fairly stable and only going through random fluctuations, use a value of 0.1.

Note
To select the value of the smoothing constant objectively, internal algorithm searches for an Alpha that minimizes the mean squared error (MSE)of the combined forecast errors of the currently available series.

Examples
Uses MtxExpr, StatTimeSerAnalysis, Math387;
procedure Example;
var Data,S: Vector;
Alpha,MSE: double;
begin
    Data.LoadFromFile('aerosol_particles.vec');
    // smooth data, initial alpha = 0.1
    Alpha := 0.1;
    MSE := SingleExpSmooth(Data,S,Alpha,0);
    // results: MSE and MLE estimate for Alpha
end;
See Also: StatTimeSerAnalysis.SingleExpForecast