cleverly.longitudinal.StructuralModelCheck#

class cleverly.longitudinal.StructuralModelCheck(names: tuple[str, ...], structural: NDArray[float64], nonparametric: NDArray[float64], covariance: NDArray[float64], statistic: float, df: int, pvalue: float, reason: str | None, ltmle: Any, n_splits: int, reference_df: float = nan, support: Support = Support(label='experimental', reason='This estimate was built outside a classified fit.', evidence=(), row=None, limits=()))[source]#

The comparison of the structural contrasts with the nonparametric ones.

The difference of the two contrast vectors has mean zero when the structural model holds. The statistic is a joint Wald statistic over the contrasts against the reference. It is a necessary-condition check and not a test of the model. On a cross-fitted fit, every estimate is the mean over n_splits fold splits, the first of which is the fit’s own.

Parameters:
namestuple of str

The contrasts, ate_regimen[<regimen> vs <reference>].

structuralndarray

The structural point estimates, averaged over the splits.

nonparametricndarray

The LTMLE point estimates on the same rows and splits, averaged over the splits.

covariancendarray

The covariance of the split-averaged difference: the cross-split covariance of the difference curves plus the between-split covariance of the difference over n_splits.

statisticfloat

The Wald statistic, nan when no test is reported.

dfint

The degrees of freedom: the number of contrasts.

pvaluefloat

The tail probability of the Hotelling-type reference law, nan when no test is reported.

reasonstr or None

Why no test is reported, or None.

ltmleLongitudinalResult

The nonparametric fit on the folds of the structural fit.

n_splitsint

The fold splits behind the estimates: 1 for an in-sample fit.

reference_dffloat, default=nan

The Welch-Satterthwaite degrees of freedom of the covariance, the smallest over the contrasts. The p-value reads the Hotelling-type law F(df, reference_df - df + 1) of the scaled statistic, and inf reads chi-squared. nan when no statistic is reported.

supportSupport, default=UNCLASSIFIED

What the package states about the evidence behind the statistic: the combination of the support of the structural contrasts and of the nonparametric contrasts that the statistic compares. The check is supported only when every one of them is supported on one row.

Methods#

StructuralModelCheck.summary(*, detail: Literal['short', 'full'] = 'short') → Summary[source]#

The two sets of contrasts, the joint test, and how to read it.

Parameters:
detail{“short”, “full”}, default “short”

"full" adds how the check works and what its degrees of freedom mean.

Returns:
Summary

The summary. It prints as text; reading says what the test means.

Attributes#

StructuralModelCheck.difference#

The structural minus the nonparametric contrasts.

StructuralModelCheck.reference_df: float = nan#
StructuralModelCheck.support: Support = Support(label='experimental', reason='This estimate was built outside a classified fit.', evidence=(), row=None, limits=())#
StructuralModelCheck.tested#

Whether the check reports a statistic.

StructuralModelCheck.names: tuple[str, ...]#
StructuralModelCheck.structural: NDArray[float64]#
StructuralModelCheck.nonparametric: NDArray[float64]#
StructuralModelCheck.covariance: NDArray[float64]#
StructuralModelCheck.statistic: float#
StructuralModelCheck.df: int#
StructuralModelCheck.pvalue: float#
StructuralModelCheck.reason: str | None#
StructuralModelCheck.ltmle: Any#
StructuralModelCheck.n_splits: int#