You are here: Symbol Reference > StatTimeSerAnalysis Namespace > Functions > StatTimeSerAnalysis.SingleExpForecast Function
Stats Master VCL
ContentsIndex
PreviousUpNext
StatTimeSerAnalysis.SingleExpForecast Function

Single exponential forecast.

Pascal
procedure SingleExpForecast(const Y: TVec; const YHat: TVec; const Alpha: double; const T: Integer; const InitMethod: Integer = 0); overload;
Parameters 
Description 
Time series data set. 
YHat 
Time series forecasts. Size of the YHat vector are adjusted automatically. 
Alpha 
Overal smoothing parameter used for forecast. 
Forecast values up to T period. 
InitMethod 
Defines how the initial values for S[0] are calculated. 

Forecasts time series values by using single exponential smoothing equations. For single exponential smoothing, the h period ahead forecast is given by: 

 

 

Load data, assume Alpha is 0.33, forecast 20 points past the last value.

Uses MtxExpr, StatTimeSerAnalysis, Math387;
procedure Example;
var Data,YHat: Vector;
    T: Integer;
    NumPoints: Integer;
    Residuals: TVec;
begin
  NumPoints := 20;
  Data.LoadFromFile('aerosol_particles.vec');
  // last point period = Data.Length-1 + NumPoints
  T := Data.Length-1+NumPoints;
  SingleExpForecast(Data,YHat,0.33,T,0);
  // YHat now stores estimates for YHat[1,...Length-1]
  // so, if we need residuals, we have to subtract
  // these values from y[1,...,Length-1)
  Residuals.Size(YHat);
  Residuals.Sub(Y,YHat,1,0,0,YHat.Length);
end;
#include "MtxExpr.hpp"
#include "Math387.hpp"
#include "StatTimeSerAnalysis.hpp"
void __fastcall Example();
{
    sVector Data,YHat, Residuals;
    int NumPoints = 20;
    Data.LoadFromFile("aerosol_particles.vec");
    // last point period = Data.Length-1 + NumPoints
    int T = Data.Length-1+NumPoints;
    SingleExpForecast(Data,YHat,0.33,T,0);
    // YHat now stores estimates for YHat[1,...Length-1]
    // so, if we need residuals, we have to subtract
    // these values from y[1,...,Length-1)
    Residuals.Size(YHat);
    Residuals.Sub(Y,YHat,1,0,0,YHat.Length);
}
Examples on GitHub
Copyright (c) 1999-2024 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!