|
|||||||||
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.SimpleExponentialSmoothingModel
public class SimpleExponentialSmoothingModel
A simple exponential smoothing forecast model is a very popular model used to produce a smoothed Time Series. Whereas in simple Moving Average models the past observations are weighted equally, Exponential Smoothing assigns exponentially decreasing weights as the observations get older.
In other words, recent observations are given relatively more weight in forecasting than the older observations.
In the case of moving averages, the weights assigned to the observations are the same and are equal to 1/N. In simple exponential smoothing, however, a "smoothing parameter" - or "smoothing constant" - is used to determine the weights assigned to the observations.
This simple exponential smoothing model begins by setting the forecast for the second period equal to the observation of the first period. Note that there are ways of initializing 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 constant must be a value in the range 0.0-1.0. But, what is the "best" value to use for the smoothing constant? This depends on the data series being modeled. 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).
This class supports two approaches to forecasting using Simple Exponential Smoothing. The first approach - and the default approach - is to use the formulation according to Hunter. Hunter's formulation uses the observed and forecast values from the previous period to come up with a forecast for the current period.
An alternative formulation is also supported - that proposed by Roberts. The formulation according to Roberts uses the observed value from the current period and the forecast value from the previous period to come up with a forecast for the current period.
By default, the formulation according to Hunter is used. To override
this, use the three argument
constructor
and specify ROBERTS
as the third argument.
Field Summary | |
---|---|
static int |
HUNTER
Used in the three argument
constructor to specify that Hunter's formula is to be used for
calculating forecast values. |
static int |
ROBERTS
Used in the three argument
constructor to specify that Robert's formula is to be used for
calculating forecast values. |
Fields inherited from class net.sourceforge.openforecast.models.AbstractForecastingModel |
---|
accuracyIndicators, initialized |
Constructor Summary | |
---|---|
SimpleExponentialSmoothingModel(double alpha)
Constructs a new simple exponential smoothing forecasting model, using the specified smoothing constant. |
|
SimpleExponentialSmoothingModel(double alpha,
int approach)
Constructs a new exponential smoothing forecasting model, using the given name as the independent variable and the specified smoothing constant. |
|
SimpleExponentialSmoothingModel(String independentVariable,
double alpha)
Deprecated. As of 0.4, replaced by SimpleExponentialSmoothingModel(double) . |
|
SimpleExponentialSmoothingModel(String independentVariable,
double alpha,
int approach)
Deprecated. As of 0.4, replaced by SimpleExponentialSmoothingModel(double,int) . |
Method Summary | |
---|---|
protected double |
forecast(double timeValue)
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 SimpleExponentialSmoothingModel |
getBestFitModel(DataSet dataSet)
Factory method that returns a "best fit" simple exponential smoothing model for the given data set. |
static SimpleExponentialSmoothingModel |
getBestFitModel(DataSet dataSet,
double alphaTolerance)
Factory method that returns a best fit simple exponential smoothing model for the given data set. |
String |
getForecastType()
Returns a one or two word name of this type of forecasting 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 |
---|
calculateAccuracyIndicators, forecast, getAIC, getBias, getMAD, getMAPE, getMSE, getSAE |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int HUNTER
three argument
constructor
to specify that Hunter's formula is to be used for
calculating forecast values. The formulation according to Hunter uses
the observed and forecast values from the previous period to come up
with a forecast for the current period.
public static final int ROBERTS
three argument
constructor
to specify that Robert's formula is to be used for
calculating forecast values. The formulation according to Roberts uses
the observed value from the current period and the forecast value from
the previous period to come up with a forecast for the current period.
Constructor Detail |
---|
public SimpleExponentialSmoothingModel(double alpha)
alpha
- the smoothing constant to use for this exponential
smoothing model. Must be a value in the range 0.0-1.0.
IllegalArgumentException
- if the value of the smoothing constant
is invalid - outside the range 0.0-1.0.public SimpleExponentialSmoothingModel(String independentVariable, double alpha)
SimpleExponentialSmoothingModel(double)
.
independentVariable
- the name of the independent variable - or
time variable - to use in this model.alpha
- the smoothing constant to use for this exponential
smoothing model. Must be a value in the range 0.0-1.0.
IllegalArgumentException
- if the value of the smoothing constant
is invalid - outside the range 0.0-1.0.public SimpleExponentialSmoothingModel(double alpha, int approach)
alpha
- the smoothing constant to use for this exponential
smoothing model. Must be a value in the range 0.0-1.0.approach
- determines which approach to use for the forecasting.
This must be either HUNTER
- the default - or ROBERTS
.
IllegalArgumentException
- if the value of the smoothing constant
is invalid - outside the range 0.0-1.0.public SimpleExponentialSmoothingModel(String independentVariable, double alpha, int approach)
SimpleExponentialSmoothingModel(double,int)
.
independentVariable
- the name of the independent variable - or
time variable - to use in this model.alpha
- the smoothing constant to use for this exponential
smoothing model. Must be a value in the range 0.0-1.0.approach
- determines which approach to use for the forecasting.
This must be either HUNTER
- the default - or ROBERTS
.
IllegalArgumentException
- if the value of the smoothing constant
is invalid - outside the range 0.0-1.0.Method Detail |
---|
public static SimpleExponentialSmoothingModel getBestFitModel(DataSet dataSet)
getBestFitModel(DataSet,double)
, attempts to derive a
"good" - hopefully near optimal - value for the alpha smoothing
constant.
dataSet
- the observations for which a "best fit" simple
exponential smoothing model is required.
getBestFitModel(DataSet,double)
public static SimpleExponentialSmoothingModel getBestFitModel(DataSet dataSet, double alphaTolerance)
getBestFitModel(DataSet)
, attempts to derive a "good" -
hopefully near optimal - value for the alpha smoothing constant.
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 value of alpha - is expected to be very similar either way.
Note that the approach used to calculate the best smoothing constant, alpha, may end up choosing values near a local optimum. In other words, there may be other values for alpha and that result in a model with the same, or even better MSE.
dataSet
- the observations for which a "best fit" simple
exponential smoothing model is required.alphaTolerance
- the required precision/accuracy - or tolerance
of error - required in the estimate of the alpha smoothing constant.
protected double forecast(double timeValue) throws IllegalArgumentException
forecast
in class AbstractTimeBasedModel
timeValue
- 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()
public double 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 |