Skip to main content

Correlation Tests

AnoFox provides 5 correlation methods spanning linear (Pearson), rank-based (Spearman, Kendall), nonlinear (distance correlation), and reliability (Intraclass Correlation Coefficient with 3 model types). Distance correlation is uniquely powerful: it equals zero if and only if the two variables are statistically independent -- unlike Pearson, which only detects linear relationships. ICC supports one-way, two-way random, and two-way mixed models for inter-rater reliability assessment. All correlation functions return p-values, confidence intervals, and sample sizes alongside the correlation coefficient.

Correlation is a statistical measure that quantifies the strength and direction of the relationship between two variables. A correlation of +1 indicates a perfect positive relationship, -1 a perfect negative relationship, and 0 no relationship. Different correlation methods capture different types of relationships: linear (Pearson), monotonic (Spearman, Kendall), or general dependence (distance correlation).


Linear Correlation

Pearson Correlation

Linear correlation with significance test.

Parameters

ParameterTypeRequiredDefaultDescription
xDOUBLEYes-First variable
yDOUBLEYes-Second variable
optionsMAPNo-Configuration options

Output

FieldTypeDescription
rDOUBLEPearson correlation (-1 to 1)
p_valueDOUBLEp-value
t_statisticDOUBLEt-statistic
ci_lowerDOUBLECI lower bound
ci_upperDOUBLECI upper bound
nBIGINTSample size

Example

SELECT anofox_stats_pearson_agg(x, y) as result
FROM data;

Interpretation:

r valueStrength
0.0 - 0.3Weak
0.3 - 0.7Moderate
0.7 - 1.0Strong

Rank Correlations

Spearman Rank Correlation

Monotonic relationship (robust to outliers).

Parameters

ParameterTypeRequiredDefaultDescription
xDOUBLEYes-First variable
yDOUBLEYes-Second variable
optionsMAPNo-Configuration options

Output

FieldTypeDescription
rhoDOUBLESpearman's rho
p_valueDOUBLEp-value
nBIGINTSample size

Example

SELECT anofox_stats_spearman_agg(x, y) as result
FROM data;

Kendall's Tau

Rank correlation (handles ties well).

Parameters

ParameterTypeRequiredDefaultDescription
xDOUBLEYes-First variable
yDOUBLEYes-Second variable
optionsMAPNo-Configuration options

Output

FieldTypeDescription
tauDOUBLEKendall's tau
p_valueDOUBLEp-value
nBIGINTSample size

Example

SELECT anofox_stats_kendall_agg(x, y) as result
FROM data;

Nonlinear Correlation

Distance Correlation

Detects nonlinear relationships using the distance correlation measure.

Parameters

ParameterTypeRequiredDefaultDescription
xDOUBLEYes-First variable
yDOUBLEYes-Second variable

Output

FieldTypeDescription
dcorDOUBLEDistance correlation (0 to 1)
dcovDOUBLEDistance covariance
nBIGINTSample size

Example

SELECT anofox_stats_distance_cor_agg(x, y) as result
FROM data;

Key property: Distance correlation = 0 if and only if X and Y are independent (unlike Pearson which only detects linear relationships).


Reliability Measures

Intraclass Correlation (ICC)

Reliability/agreement between raters.

Parameters

ParameterTypeRequiredDefaultDescription
valueDOUBLEYes-Rating value
rater_idINTEGERYes-Rater identifier
subject_idINTEGERYes-Subject identifier
optionsMAPNo-Model configuration

Options MAP:

OptionTypeDefaultDescription
modelVARCHARtwo_way_randomone_way, two_way_random, two_way_mixed

Example

SELECT anofox_stats_icc_agg(
value,
rater_id,
subject_id,
MAP {'model': 'two_way_random'}
) as result
FROM rating_data;

Interpretation:

ICC valueReliability
< 0.5Poor
0.5 - 0.75Moderate
0.75 - 0.9Good
> 0.9Excellent

Choosing a Correlation Method

ScenarioRecommended
Linear relationship, normal dataPearson
Outliers presentSpearman
Ordinal dataSpearman or Kendall
Many tiesKendall
Nonlinear relationshipDistance Correlation
Rater agreementICC

🍪 Cookie Settings