Class DoubleExponentialSmoothingModel
- java.lang.Object
-
- net.sourceforge.openforecast.models.AbstractForecastingModel
-
- net.sourceforge.openforecast.models.AbstractTimeBasedModel
-
- net.sourceforge.openforecast.models.DoubleExponentialSmoothingModel
-
- All Implemented Interfaces:
- ForecastingModel
public class DoubleExponentialSmoothingModel extends AbstractTimeBasedModel
Double exponential smoothing - also known as Holt exponential smoothing - is a refinement of the popular simple exponential smoothing model but adds another component which takes into account any trend in the data. Simple exponential smoothing models work best with data where there are no trend or seasonality components to the data. When the data exhibits either an increasing or decreasing trend over time, simple exponential smoothing forecasts tend to lag behind observations. Double exponential smoothing is designed to address this type of data series by taking into account any trend in the data.Note that double exponential smoothing still does not address seasonality. For better exponentially smoothed forecasts using data where there is expected or known to be seasonal variation in the data, use triple exponential smoothing.
As with simple exponential smoothing, in double exponential smoothing models past observations are given exponentially smaller weights as the observations get older. In other words, recent observations are given relatively more weight in forecasting than the older observations.
There are two equations associated with Double Exponential Smoothing.
ft = a.Yt+(1-a)(ft-1+bt-1)bt = g.(ft-ft-1)+(1-g).bt-1
where:
Ytis the observed value at time t.ftis the forecast at time t.btis the estimated slope at time t.a- representing alpha - is the first smoothing constant, used to smooth the observations.g- representing gamma - is the second smoothing constant, used to smooth the trend.
To initialize the double exponential smoothing model,
f1is set toY1, and the initial slopeb1is set to the difference between the first two observations; i.e.Y2-Y1. Although there are other ways to initialize the model, as of the time of writing, these alternatives are not available in this implementation. Future implementations of this model may offer these options.Choosing values for the smoothing constants
The smoothing constants must be a values in the range 0.0-1.0. But, what are the "best" values to use for the smoothing constants? This depends on the data series being modeled.
In general, the speed at which the older responses are dampened (smoothed) is a function of the value of the smoothing constant. When this smoothing constant is close to 1.0, dampening is quick - more weight is given to recent observations - and when it is close to 0.0, dampening is slow - and relatively less weight is given to recent observations.
The best value for the smoothing constant is the one that results in the smallest mean of the squared errors (or other similar accuracy indicator). The
Forecasterclass can help with selection of the best values for the smoothing constants.- Since:
- 0.4
- See Also:
- Engineering Statistics Handbook, 6.4.3.3 Double Exponential Smoothing
-
-
Constructor Summary
Constructors Constructor and Description DoubleExponentialSmoothingModel(double alpha, double gamma)Constructs a new double exponential smoothing forecasting model, using the given smoothing constants - alpha and gamma.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description doublegetAlpha()Returns the value of the smoothing constant, alpha, used in this model.static DoubleExponentialSmoothingModelgetBestFitModel(DataSet dataSet)Factory method that returns a "best fit" double exponential smoothing model for the given data set.static DoubleExponentialSmoothingModelgetBestFitModel(DataSet dataSet, double alphaTolerance, double gammaTolerance)Factory method that returns a best fit double exponential smoothing model for the given data set.java.lang.StringgetForecastType()Returns a one or two word name of this type of forecasting model.doublegetGamma()Returns the value of the trend smoothing constant, gamma, used in this model.intgetNumberOfPredictors()Returns the number of predictors used by the underlying model.java.lang.StringtoString()This should be overridden to provide a textual description of the current forecasting model including, where possible, any derived parameters used.-
Methods inherited from class net.sourceforge.openforecast.models.AbstractTimeBasedModel
forecast, getIndependentVariable, getMaximumTimeValue, getMinimumTimeValue, getTimeVariable, init
-
-
-
-
Constructor Detail
-
DoubleExponentialSmoothingModel
public DoubleExponentialSmoothingModel(double alpha, double gamma)Constructs a new double exponential smoothing forecasting model, using the given smoothing constants - alpha and gamma. For a valid model to be constructed, you should call init and pass in a data set containing a series of data points with the time variable initialized to identify the independent variable.- Parameters:
alpha- the smoothing constant to use for this exponential smoothing model. Must be a value in the range 0.0-1.0.gamma- the second smoothing constant, gamma to use in this model to smooth the trend. Must be a value in the range 0.0-1.0.- Throws:
java.lang.IllegalArgumentException- if the value of either smoothing constant is invalid - outside the range 0.0-1.0.
-
-
Method Detail
-
getBestFitModel
public static DoubleExponentialSmoothingModel getBestFitModel(DataSet dataSet)
Factory method that returns a "best fit" double exponential smoothing model for the given data set. This, like the overloadedgetBestFitModel(DataSet,double,double), attempts to derive "good" - hopefully near optimal - values for the alpha and gamma smoothing constants.- Parameters:
dataSet- the observations for which a "best fit" double exponential smoothing model is required.- Returns:
- a best fit double exponential smoothing model for the given data set.
- See Also:
getBestFitModel(DataSet,double,double)
-
getBestFitModel
public static DoubleExponentialSmoothingModel getBestFitModel(DataSet dataSet, double alphaTolerance, double gammaTolerance)
Factory method that returns a best fit double exponential smoothing model for the given data set. This, like the overloadedgetBestFitModel(DataSet), attempts to derive "good" - hopefully near optimal - values for the alpha and gamma smoothing constants.To determine which model is "best", this method currently uses only the Mean Squared Error (MSE). Future versions may use other measures in addition to the MSE. However, the resulting "best fit" model - and the associated values of alpha and gamma - is expected to be very similar either way.
Note that the approach used to calculate the best smoothing constants - alpha and gamma - may end up choosing values near a local optimum. In other words, there may be other values for alpha and gamma that result in an even better model.
- Parameters:
dataSet- the observations for which a "best fit" double exponential smoothing model is required.alphaTolerance- the required precision/accuracy - or tolerance of error - required in the estimate of the alpha smoothing constant.gammaTolerance- the required precision/accuracy - or tolerance of error - required in the estimate of the gamma smoothing constant.- Returns:
- a best fit double exponential smoothing model for the given data set.
-
getNumberOfPredictors
public int getNumberOfPredictors()
Returns the number of predictors used by the underlying model.- Returns:
- the number of predictors used by the underlying model.
- Since:
- 0.5
-
getAlpha
public double getAlpha()
Returns the value of the smoothing constant, alpha, used in this model.- Returns:
- the value of the smoothing constant, alpha.
- See Also:
getGamma()
-
getGamma
public double getGamma()
Returns the value of the trend smoothing constant, gamma, used in this model.- Returns:
- the value of the trend smoothing constant, gamma.
- See Also:
getAlpha()
-
getForecastType
public java.lang.String getForecastType()
Returns a one or two word name of this type of forecasting model. Keep this short. A longer description should be implemented in the toString method.- Specified by:
getForecastTypein interfaceForecastingModel- Overrides:
getForecastTypein classAbstractTimeBasedModel- Returns:
- a string representation of the type of forecasting model implemented.
-
toString
public java.lang.String toString()
This should be overridden to provide a textual description of the current forecasting model including, where possible, any derived parameters used.- Specified by:
toStringin interfaceForecastingModel- Overrides:
toStringin classAbstractTimeBasedModel- Returns:
- a string representation of the current forecast model, and its parameters.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG