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

Class MovingAverageModel

  • All Implemented Interfaces:
    ForecastingModel
    Direct Known Subclasses:
    NaiveForecastingModel


    public class MovingAverageModel
    extends WeightedMovingAverageModel
    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.

    Since:
    0.3
    • Constructor Detail

      • MovingAverageModel

        public MovingAverageModel()
        Constructs a new moving average forecasting model. 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.
      • MovingAverageModel

        public MovingAverageModel(java.lang.String independentVariable)
        Deprecated. As of 0.4, replaced by MovingAverageModel(java.lang.String, int).
        Constructs a new moving average forecasting model, using the given name as the independent variable.
        Parameters:
        independentVariable - the name of the independent variable to use in this model.
      • MovingAverageModel

        public MovingAverageModel(int period)
        Constructs a new moving average forecasting model, using the specified period. 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.

        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.

        Parameters:
        period - the number of observations to be used to calculate the moving average.
      • MovingAverageModel

        public MovingAverageModel(java.lang.String independentVariable,
                                  int period)
        Deprecated. As of 0.4, replaced by MovingAverageModel(int).
        Constructs a new moving average forecasting model, using the given name as the independent variable and the specified period.
        Parameters:
        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

      • init

        public void init(DataSet dataSet)
        Used to initialize the moving average model. This method must be called before any other method in the class. Since the moving average model does not derive any equation for forecasting, this method uses the input DataSet to calculate forecast values for all valid values of the independent time variable.
        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.
      • 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 WeightedMovingAverageModel
        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 WeightedMovingAverageModel
        Returns:
        a string representation of the current forecast model, and its parameters.

DataMelt 3.0 © DataMelt by jWork.ORG

Ads help maintain this website.