> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-vortex-format.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Devuelve el coeficiente de determinación de la recta de regresión.

# regr_r2

<h2 id="regr_r2">
  regr\_r2
</h2>

Introducido en: v26.9.0

Devuelve el coeficiente de determinación del ajuste por mínimos cuadrados, es decir, el cuadrado del
coeficiente de correlación. Devuelve `nan` cuando `x` es constante y `1` cuando `y` es constante.

**Sintaxis**

```sql theme={null}
regr_r2(y, x)
```

**Alias**: `regrR2`

**Argumentos**

* `y` — Variable dependiente. [`(U)Int*`](/es/reference/data-types/int-uint) o [`Float*`](/es/reference/data-types/float)
* `x` — Variable independiente. [`(U)Int*`](/es/reference/data-types/int-uint) o [`Float*`](/es/reference/data-types/float)

**Valor devuelto**

Devuelve un valor entre 0 y 1. [`Float64`](/es/reference/data-types/float)

**Ejemplos**

**Uso básico**

```sql title=Query theme={null}
SELECT regr_r2(y, x)
FROM VALUES('x Float64, y Float64', (1, 2), (2, 4), (3, 6), (4, 8))
```

```response title=Response theme={null}
┌─regr_r2(y, x)─┐
│             1 │
└───────────────┘
```
