Skip to content
Increment 0.1.0a6 prerelease documentation. These docs describe the increment 0.1.0a6 prerelease (v0.1.0a6). Its API may change. Install: pip install 'increment==0.1.0a6' Keep any extras requested by the guide, such as increment[dashboard]==0.1.0a6.

Diagnostics and robustness

sample_ratio_mismatch(counts, expected, alpha, inference, grain, unit_counts)

Detect allocation sample-ratio mismatch with fixed or anytime-valid evidence.

inference="always_valid" (default) evaluates the exact uniform-Dirichlet mixture e-process against the normalized expected allocation and alarms when its log evidence reaches -log(alpha). The time-uniform guarantee needs cumulative prefixes with the same known conditional arm probabilities at every assignment; static marginal shares alone do not suffice, and blocked, adaptive, dependent, quota, exact-balance, without-replacement, and ramped or reset assignment streams are unsupported (independently assigned clusters satisfy the contract at cluster grain). log_e_value is stateless and may decrease, since this result retains no historical maximum.

inference="fixed" uses the ordinary Pearson chi-square p-value for one predeclared look or a caller-managed scheduled-look alpha budget. Both modes require an explicit expected allocation.

Apply to all assigned or targeted units, or to a demonstrably pre-treatment, arm-invariant exposure - a treatment-affected triggered subset is selection or telemetry evidence, not evidence that randomization failed.

counts’ "(unassigned)"/"(mixed assignment)" accounting keys are split out and never treated as arms. expected declares the target arm shares for both inference modes; missing observed arms receive zero counts. unit_counts is descriptive per-arm context for a cluster-grain test, never a second allocation sample.

allocation_posterior_bands(counts, credible_level, prior)

Compute per-arm Beta posterior credible bands on allocation share.

counts carries ds/group_id/n_cumulative (the shape daily_exposure_counts produces, minus experiment_id/ n_daily); accepts any narwhals-supported frame or an iterable of row mappings. prior is the Beta(a, b) prior on each arm’s share (default uniform); both parameters must be finite and positive.

Every ds is pooled across all arms present to compute that day’s n_total - rows spanning more than one experiment_id raise ValueError, since silently mixing experiments sharing a date would inflate the total and produce spuriously narrow, wrong bands. Returns one band per input row, in input order.

absorb_factor(summary, factor, control, pooling, alpha)

Absorb factor and return the sharpened average treatment effect.

summary : IntoDataFrame group_summary-shaped table, one row per factor level x arm, carrying factor plus group_id, n, ref_y, cy1, cy2. factor : str Name of the factor-level column. control : str Which group_id is the control arm. pooling : {“partial”, “hard”, “none”} Passed through; prefer the default. alpha : float Two-sided significance level.

AbsorptionResult Effect on the absolute scale, with a level-clustered interval.

ValueError If required columns are missing, the control group is absent, or the table does not describe exactly two arms.

RuntimeWarning Below 40 levels survive absorption — see _check_level_count.

absorb_one_way takes raw sum(y)/sum(y**2) per cell, so centered moments are re-expressed against one global reference (the count-weighted pooled mean) instead of raw sums. This is exact: the model y = mu + tau*D + b_g + e is invariant to a location shift of y - only the intercept moves, so no field on AbsorptionResult reports an absolute level (effect is a contrast; se/icc/ mean_shrinkage are all shift-invariant).

increment.estimators.confounding_sensitivity reports a marginal conversion risk-ratio interval for an observational LiftEstimate; increment.results.ConfoundingSensitivity is its receive-only result type.

increment.workflows.health_check(experiment, reader) combines assignment balance, triggered-cohort balance, descriptive trigger rates, retained source-maturity/completeness evidence, and declared trigger assumptions. Use it alongside estimates; it is not a general safety verdict or causal-validity test. Missing source evidence remains unavailable with its identity and reason. A non-rejected SRM does not prove valid assignment.

For triggered experiments, inspect assigned and triggered checks separately. Balanced rates do not remove the assumptions of treatment-independent triggering, no pre-trigger treatment effect, and stable trigger order. Sequential triggered analyses also assume triggered_look_predictability: looks, stops, and freezes use only already-revealed triggered-chain data. Assigned results must not reveal future triggered outcomes, including for the same metric. The health check does not verify an analyst’s decision rule.

confounding_sensitivity(estimate, threshold_risk_ratio)

Transform an observational relative row without altering it.

Method names are user labels; eligibility follows the persisted estimand and the row’s declared metric type.

ConfoundingSensitivity

A deterministic conservative tipping point, not causal identification.

Interval sensitivity inherits the row’s reported interval and level, including any family adjustment; it does not supply a new coverage guarantee. Analysis population and source snapshot identity are copied from the row.

For fixed-horizon IPTW/AIPW conversion risk ratios, confounding sensitivity transforms an existing LiftEstimate. Binary outcome status is caller-attested, not verified; robustness is not identification.

import pandas as pd
import increment
from increment.workflows import health_check
units = pd.DataFrame(
{
"unit": ["c1", "c2", "t1", "t2"],
"arm": ["control", "control", "treatment", "treatment"],
"value": [1.0, 0.0, 1.5, 1.0],
}
)
experiment, reader = increment.from_frame(
units,
shape="summary",
unit="unit",
group="arm",
control="control",
metrics={"value": "mean"},
)
report = health_check(experiment, reader)
for check in report.checks:
print(check.check, check.analysis_population, check.availability, check.conclusion)
health_check(experiment, reader, expected_allocation)

Report assignment balance, trigger evidence and declared trigger assumptions.

Every check reads one source snapshot; the report carries that snapshot’s fingerprint and cutoff. A check the source cannot answer is unavailable with its refusal code, and a check the design does not call for is not applicable; neither is a pass. A non-rejected allocation check does not prove valid assignment, and balanced trigger rates do not establish the declared trigger assumptions.

experiment : Experiment Experiment declaration the reader was built for. reader : ExperimentReader Reader returned with the experiment by its builder. expected_allocation : Mapping[str, float] | None Target arm shares for the allocation checks when the design declares none.

ExperimentHealth Every check in stable order, with the source fingerprint and cutoff.