Function: ols()
ts
function ols(x, y, options?): OlsFit;Fit y on x by least squares. Pairs with a non-finite value are dropped (statsmodels' missing='drop'). Degenerate designs follow statsmodels' pseudo-inverse: a constant non-zero x with addConstant is taken as the constant column itself (add_constant's has_constant='skip': one coefficient, the mean of y over x), and an all-zero regressor gets a zero slope.
Parameters
| Parameter | Type |
|---|---|
x | ArrayLike<number> |
y | ArrayLike<number> |
options | { addConstant?: boolean; } |
options.addConstant? | boolean |
Returns
Example
ts
ols([1, 2, 3, 4], [2, 4, 5, 8]).params; // [0, 1.9] (intercept, slope)