|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.openforecast.models.AbstractForecastingModel
net.sourceforge.openforecast.models.AbstractTimeBasedModel
net.sourceforge.openforecast.models.WeightedMovingAverageModel
net.sourceforge.openforecast.models.MovingAverageModel
public class MovingAverageModel
A moving average forecast model is based on an artificially constructed time series in which the value for a given time period is replaced by the mean of that value and the values for some number of preceding and succeeding time periods. As you may have guessed from the description, this model is best suited to time-series data; i.e. data that changes over time. For example, many charts of individual stocks on the stock market show 20, 50, 100 or 200 day moving averages as a way to show trends.
Since the forecast value for any given period is an average of the previous periods, then the forecast will always appear to "lag" behind either increases or decreases in the observed (dependent) values. For example, if a data series has a noticable upward trend then a moving average forecast will generally provide an underestimate of the values of the dependent variable.
The moving average method has an advantage over other forecasting models in that it does smooth out peaks and troughs (or valleys) in a set of observations. However, it also has several disadvantages. In particular this model does not produce an actual equation. Therefore, it is not all that useful as a medium-long range forecasting tool. It can only reliably be used to forecast one or two periods into the future.
The moving average model is a special case of the more general weighted moving average. In the simple moving average, all weights are equal.
Field Summary |
---|
Fields inherited from class net.sourceforge.openforecast.models.AbstractForecastingModel |
---|
accuracyIndicators, initialized |
Constructor Summary | |
---|---|
MovingAverageModel()
Constructs a new moving average forecasting model. |
|
MovingAverageModel(int period)
Constructs a new moving average forecasting model, using the specified period. |
|
MovingAverageModel(String independentVariable)
Deprecated. As of 0.4, replaced by MovingAverageModel(java.lang.String, int) . |
|
MovingAverageModel(String independentVariable,
int period)
Deprecated. As of 0.4, replaced by MovingAverageModel(int) . |
Method Summary | |
---|---|
String |
getForecastType()
Returns a one or two word name of this type of forecasting model. |
void |
init(DataSet dataSet)
Used to initialize the moving average 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.WeightedMovingAverageModel |
---|
forecast, getNumberOfPeriods, getNumberOfPredictors, setWeights |
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 |
---|
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 |
Constructor Detail |
---|
public MovingAverageModel()
public MovingAverageModel(String independentVariable)
MovingAverageModel(java.lang.String, int)
.
independentVariable
- the name of the independent variable to use
in this model.public MovingAverageModel(int period)
The period value is used to determine the number of observations to be used to calculate the moving average. For example, for a 50-day moving average where the data points are daily observations, then the period should be set to 50.
The period is also used to determine the amount of future periods that can effectively be forecast. With a 50 day moving average, then we cannot reasonably - with any degree of accuracy - forecast more than 50 days beyond the last period for which data is available. This may be more beneficial than, say a 10 day period, where we could only reasonably forecast 10 days beyond the last period.
period
- the number of observations to be used to calculate the
moving average.public MovingAverageModel(String independentVariable, int period)
MovingAverageModel(int)
.
independentVariable
- the name of the independent variable to use
in this model.period
- the number of observations to be used to calculate the
moving average.Method Detail |
---|
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.public String getForecastType()
getForecastType
in interface ForecastingModel
getForecastType
in class WeightedMovingAverageModel
public String toString()
toString
in interface ForecastingModel
toString
in class WeightedMovingAverageModel
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |