|
|||||||||
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.PolynomialRegressionModel
public class PolynomialRegressionModel
Implements a single variable polynomial regression model using the variable named in the constructor as the independent variable. The cofficients of the regression 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 polynomial regression model essentially attempts to put a polynomial line - a curve if you prefer - through the data points. Mathematically, assuming the independent variable is x and the dependent variable is y, then this line can be represented as:
y = a0 + a1*x + a2*x2 + a3*x3 + ... + am*xmYou can specify the order of the polynomial fit (the value of
m
in the above equation) in the constructor.
Field Summary |
---|
Fields inherited from class net.sourceforge.openforecast.models.AbstractForecastingModel |
---|
accuracyIndicators, initialized |
Constructor Summary | |
---|---|
PolynomialRegressionModel(String independentVariable)
Constructs a new polynomial regression model, using the given name as the independent variable. |
|
PolynomialRegressionModel(String independentVariable,
int order)
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 PolynomialRegressionModel(String independentVariable)
Using this constructor the order of the polynomial fit is not specified. The effect is that the model will try to determine an appropriate order for the given data. It will do this by calculating up to 10 coefficients and once the coefficients become numerically insignificant they will be excluded from the model.
independentVariable
- the name of the independent variable to use
in this model.public PolynomialRegressionModel(String independentVariable, int order)
independentVariable
- the name of the independent variable to use
in this model.order
- the required order of the polynomial to fit.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)
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 int getNumberOfPredictors()
public String getForecastType()
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 |