Top Description Fields Constructors Methods
org.apache.commons.math3.stat.regression

public Class GLSMultipleLinearRegression

extends AbstractMultipleLinearRegression
Class Inheritance
Imports
org.apache.commons.math3.linear.LUDecomposition, .RealMatrix, .Array2DRowRealMatrix, .RealVector

The GLS implementation of multiple linear regression. GLS assumes a general covariance matrix Omega of the error
u ~ N(0, Omega)
Estimated by GLS,
b=(X' Omega^-1 X)^-1X'Omega^-1 y
whose variance is
Var(b)=(X' Omega^-1 X)^-1
Since
2.0

Field Summary

Modifier and TypeField and Description
private RealMatrix
Omega

Covariance matrix.

private RealMatrix
OmegaInverse

Inverse of covariance matrix.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected RealVector
protected RealMatrix

Returns:

The beta variance matrix
calculateBetaVariance
()

Implements abstract org.apache.commons.math3.stat.regression.AbstractMultipleLinearRegression.calculateBetaVariance.

Calculates the variance on the beta.

protected double

Returns:

error variance
calculateErrorVariance
()

Overrides org.apache.commons.math3.stat.regression.AbstractMultipleLinearRegression.calculateErrorVariance.

Calculates the estimated variance of the error term using the formula

 Var(u) = Tr(u' Omega^-1 u)/(n-k)
protected RealMatrix

Returns:

inverse of the covariance
getOmegaInverse
()

Get the inverse of the covariance.

protected void
newCovarianceData(double[][]
the [n,n] array representing the covariance
omega
)

Add the covariance data.

public void
newSampleData(double[]
y values of the sample
y
,
double[][]
x values of the sample
x
,
double[][]
array representing the covariance matrix
covariance
)

Replace sample data, overriding any previous sample.

Inherited from org.apache.commons.math3.stat.regression.AbstractMultipleLinearRegression:
calculateResidualscalculateYVarianceestimateErrorVarianceestimateRegressandVarianceestimateRegressionParametersestimateRegressionParametersStandardErrorsestimateRegressionParametersVarianceestimateRegressionStandardErrorestimateResidualsgetXgetYisNoInterceptnewSampleDatanewXSampleDatanewYSampleDatasetNoInterceptvalidateCovarianceDatavalidateSampleData

Field Detail

Omegaback to summary
private RealMatrix Omega

Covariance matrix.

OmegaInverseback to summary
private RealMatrix OmegaInverse

Inverse of covariance matrix.

Constructor Detail

GLSMultipleLinearRegressionback to summary
public GLSMultipleLinearRegression()

Method Detail

calculateBetaback to summary
protected RealVector calculateBeta()

Implements abstract org.apache.commons.math3.stat.regression.AbstractMultipleLinearRegression.calculateBeta.

Calculates beta by GLS.

 b=(X' Omega^-1 X)^-1X'Omega^-1 y
Returns:RealVector

beta

Annotations
@Override
calculateBetaVarianceback to summary
protected RealMatrix calculateBetaVariance()

Implements abstract org.apache.commons.math3.stat.regression.AbstractMultipleLinearRegression.calculateBetaVariance.

Calculates the variance on the beta.

 Var(b)=(X' Omega^-1 X)^-1
Returns:RealMatrix

The beta variance matrix

Annotations
@Override
calculateErrorVarianceback to summary
protected double calculateErrorVariance()

Overrides org.apache.commons.math3.stat.regression.AbstractMultipleLinearRegression.calculateErrorVariance.

Calculates the estimated variance of the error term using the formula

 Var(u) = Tr(u' Omega^-1 u)/(n-k)
where n and k are the row and column dimensions of the design matrix X.
Returns:double

error variance

Annotations
@Override
Since
2.2
getOmegaInverseback to summary
protected RealMatrix getOmegaInverse()

Get the inverse of the covariance.

The inverse of the covariance matrix is lazily evaluated and cached.

Returns:RealMatrix

inverse of the covariance

newCovarianceDataback to summary
protected void newCovarianceData(double[][] omega)

Add the covariance data.

Parameters
omega:double[][]

the [n,n] array representing the covariance

newSampleDataback to summary
public void newSampleData(double[] y, double[][] x, double[][] covariance)

Replace sample data, overriding any previous sample.

Parameters
y:double[]

y values of the sample

x:double[][]

x values of the sample

covariance:double[][]

array representing the covariance matrix