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_THRESHOLD clusters, 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:
statisticfloat

The Wald chi-square statistic.

dfint

Its degrees of freedom, the number of non-constant terms.

p_valuefloat

The upper-tail probability of the reference.

termstuple of str

The tested terms.

scale{“difference”, “log_ratio”}

The scale of the projected contrast.

reference_dfint or None

The degrees of freedom \(\nu = J - 2\) of the covariance, which the Hotelling reference reads, or None for the chi-square reference.

residual_marginfloat

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.0 otherwise. The p-value then reads \(\max(0, \sqrt{T} - m)^2\) in place of \(T\).

Methods#

Attributes#

HeterogeneityTest.reference_df: int | None = None#
HeterogeneityTest.residual_margin: float = 0.0#
HeterogeneityTest.statistic: float#
HeterogeneityTest.df: int#
HeterogeneityTest.p_value: float#
HeterogeneityTest.terms: tuple[str, ...]#
HeterogeneityTest.scale: str#