Switchback¶
Randomized switchback schedules of two settings, and their randomization analysis.
tsdive.switchback.design draws a balanced schedule of K blocks and
the reference assignments; tsdive.switchback.inference computes
the B - A difference on the kept samples, its randomization p-value and
the interval that inverts the test; tsdive.switchback.plan holds
the schedule as a plan with a digest, checks it, and reads its power off
a history window; tsdive.switchback.archive reads the target and
covariates through the store and runs the analysis, and
tsdive.switchback.render writes both as text and JSON. The package
imports numpy and pandas and nothing heavier.
| Name | Summary |
|---|---|
tsdive.switchback_plan |
Plan a balanced random schedule of settings A and B over one window. |
tsdive.SwitchbackPlan |
A balanced random schedule of settings A and B over one window. |
tsdive.switchback_analyze |
The difference between settings A and B on target under a verified plan. |
tsdive.SwitchbackAnalysis |
The difference between settings A and B on one target, under a verified plan. |
tsdive.SwitchbackEstimate |
One analysis of the target: direct (no covariates) or adjusted. |
tsdive.switchback.analyze |
The B - A coefficient of y on [1, z] or [1, z, X], its p-value and interval. |
tsdive.switchback.cut_blocks |
Blocks of length from time 0, K = schedule_blocks(span, length). |
tsdive.switchback.design_size |
(balanced assignments, enumerated, smallest attainable two-sided p) of K blocks. |
tsdive.switchback.lag_response |
First-order lag response to the per-sample setting u, starting from 0. |
tsdive.switchback.make_design |
Observed assignment and reference set, deterministic in seed. |
tsdive.switchback.make_plan |
The balanced schedule seed draws over start to end. |
tsdive.switchback.plan_digest |
SHA-256 hex digest of the plan's canonical schedule. |
tsdive.switchback.schedule_blocks |
K = floor(span / length), less one when it is odd. |
tsdive.switchback.setting |
Per-sample setting: 1 in B blocks, 0 in A blocks and outside the schedule. |
tsdive.switchback.verify_plan |
The design the plan's seed draws, after checking the plan against it. |
tsdive.switchback.Analysis |
One randomization analysis of a target, or the reason it has none. |
tsdive.switchback.Blocks |
Block of each sample (-1 outside the schedule) and its offset from the block start. |
tsdive.switchback.Design |
The observed assignment of K blocks and the assignments its p-value reads. |
tsdive.switchback.PlannedBlock |
One block of the schedule: when it runs, its setting, and when its washout ends. |
tsdive.switchback.PowerReadout |
Detection rates of the plan's design over a history window where nothing changed. |
tsdive.switchback.SwitchbackPlan |
A balanced random schedule of settings A and B over one window. |
tsdive.switchback.ALPHA |
Level of the two-sided randomization test. |
tsdive.switchback.COLLINEAR |
Refusal reason: the observed assignment lies in the span of the covariates. |
tsdive.switchback.EMPTY_BLOCK |
Refusal reason: a block with no kept sample. |
tsdive.switchback.MIN_ASSIGNMENTS |
Fewest balanced assignments a design may have (DesignTooSmall below it). |
tsdive.switchback.NO_SPREAD |
Refusal reason: the kept target has MAD 0, or the covariates reproduce it. |
tsdive.switchback.PERMUTATIONS |
Largest reference set enumerated in full. |
tsdive.switchback.POWER_DELTAS |
Shifts the power readout adds to the B blocks, in sigma (1.4826 MAD of the history). |
tsdive.switchback.POWER_DRAWS |
Seeded schedules the power readout draws over the history window. |
tsdive.switchback.REASONS |
Every refusal reason analyze can put in Analysis.reason. |
tsdive.switchback.TOO_FEW |
Refusal reason: fewer than 30 kept samples. |
tsdive.switchback.TOO_MANY_COVARIATES |
Refusal reason: more than one covariate per 10 kept samples. |