pingouin.circ_corrcc

pingouin.circ_corrcc(x, y, tail='two-sided', correction_uniform=False)[source]

Correlation coefficient between two circular variables.

Parameters
x1-D array_like

First circular variable (expressed in radians).

y1-D array_like

Second circular variable (expressed in radians).

tailstring

Specify whether to return ‘one-sided’ or ‘two-sided’ p-value.

correction_uniformbool

Use correction for uniform marginals.

Returns
rfloat

Correlation coefficient.

pvalfloat

Uncorrected p-value.

Notes

Adapted from the CircStats MATLAB toolbox [1].

The range of x and y must be either \([0, 2\pi]\) or \([-\pi, \pi]\). If angles is not expressed in radians (e.g. degrees or 24-hours), please use the pingouin.convert_angles() function prior to using the present function.

Please note that NaN are automatically removed.

If the correction_uniform is True, an alternative equation from [2] (p. 177) is used. If the marginal distribution of x or y is uniform, the mean is not well defined, which leads to wrong estimates of the circular correlation. The alternative equation corrects for this by choosing the means in a way that maximizes the positive or negative correlation.

References

1

Berens, P. (2009). CircStat: A MATLAB Toolbox for Circular Statistics. Journal of Statistical Software, Articles, 31(10), 1–21. https://doi.org/10.18637/jss.v031.i10

2

Jammalamadaka, S. R., & Sengupta, A. (2001). Topics in circular statistics (Vol. 5). world scientific.

Examples

Compute the r and p-value of two circular variables

>>> from pingouin import circ_corrcc
>>> x = [0.785, 1.570, 3.141, 3.839, 5.934]
>>> y = [0.593, 1.291, 2.879, 3.892, 6.108]
>>> r, pval = circ_corrcc(x, y)
>>> print(round(r, 3), round(pval, 4))
0.942 0.0658

With the correction for uniform marginals

>>> r, pval = circ_corrcc(x, y, correction_uniform=True)
>>> print(round(r, 3), round(pval, 4))
0.547 0.2859