|
|||||||||
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.RegressionModel
public class RegressionModel
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
Field Summary |
---|
Fields inherited from class net.sourceforge.openforecast.models.AbstractForecastingModel |
---|
accuracyIndicators, initialized |
Constructor Summary | |
---|---|
RegressionModel(String independentVariable)
Constructs a new linear regression model, using the given name as the independent variable. |
Method Summary | |
---|---|
double |
forecast(DataPoint dataPoint)
Using the current model parameters (initialized in init), apply the forecast model to the given data point. |
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. |
String |
toString()
Returns a detailed description of this forcasting model, including the intercept and slope. |
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 RegressionModel(String independentVariable)
independentVariable
- the name of the independent variable to use
in this model.Method Detail |
---|
public void init(DataSet dataSet)
Additionally, the accuracy indicators are calculated based on this data set.
dataSet
- the set of observations to use to derive the regression
coefficients for this model.public double forecast(DataPoint dataPoint) throws ModelNotInitializedException
dataPoint
- the data point for which a forecast value (for the
dependent variable) is required.
ModelNotInitializedException
- if forecast is called before the
model has been initialized with a call to init.public String getForecastType()
public int getNumberOfPredictors()
public String toString()
toString
in interface ForecastingModel
toString
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |