REGR_SLOPE() OVER ...
All functions > WINDOW FUNCTION > REGR_SLOPE() OVER ...
Returns the slope of the linear regression line over the window frame.
Syntax
REGR_SLOPE(expr_y, expr_x) OVER ([PARTITION BY expr [, ...]] [ORDER BY sort_item [, ...]] [ROWS|RANGE|GROUPS frame])
Notes
- Equivalent to COVAR_POP(y, x) / VAR_POP(x) over the window
- NULL values in either expression are excluded
See also
Examples
FeatureQL
SELECT
f1 := ZIP(ARRAY[1,2,3] AS id, ARRAY[2.0E0,4.0E0,6.0E0] AS y, ARRAY[1.0E0,2.0E0,3.0E0] AS x).TRANSFORM(SELECT REGR_SLOPE(y, x) OVER (ORDER BY id ASC)).UNWRAP() -- Slope of y on x for collinear data
;Result
| f1 ARRAY |
|---|
| [null, 2.00, 2.00] |