Documentation of 'net.sourceforge.openforecast.models.TripleExponentialSmoothingModel' Java class
TripleExponentialSmoothingModel
net.sourceforge.openforecast.models

Class TripleExponentialSmoothingModel

  • All Implemented Interfaces:
    ForecastingModel


    public class TripleExponentialSmoothingModel
    extends AbstractTimeBasedModel
    Triple exponential smoothing - also known as the Winters method - is a refinement of the popular double exponential smoothing model but adds another component which takes into account any seasonality - or periodicity - 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. However, neither of these exponential smoothing models address any seasonality in the data.

    For better exponentially smoothed forecasts of data where there is expected or known to be seasonal variation in the data, use triple exponential smoothing.

    As with simple exponential smoothing, in triple 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. This is true for all terms involved - namely, the base level Lt, the trend Tt as well as the seasonality index st.

    There are four equations associated with Triple Exponential Smoothing.

    • Lt = a.(xt/st-c)+(1-a).(Lt-1+Tt-1)
    • Tt = b.(Lt-Lt-1)+(1-b).Tt-1
    • st = g.(xt/Lt)+(1-g).st-c
    • ft,k = (Lt+k.Tt).st+k-c

    where:

    • Lt is the estimate of the base value at time t. That is, the estimate for time t after eliminating the effects of seasonality and trend.
    • a - representing alpha - is the first smoothing constant, used to smooth Lt.
    • xt is the observed value at time t.
    • st is the seasonal index at time t.
    • c is the number of periods in the seasonal pattern. For example, c=4 for quarterly data, or c=12 for monthly data.
    • Tt is the estimated trend at time t.
    • b - representing beta - is the second smoothing constant, used to smooth the trend estimates.
    • g - representing gamma - is the third smoothing constant, used to smooth the seasonality estimates.
    • ft,k is the forecast at time the end of period t for the period t+k.

    There are a variety of different ways to come up with initial values for the triple exponential smoothing model. The approach implemented here uses the first two "years" (or complete cycles) of data to come up with initial values for Lt, Tt and st. Therefore, at least two complete cycles of data are required to initialize the model. For best results, more data is recommended - ideally a minimum of 4 or 5 complete cycles. This gives the model chance to better adapt to the data, instead of relying on getting - guessing - good estimates for the initial conditions.

    Choosing values for the smoothing constants

    The smoothing constants a, b, and g each must be a value 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 getBestFitModel(net.sourceforge.openforecast.DataSet) static methods can help with the selection of the best values for the smoothing constants, though the results obtained from these methods should always be validated. If any of the "best fit" smoothing constants turns out to be 1.0, you may want to be a little suspicious. This may be an indication that you really need to use more data to initialize the model.

    Since:
    0.4
    See Also:
    Engineering Statistics Handbook, 6.4.3.5 Triple Exponential Smoothing
    • Constructor Detail

      • TripleExponentialSmoothingModel

        public TripleExponentialSmoothingModel(double alpha,
                                               double beta,
                                               double gamma)
        Constructs a new triple exponential smoothing forecasting model, using the given smoothing constants - alpha, beta 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. Values above 0.5 are uncommon - though they are still valid and are supported by this implementation.
        beta - the second smoothing constant, beta to use in this model to smooth the trend. Must be a value in the range 0.0-1.0. Values above 0.5 are uncommon - though they are still valid and are supported by this implementation.
        gamma - the third smoothing constant, gamma to use in this model to smooth the seasonality. Must be a value in the range 0.0-1.0.
        Throws:
        java.lang.IllegalArgumentException - if the value of any of the smoothing constants are invalid - outside the range 0.0-1.0.
    • Method Detail

      • getBestFitModel

        public static TripleExponentialSmoothingModel getBestFitModel(DataSet dataSet)
        Factory method that returns a "best fit" triple exponential smoothing model for the given data set. This, like the overloaded getBestFitModel(DataSet,double,double), attempts to derive "good" - hopefully near optimal - values for the alpha and beta smoothing constants.
        Parameters:
        dataSet - the observations for which a "best fit" triple exponential smoothing model is required.
        Returns:
        a best fit triple exponential smoothing model for the given data set.
        See Also:
        getBestFitModel(DataSet,double,double)
      • getBestFitModel

        public static TripleExponentialSmoothingModel getBestFitModel(DataSet dataSet,
                                                                      double alphaTolerance,
                                                                      double betaTolerance)
        Factory method that returns a best fit triple exponential smoothing model for the given data set. This, like the overloaded getBestFitModel(DataSet), attempts to derive "good" - hopefully near optimal - values for the alpha and beta 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 beta - is expected to be very similar either way.

        Note that the approach used to calculate the best smoothing constants - alpha and beta - may end up choosing values near a local optimum. In other words, there may be other values for alpha and beta that result in an even better model.

        Parameters:
        dataSet - the observations for which a "best fit" triple exponential smoothing model is required.
        alphaTolerance - the required precision/accuracy - or tolerance of error - required in the estimate of the alpha smoothing constant.
        betaTolerance - the required precision/accuracy - or tolerance of error - required in the estimate of the beta smoothing constant.
        Returns:
        a best fit triple exponential smoothing model for the given data set.
      • init

        public void init(DataSet dataSet)
        Used to initialize the time based model. This method must be called before any other method in the class. Since the time based model does not derive any equation for forecasting, this method uses the input DataSet to calculate forecast values for all values of the independent time variable within the initial data set.
        Specified by:
        init in interface ForecastingModel
        Overrides:
        init in class AbstractTimeBasedModel
        Parameters:
        dataSet - a data set of observations that can be used to initialize the forecasting parameters of the forecasting model.
      • 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:
        getBeta(), getGamma()
      • getBeta

        public double getBeta()
        Returns the value of the trend smoothing constant, beta, used in this model.
        Returns:
        the value of the trend smoothing constant, beta.
        See Also:
        getAlpha(), getGamma()
      • getGamma

        public double getGamma()
        Returns the value of the seasonal smoothing constant, gamma, used in this model.
        Returns:
        the value of the seasonal smoothing constant, gamma.
        See Also:
        getAlpha(), getBeta()
      • 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:
        getForecastType in interface ForecastingModel
        Overrides:
        getForecastType in class AbstractTimeBasedModel
        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:
        toString in interface ForecastingModel
        Overrides:
        toString in class AbstractTimeBasedModel
        Returns:
        a string representation of the current forecast model, and its parameters.

DataMelt 3.0 © DataMelt by jWork.ORG

Ads help maintain this website.