| Classical Test | bossanova Equivalent | Data Transformation |
|---|---|---|
| One-sample t-test | model("y ~ 1", df) | None (raw data) |
| Wilcoxon signed-rank | model("signed_rank(y) ~ 1", df) | sign(x) * rank(abs(x)) |
One-Sample t-test¶
Classical:
As GLM:
The classical and the GLM are identical — fitting an intercept-only Gaussian GLM with identity link recovers the one-sample t-test exactly.
scipy¶
from scipy.stats import ttest_1samp
scipy_ttest = ttest_1samp(penguins['bill_length_mm'].to_numpy(), 0)
scipy_ttestTtestResult(statistic=np.float64(148.77670538724365), pvalue=np.float64(3.211394152836e-312), df=np.int64(341))bossanova¶
m = model("bill_length_mm ~ 1", penguins).fit().infer()
m.params.select("statistic", "df", "p_value")Loading...
Wilcoxon Signed-Rank Test¶
Classical:
As GLM:
The signed-rank transformation makes inference robust to outliers. The GLM approach replaces the statistic with a -test on signed ranks — both test the same null hypothesis of zero location.
scipy¶
from scipy.stats import wilcoxon
scipy_wilcox = wilcoxon(penguins['bill_length_mm'].to_numpy(), mode='approx')
scipy_wilcoxWilcoxonResult(statistic=np.float64(0.0), pvalue=np.float64(8.218085850268946e-58))bossanova¶
m_wilcox = model("signed_rank(bill_length_mm) ~ 1", penguins).fit().infer()
m_wilcox.params.select("statistic", "p_value")Loading...
scipy reports the Wilcoxon W statistic; bossanova reports a t-statistic on signed ranks. The test statistics differ but both test H₀: location = 0 and yield equivalent p-values.