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

Class RegressionModel

  • All Implemented Interfaces:
    ForecastingModel


    public class RegressionModel
    extends AbstractForecastingModel
    Implements a single variable linear regression model using the variable named in the constructor as the independent variable. The cofficients of the regression - the intercept and the slope - as well as the accuracy indicators are determined from the data set passed to init.

    Once initialized, this model can be applied to another data set using the forecast method to forecast values of the dependent variable based on values of the dependent variable (the one named in the constructor).

    A single variable linear regression model essentially attempts to put a straight line through the data points. For the more mathematically inclined, this line is defined by its gradient or slope, and the point at which it intercepts the x-axis (i.e. where the independent variable has, perhaps only theoretically, a value of zero). Mathematically, assuming the independent variable is x and the dependent variable is y, then this line can be represented as:

    y = intercept + slope * x
    • Constructor Summary

      Constructors 
      Constructor and Description
      RegressionModel(java.lang.String independentVariable)
      Constructs a new linear regression model, using the given name as the independent variable.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      double forecast(DataPoint dataPoint)
      Using the current model parameters (initialized in init), apply the forecast model to the given data point.
      java.lang.String getForecastType()
      Returns a short name for this type of forecasting model.
      int getNumberOfPredictors()
      Returns the number of predictors used by the underlying model.
      void init(DataSet dataSet)
      Initializes the coefficients to use for this regression model.
      java.lang.String toString()
      Returns a detailed description of this forcasting model, including the intercept and slope.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • RegressionModel

        public RegressionModel(java.lang.String independentVariable)
        Constructs a new linear regression model, using the given name as the independent variable. For a valid model to be constructed, you should call init and pass in a data set containing a series of data points involving the given independent variable.
        Parameters:
        independentVariable - the name of the independent variable to use in this model.
    • Method Detail

      • init

        public void init(DataSet dataSet)
        Initializes the coefficients to use for this regression model. The intercept and slope are derived so as to give the best fit line for the given data set.

        Additionally, the accuracy indicators are calculated based on this data set.

        Parameters:
        dataSet - the set of observations to use to derive the regression coefficients for this model.
      • forecast

        public double forecast(DataPoint dataPoint)
                        throws ModelNotInitializedException
        Using the current model parameters (initialized in init), apply the forecast model to the given data point. The data point must have valid values for the independent variables. Upon return, the value of the dependent variable will be updated with the forecast value computed for that data point.
        Parameters:
        dataPoint - the data point for which a forecast value (for the dependent variable) is required.
        Returns:
        the same data point passed in but with the dependent value updated to contain the new forecast value.
        Throws:
        ModelNotInitializedException - if forecast is called before the model has been initialized with a call to init.
      • getForecastType

        public java.lang.String getForecastType()
        Returns a short name for this type of forecasting model. A more detailed explanation is provided by the toString method.
        Returns:
        a short string describing this type of forecasting model.
      • getNumberOfPredictors

        public int getNumberOfPredictors()
        Returns the number of predictors used by the underlying model.
        Returns:
        the number of predictors used by the underlying model.
        Since:
        0.5
      • toString

        public java.lang.String toString()
        Returns a detailed description of this forcasting model, including the intercept and slope. A shortened version of this is provided by the getForecastType method.
        Specified by:
        toString in interface ForecastingModel
        Overrides:
        toString in class java.lang.Object
        Returns:
        a description of this forecasting model.

DataMelt 3.0 © DataMelt by jWork.ORG

Ads help maintain this website.