drasys.or.stat.model
Class LinearRegression

java.lang.Object
  |
  +--drasys.or.stat.model.LinearRegression
Direct Known Subclasses:
ReverseLinear, StepwiseLinear

public abstract class LinearRegression
extends java.lang.Object
implements LinearRegressionI

A multiple linear regression model abstract class. This class provides the basic functionality for multiple linear regression. It is an abstract class which must be subclassed to implement a specific solution search algorithm.

References:

Applied Linear Statistical Models (Irwin Series in Statistics)
    Michael H. Kutner, et al / Hardcover / Published 1996
Numerical Recipes in C : The Art of Scientific Computing
    William H. Press, et al / Hardcover / Published 1993


Field Summary
protected  double _cfstat
           
protected  VectorI _coef
           
protected  MatrixI _cov
           
protected  VectorI _dependent
           
protected  int[] _enteringVariables
           
protected  double _enterPValue
           
protected  double _exitPValue
           
protected  GeneralLinearModelI _glm
           
protected  MatrixI _independent
           
protected  double _lastConfidenceLevel
           
protected  VectorI _lower
           
protected  int _m
           
protected  int _n
           
protected  int[] _requiredVariables
           
protected  int[] _selectedVariables
           
protected  VectorI _stdv
           
protected  VectorI _tpvalue
           
protected  VectorI _tstat
           
protected  VectorI _upper
           
protected  boolean _zeroIntercept
           
 
Constructor Summary
LinearRegression(GeneralLinearModelI glm)
          Initialize the regression with an explicit general linear model.
LinearRegression(VectorI dependent, MatrixI independent)
          Initialize the regression with the sample data.
 
Method Summary
 int[] allVariables()
          A convenience method that returns an array that selects all of the independent variables.
 VectorI getCoefficients()
          Returns the selected variable coefficients.
 double getEnteringThreshold()
          Returns the p-value threshold used to select entering variables.
 int[] getEnteringVariables()
          Returns the internal array describing entering variable set.
 double getExitingThreshold()
          Returns the p-value threshold used to select exiting variables.
 double getF()
          Returns the 'F' statistic for the currrent model.
 double getFPV()
          Returns the one-sided p-value for the current 'F' statistic.
 GeneralLinearModelI getGLM()
          Returns the underlying general linear model used for solving the regression.
 VectorI getLowerBounds(double confidenceLevel)
          Returns the selected variable lower bounds.
 int[] getRequiredVariables()
          Returns the internal array describing required variable set.
 int[] getSelectedVariables()
          Returns the internal array describing current variable set.
 VectorI getT()
          Returns the 'T' statistics for the selected variables.
 VectorI getTPV()
          Returns the two-sided p-values for the 'T' statistics of the selected variables.
 double getTStatistic(double pValue)
          Returns the the 'T' statistic for a given p-value;
 VectorI getUpperBounds(double confidenceLevel)
          Returns the selected variable upper bounds.
 void setEnteringThreshold(double pValue)
          Sets the p-value threshold used to select entering variables.
 void setEnteringVariables(int[] variables)
          Selects the set of variables allowed to enter the model.
 void setExitingThreshold(double pValue)
          Sets the p-value threshold used to select exiting variables.
 void setRequiredVarables(int[] variables)
          Selects the set of variables that are forced into the final model.
 void setSelectedVariables(int[] variables)
          Selects the current variable set and and solves the model.
 java.lang.String toString()
          Creates a report describing fit of the current variables.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_m

protected int _m

_n

protected int _n

_selectedVariables

protected int[] _selectedVariables

_requiredVariables

protected int[] _requiredVariables

_enteringVariables

protected int[] _enteringVariables

_dependent

protected VectorI _dependent

_coef

protected VectorI _coef

_upper

protected VectorI _upper

_lower

protected VectorI _lower

_stdv

protected VectorI _stdv

_tstat

protected VectorI _tstat

_tpvalue

protected VectorI _tpvalue

_independent

protected MatrixI _independent

_cov

protected MatrixI _cov

_glm

protected GeneralLinearModelI _glm

_exitPValue

protected double _exitPValue

_enterPValue

protected double _enterPValue

_lastConfidenceLevel

protected double _lastConfidenceLevel

_cfstat

protected double _cfstat

_zeroIntercept

protected boolean _zeroIntercept
Constructor Detail

LinearRegression

public LinearRegression(VectorI dependent,
                        MatrixI independent)
Initialize the regression with the sample data. The model will use 'GeneralLinearModel' for the underlying GML algorithm.

LinearRegression

public LinearRegression(GeneralLinearModelI glm)
Initialize the regression with an explicit general linear model. The GML should be initialized with the sample data.
Method Detail

getGLM

public GeneralLinearModelI getGLM()
Returns the underlying general linear model used for solving the regression. The ANOVA statistics can be obtained directly from the GLM.
Specified by:
getGLM in interface LinearRegressionI

allVariables

public int[] allVariables()
A convenience method that returns an array that selects all of the independent variables. Returns - {0,1,2,...,n-1}.
Specified by:
allVariables in interface LinearRegressionI

setEnteringVariables

public void setEnteringVariables(int[] variables)
Selects the set of variables allowed to enter the model. The default setting is {0,1,2,...,n-1} which allows all variables to enter.
Specified by:
setEnteringVariables in interface LinearRegressionI

setRequiredVarables

public void setRequiredVarables(int[] variables)
Selects the set of variables that are forced into the final model. The default setting is {} which does not force any variables into the model.
Specified by:
setRequiredVarables in interface LinearRegressionI

setEnteringThreshold

public void setEnteringThreshold(double pValue)
Sets the p-value threshold used to select entering variables. The default value is '0.05'.
Specified by:
setEnteringThreshold in interface LinearRegressionI

getEnteringThreshold

public double getEnteringThreshold()
Returns the p-value threshold used to select entering variables.
Specified by:
getEnteringThreshold in interface LinearRegressionI

setExitingThreshold

public void setExitingThreshold(double pValue)
Sets the p-value threshold used to select exiting variables. The default value is '0.05'.
Specified by:
setExitingThreshold in interface LinearRegressionI

getExitingThreshold

public double getExitingThreshold()
Returns the p-value threshold used to select exiting variables.
Specified by:
getExitingThreshold in interface LinearRegressionI

getSelectedVariables

public int[] getSelectedVariables()
Returns the internal array describing current variable set. This array should not be directly modified.
Specified by:
getSelectedVariables in interface LinearRegressionI

getEnteringVariables

public int[] getEnteringVariables()
Returns the internal array describing entering variable set. This array should not be directly modified.
Specified by:
getEnteringVariables in interface LinearRegressionI

getRequiredVariables

public int[] getRequiredVariables()
Returns the internal array describing required variable set. This array should not be directly modified.
Specified by:
getRequiredVariables in interface LinearRegressionI

setSelectedVariables

public void setSelectedVariables(int[] variables)
Selects the current variable set and and solves the model. Immediately after construction all the variables are selected and the model is solved. The subclass search algorithms use this method to test diferent variable sets for each iteration.
Specified by:
setSelectedVariables in interface LinearRegressionI

getF

public double getF()
Returns the 'F' statistic for the currrent model.
Specified by:
getF in interface LinearRegressionI

getFPV

public double getFPV()
Returns the one-sided p-value for the current 'F' statistic.
Specified by:
getFPV in interface LinearRegressionI

getCoefficients

public VectorI getCoefficients()
Returns the selected variable coefficients. The coefficient at index 'n' corresponds to the column indexed by 'selection[n]'. If a constant intercept term is included, its value will be in the last element.
Specified by:
getCoefficients in interface LinearRegressionI

getLowerBounds

public VectorI getLowerBounds(double confidenceLevel)
Returns the selected variable lower bounds. The coefficient at index 'n' corresponds to the column indexed by 'selection[n]'. If a constant intercept term is included, its value will be in the last element.
Specified by:
getLowerBounds in interface LinearRegressionI

getUpperBounds

public VectorI getUpperBounds(double confidenceLevel)
Returns the selected variable upper bounds. The coefficient at index 'n' corresponds to the column indexed by 'selection[n]'. If a constant intercept term is included, its value will be in the last element.
Specified by:
getUpperBounds in interface LinearRegressionI

getT

public VectorI getT()
Returns the 'T' statistics for the selected variables. The statistic at index 'n' corresponds to the column indexed by 'selection[n]'.
Specified by:
getT in interface LinearRegressionI

getTPV

public VectorI getTPV()
Returns the two-sided p-values for the 'T' statistics of the selected variables. The p-value at index 'n' corresponds to the column indexed by 'selection[n]'.
Specified by:
getTPV in interface LinearRegressionI

getTStatistic

public double getTStatistic(double pValue)
Returns the the 'T' statistic for a given p-value;
Specified by:
getTStatistic in interface LinearRegressionI

toString

public java.lang.String toString()
Creates a report describing fit of the current variables.
Overrides:
toString in class java.lang.Object


Copyright(C)1997-2000 by DRA Systems all rights reserved. OpsResearch.com