Package org.hipparchus.stat.regression
Class GLSMultipleLinearRegression
- java.lang.Object
-
- org.hipparchus.stat.regression.AbstractMultipleLinearRegression
-
- org.hipparchus.stat.regression.GLSMultipleLinearRegression
-
- All Implemented Interfaces:
MultipleLinearRegression
public class GLSMultipleLinearRegression extends AbstractMultipleLinearRegression
The GLS implementation of multiple linear regression. GLS assumes a general covariance matrix Omega of the erroru ~ N(0, Omega)
Estimated by GLS,b=(X' Omega^-1 X)^-1X'Omega^-1 y
whose variance isVar(b)=(X' Omega^-1 X)^-1
-
-
Constructor Summary
Constructors Constructor Description GLSMultipleLinearRegression()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.hipparchus.linear.RealVectorcalculateBeta()Calculates beta by GLS.protected org.hipparchus.linear.RealMatrixcalculateBetaVariance()Calculates the variance on the beta.protected doublecalculateErrorVariance()Calculates the estimated variance of the error term using the formulaprotected org.hipparchus.linear.RealMatrixgetOmegaInverse()Get the inverse of the covariance.protected voidnewCovarianceData(double[][] omega)Add the covariance data.voidnewSampleData(double[] y, double[][] x, double[][] covariance)Replace sample data, overriding any previous sample.-
Methods inherited from class org.hipparchus.stat.regression.AbstractMultipleLinearRegression
calculateResiduals, calculateYVariance, estimateErrorVariance, estimateRegressandVariance, estimateRegressionParameters, estimateRegressionParametersStandardErrors, estimateRegressionParametersVariance, estimateRegressionStandardError, estimateResiduals, getX, getY, isNoIntercept, newSampleData, newXSampleData, newYSampleData, setNoIntercept, validateCovarianceData, validateSampleData
-
-
-
-
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 samplex- x values of the samplecovariance- 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 org.hipparchus.linear.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 org.hipparchus.linear.RealVector calculateBeta()
Calculates beta by GLS.b=(X' Omega^-1 X)^-1X'Omega^-1 y
- Specified by:
calculateBetain classAbstractMultipleLinearRegression- Returns:
- beta
-
calculateBetaVariance
protected org.hipparchus.linear.RealMatrix calculateBetaVariance()
Calculates the variance on the beta.Var(b)=(X' Omega^-1 X)^-1
- Specified by:
calculateBetaVariancein classAbstractMultipleLinearRegression- Returns:
- The beta variance matrix
-
calculateErrorVariance
protected double calculateErrorVariance()
Calculates the estimated variance of the error term using the formulaVar(u) = Tr(u' Omega^-1 u)/(n-k)
where n and k are the row and column dimensions of the design matrix X.- Overrides:
calculateErrorVariancein classAbstractMultipleLinearRegression- Returns:
- error variance
-
-