|
|||||||||
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.DoubleExponentialSmoothingModel
public class DoubleExponentialSmoothingModel
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:
Yt
is the observed value at time t.ft
is the forecast at time t.bt
is 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,
f1
is set to Y1
, and the
initial slope b1
is 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.
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 Forecaster
class can help with
selection of the best values for the smoothing constants.
Field Summary |
---|
Fields inherited from class net.sourceforge.openforecast.models.AbstractForecastingModel |
---|
accuracyIndicators, initialized |
Constructor Summary | |
---|---|
DoubleExponentialSmoothingModel(double alpha,
double gamma)
Constructs a new double exponential smoothing forecasting model, using the given smoothing constants - alpha and gamma. |
Method Summary | |
---|---|
protected void |
calculateAccuracyIndicators(DataSet dataSet)
Since this version of double exponential smoothing uses the current observation to calculate a smoothed value, we must override the calculation of the accuracy indicators. |
protected double |
forecast(double t)
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 DoubleExponentialSmoothingModel |
getBestFitModel(DataSet dataSet)
Factory method that returns a "best fit" double exponential smoothing model for the given data set. |
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. |
String |
getForecastType()
Returns a one or two word name of this type of forecasting model. |
double |
getGamma()
Returns the value of the trend 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. |
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, init, 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 DoubleExponentialSmoothingModel(double alpha, double gamma)
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.
IllegalArgumentException
- if the value of either smoothing
constant is invalid - outside the range 0.0-1.0.Method Detail |
---|
public static DoubleExponentialSmoothingModel getBestFitModel(DataSet dataSet)
getBestFitModel(DataSet,double,double)
, attempts to derive
"good" - hopefully near optimal - values for the alpha and gamma
smoothing constants.
dataSet
- the observations for which a "best fit" double
exponential smoothing model is required.
getBestFitModel(DataSet,double,double)
public static DoubleExponentialSmoothingModel getBestFitModel(DataSet dataSet, double alphaTolerance, double gammaTolerance)
getBestFitModel(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.
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.
protected double forecast(double t) throws IllegalArgumentException
forecast
in class AbstractTimeBasedModel
t
- 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.protected int getNumberOfPeriods()
getNumberOfPeriods
in class AbstractTimeBasedModel
public int getNumberOfPredictors()
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()
getGamma()
public double getGamma()
getAlpha()
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 |