calibrax.metrics.functional.statistical¤
Statistical correlation and agreement functions. Includes Pearson and Spearman correlation, Kendall's tau, Lin's concordance correlation coefficient, and adjusted R-squared.
Statistical correlation and agreement metrics.
Pure functions for measuring statistical relationships between variables. Covers linear correlation, rank correlation, and agreement measures.
Includes 5 functions: pearson_correlation, spearman_rank_correlation, kendall_tau, concordance_correlation, r_squared_adjusted.
pearson_correlation(a: Any, b: Any) -> Any
¤
Pearson correlation coefficient.
Linear correlation: cov(a,b) / (std(a) * std(b)).
Note
Direction: HIGHER (1.0 = perfect positive correlation). Range: [-1, 1]. Measures linear association only.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
Any
|
First variable. |
required |
b
|
Any
|
Second variable. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
Pearson r as a scalar value. |
Examples:
spearman_rank_correlation(a: Any, b: Any) -> Any
¤
Spearman's rank correlation coefficient.
Pearson correlation computed on ranks. Measures monotonic association.
Note
Direction: HIGHER (1.0 = perfect monotonic relationship). Range: [-1, 1].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
Any
|
First variable. |
required |
b
|
Any
|
Second variable. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
Spearman rho as a scalar value. |
Examples:
kendall_tau(a: Any, b: Any) -> Any
¤
Kendall rank correlation coefficient (tau-b).
(concordant - discordant) / (n*(n-1)/2).
Note
Direction: HIGHER (1.0 = perfect agreement). Range: [-1, 1].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
Any
|
First variable. |
required |
b
|
Any
|
Second variable. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
Kendall tau as a scalar value. |
Examples:
concordance_correlation(a: Any, b: Any) -> Any
¤
Lin's concordance correlation coefficient.
Measures agreement (not just correlation). Penalizes deviations from the identity line, unlike Pearson which only measures linear association.
Note
Direction: HIGHER (1.0 = perfect agreement). Range: [-1, 1]. CCC <= |Pearson r|. Equal only when means and variances match.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
Any
|
First variable. |
required |
b
|
Any
|
Second variable. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
Concordance correlation as a scalar value. |
Examples:
r_squared_adjusted(predictions: Any, targets: Any, *, num_predictors: int) -> Any
¤
Adjusted R-squared.
1 - (1-R^2)(n-1)/(n-p-1) where p is number of predictors.
Penalizes adding predictors that don't improve fit.
Note
Direction: HIGHER (1.0 = perfect fit). Range: (-inf, 1].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
predictions
|
Any
|
Predicted values. |
required |
targets
|
Any
|
Ground truth values. |
required |
num_predictors
|
int
|
Number of predictors in the model. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
Adjusted R-squared as a scalar value. |