OrdinaryLeastSquares class

Implements Ordinary Least Squares method for linear regression.

This class inherits all the attributes and methods from LeastSquares.

Example:

var A = Matrix.fromList([[1, 2], [3, 4], [5, 6]]);
var b = Column.fromList([7, 8, 9]);
var ols = OrdinaryLeastSquares(A, b);
ols.fit();
print(ols.beta);  // Prints the coefficients of the regression model
print(ols.residuals); // Prints the residuals of the model
print(ols.standardError());  // Prints the standard error of the residuals
Inheritance

Constructors

OrdinaryLeastSquares.new(Matrix A, ColumnMatrix b, {DiagonalMatrix? W, EquationMethod method = EquationMethod.linear})
Creates an instance of the OrdinaryLeastSquares class.

Properties

A Matrix
The designed or input matrix for the model.
finalinherited
b ColumnMatrix
The absolute terms or output column matrix for the model.
finalinherited
beta Matrix
Coefficients vector, solved in the fit method.
getter/setter pairinherited
hashCode int
The hash code for this object.
no setterinherited
method EquationMethod
Equation solving method.
getter/setter pairinherited
residuals Matrix
Computes residuals of the fitted model.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
W DiagonalMatrix?
An optional diagonal matrix of weights.
finalinherited

Methods

confidenceLevel() num
Compute confidence level. Actual implementation depends on the fit and residuals.
inherited
covariance([bool isOnDesignMatrix = true]) Matrix
Compute covariance matrix either of the coefficients or of the residuals.
inherited
detectOutliers(double confidenceLevel) List<int>
Detect outliers in the data using Chauvenet's criterion with a given confidence level.
inherited
errorEllipse() Eigen
Compute error ellipse parameters using eigenvalue decomposition on the covariance matrix.
inherited
fit({LinearSystemMethod linear = LinearSystemMethod.leastSquares, DecompositionMethod decomposition = DecompositionMethod.cholesky}) → void
Fits the model to the data using the chosen method. The method can be either linear or using a matrix decomposition.
inherited
normal() Matrix
Computes the normal equation matrix.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
predict(Matrix xNew) Matrix
Uses the fitted model to predict new outputs given new inputs xNew.
inherited
standardDeviation() num
Compute standard deviation of residuals.
inherited
standardError() num
Compute standard error of residuals, which is the standard deviation divided by the square root of the number of observations.
inherited
toString() String
A string representation of this object.
inherited
unitVariance() num
Compute unit variance, also known as the mean square error (MSE).
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited