Home > @josh-brown/vector > calculateLinearLeastSquares
Calculates a linear regression model for the provided dataPoints
.
Signature:
export declare function calculateLinearLeastSquares<S>(dataPoints: Vector<S>[]): LeastSquaresApproximation<S>;
Parameter | Type | Description |
---|---|---|
dataPoints | Vector<S>[] | An array of vectors, each of which represents a single data point where the last entry is the variable to be predicted, and the other entries are the values of the independent variables |
Returns:
- the result of the linear regression
The result is an object which has: - coefficients
: a vector whose first entry is the constant term, and whose following entries are the coefficients for the other independent variables, in the same order they appear in the dataPoints
- approximationFunction
: a function which takes a vector of the independent variable values, and returns the predicted value of the dependent variable