Rank Correlation#
The Rank Correlation (RC) connectivity metric calculates the Spearman rank correlation between two time series.
import delaynet as dn
# Calculate rank correlation
result = dn.connectivity(ts1, ts2, metric="rank_correlation", lag_steps=5)
Parameters:
lag_steps: Time lags to consider. An integer will consider lags [1, …, lag_steps]. Passing a list will consider the specified values as lags.**sr_kwargs: Additional keyword arguments forwarded to {py:func}scipy.stats.spearmanr.
- connectivities.rank_correlation(ts2, lag_steps: int | list = None, **sr_kwargs)
Rank correlation (RC) connectivity metric.
RC measures the spearman rank correlation coefficient between two time series over specified time lags. The interesting value is the p-value of the statistic, which is returned as the second element of the returned tuple in
scipy.stats.spearmanr().- Parameters:
ts1 (numpy.ndarray) – First time series.
ts2 (numpy.ndarray) – Second time series.
lag_steps (int | list) – Time lags to consider. Can be a single integer or a list of integers. An integer will consider lags [1, …, lag_steps]. A list will consider the specified values as lags.
sr_kwargs – Keyword arguments forwarded to
scipy.stats.spearmanr().
- Returns:
Best p-value and corresponding lag.
- Return type: