Linear Correlation#
The Linear Correlation (LC) connectivity metric calculates the Pearson correlation coefficient between two time series.
import delaynet as dn
# Calculate linear correlation
result = dn.connectivity(ts1, ts2, metric="linear_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.**pr_kwargs: Additional keyword arguments forwarded to {py:func}scipy.stats.pearsonr.
- connectivities.linear_correlation(ts2, lag_steps: int | list = None, **pr_kwargs)
Linear correlation (LC) connectivity metric.
LC measures the linear correlation between two time series over a specified number of time lags. The relevant value is the p-value of the Pearson correlation coefficient. This is returned by
scipy.stats.pearsonr()as the second element of the returned tuple.- 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.
pr_kwargs – Keyword arguments forwarded to
scipy.stats.pearsonr().
- Returns:
Best p-value and corresponding lag.
- Return type: