cleverly.validation.refute#
- cleverly.validation.refute(result: TMLEResult, *, estimand: str = 'ate', tests: Sequence[str] = ('placebo', 'random_common_cause', 'subset'), n_replicates: int | None = None, subset_fraction: float = 0.7, negative_control_outcome: Any = None, dummy_outcome: GaussianIndependentOutcome | None = None, simulated_outcome: GaussianAdjustmentOutcome | None = None, outcome_rule: EmpiricalInclusionRule = EmpiricalInclusionRule(alpha=0.05, minimum_draws=40, failure_policy='fail'), bootstrap_measurement_error: BootstrapMeasurementError | None = None, measurement_error_rule: EmpiricalInclusionRule = EmpiricalInclusionRule(alpha=0.05, minimum_draws=40, failure_policy='fail'), random_state: int | None = None, tolerance: float = 3.0) RefutationResult[source]#
Run refutation tests against a fitted model.
- Parameters:
- result
TMLEResult A fitted result to refute.
- estimand
str Alias the tests are run for.
- testssequence
ofstr Which refutations to run. Parameters without a fixed reported-scale no-effect value refuse
placeboandnegative_control_outcomebefore any refit. Differences use zero; risk and odds ratios use one.subsetandrandom_common_causekeep their stability interpretations. A fit givensplit_plan=refusessubsetandbootstrap_measurement_errorbefore any refit.refute_refusalholds these refusals, and every refusal of a generated-outcome or measurement-error request. Therefutecapability row reads it for the same request, and defers ontestswhen the default tests meet one and a smaller set runs.random_common_causeadds a column of independent noise. ACTMLEwith an explicitordering=places that column after the declared ordering, and aDRTMLErefits without anevaluation=companion that lacks it.- n_replicates
intorNone Replicates per randomized test.
Noneuses five for each established perturbation, and 100 for each generated-outcome test and forbootstrap_measurement_error. Each of those three tests refuses a budget below its rule’sminimum_drawsbefore any refit.- subset_fraction
float Share of rows the subset test refits on.
- negative_control_outcome
strorNone An outcome the treatment cannot affect. Required to run that test.
- dummy_outcome
GaussianIndependentOutcomeorNone Independent Gaussian process declaration.
Noneuses the default declaration.- simulated_outcome
GaussianAdjustmentOutcomeorNone Adjustment-dependent additive process.
Noneuses the default declaration.- outcome_rule
EmpiricalInclusionRule Recorded rule applied to generated-outcome refits.
- bootstrap_measurement_error
BootstrapMeasurementErrororNone Measurement-error declaration. Required when the named test is requested.
- measurement_error_rule
EmpiricalInclusionRule Recorded rule that compares the original estimate with measurement-error refits.
- random_state
intorNone Seed for the randomised tests.
Noneuses the seed the fit was run with, so a seeded fit gives the same refutation every time. An unseeded fit draws a seed, and the refits run under it too. Either way the report records it underrandom_state, and passing that value back repeats the report.- tolerance
float How many standard errors a null test may deviate before failing. The default of 3 keeps the false-alarm rate low across several tests.
- result
- Returns:
RefutationResultOne record per test run, with what it expected and what it saw.
- Raises:
ValueErrorIf a test name is unknown,
n_replicatesis not a positive integer, or the negative-control test has no outcome. These checks precede every refusal and refit.CapabilityErrorIf
refute_refusalrefuses the request. Each such refusal precedes every refit.