Skip to content
ClickHouse Docs

regr_r2

Autogenerated from ClickHouse system tables

Introduced in: v26.9.0

Returns the coefficient of determination of the least-squares fit, that is, the square of the correlation coefficient. Returns nan when x is constant, and 1 when y is constant.

Syntax

regr_r2(y, x)

Arguments

Returned value

Returns a value between 0 and 1. Float64

Examples

Basic usage

SELECT regr_r2(y, x)
FROM VALUES('x Float64, y Float64', (1, 2), (2, 4), (3, 6), (4, 8))
┌─regr_r2(y, x)─┐
│             1 │
└───────────────┘