stats.comparison.pairwise_paired_t

stats.comparison.pairwise_paired_t(panel, *, correction='holm')

Pairwise two-sided paired t-tests over the columns of a panel.

Runs a paired t-test for every pair of entries (columns) over the shared blocks (rows) and returns the p-values as a square symmetric matrix — the pairwise stage of the blocked comparison protocol, rendered with spotforecast2.plots.comparison.plot_critical_difference.

Parameters

Name Type Description Default
panel pd.DataFrame Complete block-by-entry frame (e.g. one row per target day, one column per entry, daily MAE values). Must contain no NaN — subset to shared blocks first. required
correction str Multiple-testing correction applied across the pairs. Options: - "holm": Holm step-down adjustment (holm_adjust). - "none": raw p-values. Defaults to "holm". 'holm'

Returns

Name Type Description
pd.DataFrame pd.DataFrame: Square symmetric p-value matrix over
pd.DataFrame panel.columns with 1.0 on the diagonal.

Raises

Name Type Description
ValueError When panel has fewer than two columns or rows, contains NaN, or correction is unknown.

Examples

import pandas as pd
from spotforecast2_safe.stats.comparison import pairwise_paired_t

days = pd.date_range("2026-06-10", periods=8, freq="D")
panel = pd.DataFrame(
    {
        "alpha": [500.0, 520, 480, 510, 490, 505, 515, 495],
        "beta": [540.0, 565, 515, 555, 530, 545, 560, 535],
        "gamma": [502.0, 519, 483, 508, 493, 504, 517, 496],
    },
    index=days,
)
p = pairwise_paired_t(panel)
print(p.round(4).to_string())
assert (p.values == p.values.T).all()
       alpha  beta  gamma
alpha  1.000   0.0  0.247
beta   0.000   1.0  0.000
gamma  0.247   0.0  1.000