Published
Missing pairs make bioinfokit’s confidence interval contradict its p-value
A paired t-test reports p = 0.0756 alongside a 95% confidence interval that excludes zero because missing pairs still count toward its degrees of freedom.
Two summaries of the same test give opposite signals
A paired t-test compares measurements from the same subjects before and after a change. In a bioinfokit example with incomplete follow-up, we found that the p-value correctly remains above 0.05 while the reported 95% confidence interval excludes zero. These two summaries disagree because they use different counts of usable pairs.
Tasuku Kobayashi submitted bioinfokit issue #74 on November 9, 2026. Upstream confirmation and a repair are pending.
Six complete pairs, twelve rows
The synthetic data contain twelve before measurements, but only six after measurements. The six available differences are [1, 1, 1, 0, 0, 0]. Both implementations calculate a mean difference of 0.5, a t statistic of 2.23606798 and a two-sided p-value of 0.0755868184.
import numpy as np
import pandas as pd
from scipy.stats import ttest_rel
from bioinfokit.analys import stat
pre = np.arange(10., 22.)
diff = np.array([1.,1.,1.,0.,0.,0.] + [np.nan] * 6)
df = pd.DataFrame({"pre": pre, "post": pre - diff})
out = stat()
out.ttest(df=df.copy(), res=["pre", "post"], test_type=3)
print(out.summary)
ref = ttest_rel(df.pre, df.post, nan_policy="omit")
print(ref)
print(ref.confidence_interval())| Reported quantity | bioinfokit | Complete-pair reference |
|---|---|---|
| Sample size for inference | 12 | 6 |
| Degrees of freedom | 11 | 5 |
| Two-sided p-value | 0.0755868184 | 0.0755868184 |
| Lower 95% confidence bound | 0.0078447565 | −0.0747995726 |
| Upper 95% confidence bound | 0.9921552435 | 1.0747995726 |
For the same two-sided t procedure, a 95% confidence interval excludes zero exactly when its p-value is below 0.05. The complete-pair reference preserves that relationship. Removing incomplete pairs explicitly before calling bioinfokit restores the reference interval without changing t or p.
Use the same pairs for the test and its interval
The paired branch omits missing differences for its test, mean and standard error. Its displayed sample size and degrees of freedom, and the critical value used for the confidence interval, still count all twelve rows. The correct interval uses five degrees of freedom, one fewer than the six complete pairs, rather than eleven.
The report proposes using the same nonmissing difference vector throughout inference and reporting. This is distinct from PR #40’s earlier missing-value change. The p-value itself is correct; the defect concerns the displayed sample size, degrees of freedom and confidence interval.
We reproduced the behavior in bioinfokit 2.1.4 and unmodified upstream source at d7df2c9, using Python 3.12.14, pandas 3.1.1, NumPy 2.5.4, SciPy 1.18.1 and statsmodels 0.15.0. The comparison uses SciPy’s paired-test confidence interval. The public example includes runnable code.
These are constructed data representing incomplete follow-up, not evidence of an affected real study or its frequency. The finding illustrates the value of checking agreement across reported quantities, without establishing a SciGround production incident, new product support or an upstream-adopted repair. Read the public report for the current upstream disposition.