## org.apache.commons.math.stat.regression
Class GLSMultipleLinearRegression

    java.lang.Object
      org.apache.commons.math.stat.regression.AbstractMultipleLinearRegression
          org.apache.commons.math.stat.regression.GLSMultipleLinearRegression

All Implemented Interfaces:
  MultipleLinearRegression

    public class GLSMultipleLinearRegression

extends AbstractMultipleLinearRegression

The GLS implementation of the 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
Version:
  $Revision: 811685 $ $Date: 2009-09-05 13:36:48 -0400 (Sat, 05 Sep 2009) $

Field Summary
`private RealMatrix` `Omega` Covariance matrix.
`private RealMatrix` `OmegaInverse` Inverse of covariance matrix.

Fields inherited from class org.apache.commons.math.stat.regression.AbstractMultipleLinearRegression
`X, Y`

Constructor Summary
`GLSMultipleLinearRegression()`

Method Summary
`protected RealVector` `calculateBeta()` Calculates beta by GLS.
`protected RealMatrix` `calculateBetaVariance()` Calculates the variance on the beta by GLS.
`protected double` `calculateYVariance()` Calculates the variance on the y by GLS.
`protected RealMatrix` `getOmegaInverse()` Get the inverse of the covariance.
`protected void` `newCovarianceData(double[][] omega)` Add the covariance data.
`void` `newSampleData(double[] y, double[][] x, double[][] covariance)` Replace sample data, overriding any previous sample.

Methods inherited from class org.apache.commons.math.stat.regression.AbstractMultipleLinearRegression
`calculateResiduals, estimateRegressandVariance, estimateRegressionParameters, estimateRegressionParametersStandardErrors, estimateRegressionParametersVariance, estimateResiduals, newSampleData, newXSampleData, newYSampleData, validateCovarianceData, validateSampleData`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### Omega

    private RealMatrix Omega

  Covariance matrix.

### OmegaInverse

    private RealMatrix OmegaInverse

  Inverse of covariance matrix.

Constructor Detail

### GLSMultipleLinearRegression

    public GLSMultipleLinearRegression()

Method Detail

### newSampleData

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

  Replace sample data, overriding any previous sample.

  Parameters:
    `y` - y values of the sample
    `x` - x values of the sample
    `covariance` - array representing the covariance matrix

### newCovarianceData

    protected void newCovarianceData(double[][] omega)

  Add the covariance data.

  Parameters:
    `omega` - the [n,n] array representing the covariance

### getOmegaInverse

    protected RealMatrix getOmegaInverse()

  Get the inverse of the covariance.

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

  Returns:
    inverse of the covariance

### calculateBeta

    protected RealVector calculateBeta()

  Calculates beta by GLS.

        b=(X' Omega^-1 X)^-1X'Omega^-1 y

  Specified by:
    `calculateBeta` in class `AbstractMultipleLinearRegression`
  Returns:
    beta

### calculateBetaVariance

    protected RealMatrix calculateBetaVariance()

  Calculates the variance on the beta by GLS.

        Var(b)=(X' Omega^-1 X)^-1

  Specified by:
    `calculateBetaVariance` in class `AbstractMultipleLinearRegression`
  Returns:
    The beta variance matrix

### calculateYVariance

    protected double calculateYVariance()

  Calculates the variance on the y by GLS.

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

  Specified by:
    `calculateYVariance` in class `AbstractMultipleLinearRegression`
  Returns:
    The Y variance

Copyright (c) 2003-2010 Apache Software Foundation