Rolling correlation & tail dependence
Rolling windows in time
Rolling statistics look at a fixed-width window (e.g., 90 days) that slides through time. At each step we compute a summary from only the values inside the window, producing a new cube aligned to the window center. This approach keeps temporal context while remaining responsive to recent dynamics.
Correlation vs a reference pixel
When studying spatial synchrony we often compare every pixel to a single
reference location. In cubedynamics the default reference is the center
pixel in the requested climate cube. The function
cubedynamics.stats.correlation.rolling_corr_vs_center computes the
Pearson correlation between each pixel and the reference pixel within every
rolling window. The resulting cube reveals how tightly each pixel's climate
fluctuations track the anchor over time.
Tail dependence
Mean correlation can miss asymmetric extremes. Tail dependence focuses on the
degree to which two pixels vary together during unusually low or high
conditions. The helper
cubedynamics.stats.tails.rolling_tail_dep_vs_center implements a rolling
Spearman correlation after splitting each pixel and the center reference at
their respective window quantiles. With b=0.5, the bottom set contains dates
when both values are at or below their medians, while the top set contains
dates when both values are above their medians. The helper returns bottom, top,
and bottom-minus-top synchrony cubes.
Conceptual snippets
from cubedynamics.stats.correlation import rolling_corr_vs_center
from cubedynamics.stats.tails import rolling_tail_dep_vs_center
corr_cube = rolling_corr_vs_center(tmin, window_days=90, min_t=10)
bottom_tail, top_tail, diff_tail = rolling_tail_dep_vs_center(
tmin, window_days=90, min_t=10, b=0.5
)
For temperature analyses, compare below-median synchrony from tmin with
above-median synchrony from tmax to distinguish coordinated cold conditions
from coordinated hot conditions.
The lower-level helper returns Spearman correlations in [-1, 1] and their
signed lower-minus-upper difference in [-2, 2]. Negative values are valid.
The pipe verb v.rolling_tail_dep_vs_center(...) is a retained historical
name for a different signed statistic: upper-tail variance minus full-window
variance. It is not a probability or a [0, 1] dependence coefficient.
Negative values mean variability inside the selected upper tail is smaller
than variability across the full window. Its units are squared source units
and its valid range is the unbounded real line.
v.rolling_median_split_synchrony(...) returns bottom_synchrony,
top_synchrony, and bottom_minus_top. Result attrs record the per-series
split rule, center-pixel reference, inclusive trailing window, evaluated end
labels, stride, and incomplete-edge behavior.