|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sourceforge.openforecast.models.AbstractForecastingModel net.sourceforge.openforecast.models.AbstractTimeBasedModel net.sourceforge.openforecast.models.TripleExponentialSmoothingModel
public class TripleExponentialSmoothingModel
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.
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.
Field Summary |
---|
Fields inherited from class net.sourceforge.openforecast.models.AbstractForecastingModel |
---|
accuracyIndicators, initialized |
Constructor Summary | |
---|---|
TripleExponentialSmoothingModel(double alpha,
double beta,
double gamma)
Constructs a new triple exponential smoothing forecasting model, using the given smoothing constants - alpha, beta and gamma. |
Method Summary | |
---|---|
protected void |
calculateAccuracyIndicators(DataSet dataSet)
Since this version of triple exponential smoothing uses the current observation to calculate a smoothed value, we must override the calculation of the accuracy indicators. |
protected double |
forecast(double time)
Returns the forecast value of the dependent variable for the given value of the (independent) time variable using a single exponential smoothing model. |
double |
getAlpha()
Returns the value of the smoothing constant, alpha, used in this model. |
static TripleExponentialSmoothingModel |
getBestFitModel(DataSet dataSet)
Factory method that returns a "best fit" triple exponential smoothing model for the given data set. |
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. |
double |
getBeta()
Returns the value of the trend smoothing constant, beta, used in this model. |
String |
getForecastType()
Returns a one or two word name of this type of forecasting model. |
double |
getGamma()
Returns the value of the seasonal smoothing constant, gamma, used in this model. |
protected int |
getNumberOfPeriods()
Returns the current number of periods used in this model. |
int |
getNumberOfPredictors()
Returns the number of predictors used by the underlying model. |
void |
init(DataSet dataSet)
Used to initialize the time based model. |
String |
toString()
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, getForecastValue, getIndependentVariable, getMaximumTimeValue, getMinimumTimeValue, getObservedValue, getTimeInterval, getTimeVariable, initTimeVariable |
Methods inherited from class net.sourceforge.openforecast.models.AbstractForecastingModel |
---|
forecast, getAIC, getBias, getMAD, getMAPE, getMSE, getSAE |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public TripleExponentialSmoothingModel(double alpha, double beta, double gamma)
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.
IllegalArgumentException
- if the value of any of the smoothing
constants are invalid - outside the range 0.0-1.0.Method Detail |
---|
public static TripleExponentialSmoothingModel getBestFitModel(DataSet dataSet)
getBestFitModel(DataSet,double,double)
, attempts to derive
"good" - hopefully near optimal - values for the alpha and beta
smoothing constants.
dataSet
- the observations for which a "best fit" triple
exponential smoothing model is required.
getBestFitModel(DataSet,double,double)
public static TripleExponentialSmoothingModel getBestFitModel(DataSet dataSet, double alphaTolerance, double betaTolerance)
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.
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.
public void init(DataSet dataSet)
init
in interface ForecastingModel
init
in class AbstractTimeBasedModel
dataSet
- a data set of observations that can be used to
initialize the forecasting parameters of the forecasting model.protected double forecast(double time) throws IllegalArgumentException
forecast
in class AbstractTimeBasedModel
time
- the value of the time variable for which a forecast
value is required.
IllegalArgumentException
- if there is insufficient historical
data - observations passed to init - to generate a forecast for the
given time value.public int getNumberOfPredictors()
protected int getNumberOfPeriods()
getNumberOfPeriods
in class AbstractTimeBasedModel
protected void calculateAccuracyIndicators(DataSet dataSet)
calculateAccuracyIndicators
in class AbstractForecastingModel
dataSet
- the DataSet to use to evaluate this model, and to
calculate the accuracy indicators against.public double getAlpha()
getBeta()
,
getGamma()
public double getBeta()
getAlpha()
,
getGamma()
public double getGamma()
getAlpha()
,
getBeta()
public String getForecastType()
getForecastType
in interface ForecastingModel
getForecastType
in class AbstractTimeBasedModel
public String toString()
toString
in interface ForecastingModel
toString
in class AbstractTimeBasedModel
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |