org.apache.commons.math.stat.regression
Class AbstractMultipleLinearRegression

java.lang.Object
  extended by org.apache.commons.math.stat.regression.AbstractMultipleLinearRegression
All Implemented Interfaces:
MultipleLinearRegression
Direct Known Subclasses:
GLSMultipleLinearRegression, OLSMultipleLinearRegression

public abstract class AbstractMultipleLinearRegression
extends Object
implements MultipleLinearRegression

Abstract base class for implementations of MultipleLinearRegression.

Since:
2.0
Version:
$Revision: 811685 $ $Date: 2009-09-05 13:36:48 -0400 (Sat, 05 Sep 2009) $

Field Summary
protected  RealMatrix X
          X sample data.
protected  RealVector Y
          Y sample data.
 
Constructor Summary
AbstractMultipleLinearRegression()
           
 
Method Summary
protected abstract  RealVector calculateBeta()
          Calculates the beta of multiple linear regression in matrix notation.
protected abstract  RealMatrix calculateBetaVariance()
          Calculates the beta variance of multiple linear regression in matrix notation.
protected  RealVector calculateResiduals()
          Calculates the residuals of multiple linear regression in matrix notation.
protected abstract  double calculateYVariance()
          Calculates the Y variance of multiple linear regression.
 double estimateRegressandVariance()
          Returns the variance of the regressand, ie Var(y).
 double[] estimateRegressionParameters()
          Estimates the regression parameters b.
 double[] estimateRegressionParametersStandardErrors()
          Returns the standard errors of the regression parameters.
 double[][] estimateRegressionParametersVariance()
          Estimates the variance of the regression parameters, ie Var(b).
 double[] estimateResiduals()
          Estimates the residuals, ie u = y - X*b.
 void newSampleData(double[] data, int nobs, int nvars)
          Loads model x and y sample data from a flat array of data, overriding any previous sample.
protected  void newXSampleData(double[][] x)
          Loads new x sample data, overriding any previous sample
protected  void newYSampleData(double[] y)
          Loads new y sample data, overriding any previous sample
protected  void validateCovarianceData(double[][] x, double[][] covariance)
          Validates sample data.
protected  void validateSampleData(double[][] x, double[] y)
          Validates sample data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

X

protected RealMatrix X
X sample data.


Y

protected RealVector Y
Y sample data.

Constructor Detail

AbstractMultipleLinearRegression

public AbstractMultipleLinearRegression()
Method Detail

newSampleData

public void newSampleData(double[] data,
                          int nobs,
                          int nvars)
Loads model x and y sample data from a flat array of data, overriding any previous sample. Assumes that rows are concatenated with y values first in each row.

Parameters:
data - input data array
nobs - number of observations (rows)
nvars - number of independent variables (columns, not counting y)

newYSampleData

protected void newYSampleData(double[] y)
Loads new y sample data, overriding any previous sample

Parameters:
y - the [n,1] array representing the y sample

newXSampleData

protected void newXSampleData(double[][] x)
Loads new x sample data, overriding any previous sample

Parameters:
x - the [n,k] array representing the x sample

validateSampleData

protected void validateSampleData(double[][] x,
                                  double[] y)
Validates sample data.

Parameters:
x - the [n,k] array representing the x sample
y - the [n,1] array representing the y sample
Throws:
IllegalArgumentException - if the x and y array data are not compatible for the regression

validateCovarianceData

protected void validateCovarianceData(double[][] x,
                                      double[][] covariance)
Validates sample data.

Parameters:
x - the [n,k] array representing the x sample
covariance - the [n,n] array representing the covariance matrix
Throws:
IllegalArgumentException - if the x sample data or covariance matrix are not compatible for the regression

estimateRegressionParameters

public double[] estimateRegressionParameters()
Estimates the regression parameters b.

Specified by:
estimateRegressionParameters in interface MultipleLinearRegression
Returns:
The [k,1] array representing b

estimateResiduals

public double[] estimateResiduals()
Estimates the residuals, ie u = y - X*b.

Specified by:
estimateResiduals in interface MultipleLinearRegression
Returns:
The [n,1] array representing the residuals

estimateRegressionParametersVariance

public double[][] estimateRegressionParametersVariance()
Estimates the variance of the regression parameters, ie Var(b).

Specified by:
estimateRegressionParametersVariance in interface MultipleLinearRegression
Returns:
The [k,k] array representing the variance of b

estimateRegressionParametersStandardErrors

public double[] estimateRegressionParametersStandardErrors()
Returns the standard errors of the regression parameters.

Specified by:
estimateRegressionParametersStandardErrors in interface MultipleLinearRegression
Returns:
standard errors of estimated regression parameters

estimateRegressandVariance

public double estimateRegressandVariance()
Returns the variance of the regressand, ie Var(y).

Specified by:
estimateRegressandVariance in interface MultipleLinearRegression
Returns:
The double representing the variance of y

calculateBeta

protected abstract RealVector calculateBeta()
Calculates the beta of multiple linear regression in matrix notation.

Returns:
beta

calculateBetaVariance

protected abstract RealMatrix calculateBetaVariance()
Calculates the beta variance of multiple linear regression in matrix notation.

Returns:
beta variance

calculateYVariance

protected abstract double calculateYVariance()
Calculates the Y variance of multiple linear regression.

Returns:
Y variance

calculateResiduals

protected RealVector calculateResiduals()
Calculates the residuals of multiple linear regression in matrix notation.
 u = y - X * b
 

Returns:
The residuals [n,1] matrix


Copyright © 2003-2010 The Apache Software Foundation. All Rights Reserved.