org.codehaus.jet.regression.estimators
Class OLSMultipleLinearRegressionEstimator
java.lang.Object
org.codehaus.jet.regression.estimators.AbstractMultipleLinearRegressionEstimator
org.codehaus.jet.regression.estimators.OLSMultipleLinearRegressionEstimator
- All Implemented Interfaces:
- MultipleLinearRegressionEstimator
public class OLSMultipleLinearRegressionEstimator
- extends AbstractMultipleLinearRegressionEstimator
The OLS implementation of the multiple linear regression
OLS assumes the covariance matrix of the error to be diagonal and with equal variance.
u ~ N(0, sigma^2*I)
Estimated by OLS,
b=(X'X)^-1X'y
whose variance is
Var(b)=MSE*(X'X)^-1, MSE=u'u/(n-k)
- Author:
- Mauro Talevi
Method Summary |
void |
addData(double[] y,
double[][] x,
double[][] covariance)
Adds sample and covariance data |
protected org.apache.commons.math.linear.RealMatrix |
calculateBeta()
Calculates beta by OLS: |
protected org.apache.commons.math.linear.RealMatrix |
calculateBetaVariance()
Calculates the variance on the beta by OLS: |
protected double |
calculateYVariance()
Calculates the variance on the Y by OLS: |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
OLSMultipleLinearRegressionEstimator
public OLSMultipleLinearRegressionEstimator()
addData
public void addData(double[] y,
double[][] x,
double[][] covariance)
- Description copied from interface:
MultipleLinearRegressionEstimator
- Adds sample and covariance data
- Parameters:
y
- the [n,1] array representing the y samplex
- the [n,k] array representing x samplecovariance
- the [n,n] array representing the covariance matrix or null
if not appropriate for the
specific implementation
calculateBeta
protected org.apache.commons.math.linear.RealMatrix calculateBeta()
- Calculates beta by OLS:
b=(X'X)^-1X'y
- Specified by:
calculateBeta
in class AbstractMultipleLinearRegressionEstimator
calculateBetaVariance
protected org.apache.commons.math.linear.RealMatrix calculateBetaVariance()
- Calculates the variance on the beta by OLS:
Var(b)=(X'X)^-1
- Specified by:
calculateBetaVariance
in class AbstractMultipleLinearRegressionEstimator
- Returns:
- The beta variance
calculateYVariance
protected double calculateYVariance()
- Calculates the variance on the Y by OLS:
Var(y)=Tr(u'u)/(n-k)
- Specified by:
calculateYVariance
in class AbstractMultipleLinearRegressionEstimator
- Returns:
- The Y variance
Copyright © 2006-2007. All Rights Reserved.