Skip to content

Latest commit

 

History

History
30 lines (17 loc) · 1.37 KB

vector.calculatelinearleastsquares.md

File metadata and controls

30 lines (17 loc) · 1.37 KB

Home > @josh-brown/vector > calculateLinearLeastSquares

calculateLinearLeastSquares() function

Calculates a linear regression model for the provided dataPoints.

Signature:

export declare function calculateLinearLeastSquares<S>(dataPoints: Vector<S>[]): LeastSquaresApproximation<S>;

Parameters

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:

LeastSquaresApproximation<S>

  • the result of the linear regression

Remarks

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