REGR_INTERCEPT() OVER ...
All functions > WINDOW FUNCTION > REGR_INTERCEPT() OVER ...
Returns the y-intercept of the linear regression line over the window frame.
Syntax
REGR_INTERCEPT(expr_y, expr_x) OVER ([PARTITION BY expr [, ...]] [ORDER BY sort_item [, ...]] [ROWS|RANGE|GROUPS frame])
Notes
- Equivalent to AVG(y) - REGR_SLOPE(y, x) * AVG(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[3.0E0,5.0E0,7.0E0] AS y, ARRAY[1.0E0,2.0E0,3.0E0] AS x).TRANSFORM(SELECT REGR_INTERCEPT(y, x) OVER (ORDER BY id ASC)).UNWRAP() -- Intercept for y = 2x + 1
;Result
| f1 ARRAY |
|---|
| [null, 1.00, 1.00] |