cleverly.effect_curves.HeterogeneityTest#
- class cleverly.effect_curves.HeterogeneityTest(statistic: float, df: int, p_value: float, terms: tuple[str, ...], scale: str, reference_df: int | None = None, residual_margin: float = 0.0)[source]#
The joint Wald test that every non-constant coefficient of the projection is zero.
It tests “no heterogeneity that the declared basis can express”, not “no heterogeneity”: a contrast that varies orthogonally to the basis leaves every coefficient but the intercept at zero.
On a clustered fit with fewer than
FEW_CLUSTER_THRESHOLDclusters, where each coefficient’s interval reads a Student t reference on \(\nu = J - 2\) degrees of freedom, the statistic \(T\) is read by the Hotelling law: \(T(\nu - q + 1)/(\nu q)\) against \(F(q, \nu - q + 1)\), with \(q\) the number of tested terms. At one term this is the square of that t reference. A basis with more tested terms than \(\nu\) has no reference and is refused.- Parameters:
- statistic
float The Wald chi-square statistic.
- df
int Its degrees of freedom, the number of non-constant terms.
- p_value
float The upper-tail probability of the reference.
- terms
tupleofstr The tested terms.
- scale{“difference”, “log_ratio”}
The scale of the projected contrast.
- reference_df
intorNone The degrees of freedom \(\nu = J - 2\) of the covariance, which the Hotelling reference reads, or
Nonefor the chi-square reference.- residual_margin
float Under a declared stopping rule, the remaining score of the tested coefficients in the statistic’s units, \(m = (s^\top \Sigma^{-1} s)^{1/2}\) for their scores \(s\);
0.0otherwise. The p-value then reads \(\max(0, \sqrt{T} - m)^2\) in place of \(T\).
- statistic