Package elki.math.statistics
Class MultipleLinearRegression
- java.lang.Object
-
- elki.math.statistics.MultipleLinearRegression
-
- Direct Known Subclasses:
PolynomialRegression
public class MultipleLinearRegression extends java.lang.Object
Multiple linear regression attempts to model the relationship between two or more explanatory variables and a response variable by fitting a linear equation to observed data. Every value of the independent variable x is associated with a value of the dependent variable y.The population regression line for p explanatory variables x1, x2, ... , xp is defined to be y = b0 + b1*x1 + b2*x2 + ... + bp*xp + e.
- Since:
- 0.1
- Author:
- Elke Achtert
-
-
Field Summary
Fields Modifier and Type Field Description private double[]
b
The (p+1 x 1) - double[] holding the estimated b-values (b0, b1, ..., bp)^T.private double[]
e
The (n x 1) - double[] holding the estimated residuals (e1, ..., en)^T.private double
ssr
The sum of square residualsprivate double
sst
The sum of square totalsprivate double
variance
The error variance.private double[][]
x
The (n x p+1)-matrix holding the x-values, where the i-th row has the form (1 x1i ... x1p).private double[][]
xx_inverse
Holds the matrix (x'x)^-1.private double[]
y
The (n x 1) - double[] holding the y-values (y1, ..., yn)^T.private double
y_mean
Holds the mean value of the y-values.
-
Constructor Summary
Constructors Constructor Description MultipleLinearRegression(double[] y, double[][] x)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
coefficientOfDetermination()
Returns the coefficient of determinationdouble
estimateY(double[][] x)
Perform an estimation of y on the specified matrix.double[]
getEstimatedCoefficients()
Returns the estimated coefficientsdouble[]
getEstimatedResiduals()
Returns the estimated residualsdouble
getSumOfSquareResiduals()
Returns the sum of square residuals.double
getSumOfSquaresTotal()
Returns the sum of squares total.double
getVariance()
Returns the error variance.java.lang.String
toString()
Returns a string representation of the object.
-
-
-
Field Detail
-
y
private final double[] y
The (n x 1) - double[] holding the y-values (y1, ..., yn)^T.
-
y_mean
private final double y_mean
Holds the mean value of the y-values.
-
x
private final double[][] x
The (n x p+1)-matrix holding the x-values, where the i-th row has the form (1 x1i ... x1p).
-
b
private final double[] b
The (p+1 x 1) - double[] holding the estimated b-values (b0, b1, ..., bp)^T.
-
e
private final double[] e
The (n x 1) - double[] holding the estimated residuals (e1, ..., en)^T.
-
variance
private final double variance
The error variance.
-
xx_inverse
private final double[][] xx_inverse
Holds the matrix (x'x)^-1.
-
ssr
private final double ssr
The sum of square residuals
-
sst
private final double sst
The sum of square totals
-
-
Constructor Detail
-
MultipleLinearRegression
public MultipleLinearRegression(double[] y, double[][] x)
Constructor.- Parameters:
y
- the (n x 1) - double[] holding the response values (y1, ..., yn)^T.x
- the (n x p+1)-matrix holding the explanatory values, where the i-th row has the form (1 x1i ... x1p).
-
-
Method Detail
-
toString
public java.lang.String toString()
Returns a string representation of the object.- Overrides:
toString
in classjava.lang.Object
- Returns:
- a string representation of the object.
-
getSumOfSquaresTotal
public double getSumOfSquaresTotal()
Returns the sum of squares total.- Returns:
- the sum of squares total
-
getSumOfSquareResiduals
public double getSumOfSquareResiduals()
Returns the sum of square residuals.- Returns:
- the sum of square residuals
-
getEstimatedCoefficients
public double[] getEstimatedCoefficients()
Returns the estimated coefficients- Returns:
- the estimated coefficients
-
getEstimatedResiduals
public double[] getEstimatedResiduals()
Returns the estimated residuals- Returns:
- the estimated residuals
-
coefficientOfDetermination
public double coefficientOfDetermination()
Returns the coefficient of determination- Returns:
- the coefficient of determination
-
estimateY
public double estimateY(double[][] x)
Perform an estimation of y on the specified matrix.- Parameters:
x
- the matrix for which y is estimated- Returns:
- the estimation of y
-
getVariance
public double getVariance()
Returns the error variance.- Returns:
- the error variance
-
-