Dew Stats Master .NET
SingleExpForecast Routines
Summary
Single exponential forecast.

Unit
StatTimeSerAnalysis

Declaration
Procedure SingleExpForecast(Y: TVec; YHat: TVec; const Alpha: TSample; T: Integer; InitMethod: Integer = 0);
 Parameter  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. 

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

Categories
Time series analysis routines
 See Also 
SingleExpSmooth 

Example 1

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,YHat.Length); end;
#include "MtxVecCpp.h" #include "Math387.hpp" #include "StatTimeSerAnalysis.hpp" void __fastcall Example(); { Vector 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,YHat->Length); }
using Dew.Math; using Dew.Stats; using Dew.Stats.Units; namespace Dew.Examples { private void Example() { Vector Data = new Vector(0); Vector YHat = new Vector(0); Vector Residuals = new Vector(0); 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,YHat.Length); } }


Declaration
Procedure SingleExpForecast(Y: TVec; YHat: TVec; var Alpha: TSample; T: Integer; out MSE: TSample; InitMethod: Integer = 0);
 Parameter  Description 
MSE MSE, evaluated at minimum. 

Description
First estimate Alpha parameters by single smoothing and then use returned value to forecast up to T periods. Use this routine if you don't know the best estimates for Alpha.

Example 1

Do estimation and forecasting in single routine call.
Uses MtxExpr, StatTimeSerAnalysis, Math387; procedure Example; var Data,YHat: Vector; Alpha: TSample; T, NumPoints: Integer; begin NumPoints := 20; Data.LoadFromFile('aerosol_particles.vec'); // last point period = Data.Length-1 + NumPoints T := Data.Length-1+NumPoints; // initial Alpha estimate = 0.6 Alpha := 0.6; SingleExpForecast(Data,YHat,Alpha,T,MSE,0); // returs MSE and estimated Alpha (from MLE) end;
#include "MtxVecCpp.h" #include "Math387.hpp" #include "StatTimeSerAnalysis.hpp" void __fastcall Example(); { Vector Data,YHat; int NumPoints = 20; Data->LoadFromFile("aerosol_particles.vec"); // last point period = Data.Length-1 + NumPoints int T = Data.Length-1+NumPoints; // initial alpha estimate = 0.6 double alpha := 0.6; double mse; SingleExpForecast(Data,YHat,alpha,T,mse,0); // returs mse and estimated Alpha (from MLE) }
using Dew.Math; using Dew.Stats; using Dew.Stats.Units; namespace Dew.Examples { private void Example() { Vector Data = new Vector(0); Vector YHat = new Vector(0); int NumPoints = 20; Data.LoadFromFile("aerosol_particles.vec"); // last point period = Data.Length-1 + NumPoints int T = Data.Length-1+NumPoints; // initial alpha estimate = 0.6 double alpha := 0.6; double mse; StatTimeSerAnalysis.SingleExpForecast(Data,YHat,ref alpha,T,out mse,0); // returs mse and estimated Alpha (from MLE) } }

Copyright 2008 Dew Research
http://www.dewresearch.com