Raw difference, B minus A
Descriptive mean difference on the exact model sample.
A before-and-after difference in one person's diary is easy to compute. This workbench asks whether it survives calendar drift, travel and the way one day follows another.
It works through three questions in order: which rows actually support the comparison, whether the phase can be told apart from calendar time, and what happens to the uncertainty once dependence between days is kept. Phase labels describe observations that already exist, and the page gives no health advice.
The diary in the example is made up. Whatever you paste stays on this page and is never sent.
Both diaries hold the same measurements. Only the phase column differs.
Closing the page discards edits. The export contains the full input, so do not paste anything that identifies a person.
Required headers: date,phase,sleep_hours,energy,travel. Optional: sequence,block. Column order may vary. Dates must be valid YYYY-MM-DD, 1900 to 2100, unique across the file. Rows are sorted by date; original line numbers are retained.
Phase: A or B. Sleep: 0 to 24 hours. Energy: a self-defined 0 to 100 score with consistent meaning across rows. Travel: 0 or 1. Empty or NA numeric cells are missing and stay missing. A gap in the outcome you did not select leaves the row in.
Sequence and block labels accept 1 to 24 letters, digits, underscores or hyphens. Blank labels mean series-1 and all. Up to 6 sequences add fixed intercepts; blocks only restrict resampling. Consecutive calendar dates and matching labels define a run. A missing date is a gap.
Maximum 366 rows and 100,000 characters. Adjustment requires at least 12 complete cases and 3 per phase. Quoted single-line CSV cells are accepted; a line break inside a cell is refused. The bounds check that a value is plausible data.
Every run also compares lengths 1, 3, 7 and 14, with and without travel. The primary length is the one you chose before the run.
Waiting for the local engine.
The example diary covers 84 calendar days in 83 rows. It was generated with linear drift, AR(1) noise with coefficient 0.72, uneven travel, missing measurements and one absent date, and with a phase effect of exactly zero. Any nonzero estimate here, even an interval that excludes zero, comes from drift and noise.
This diary has the same 83 rows, drift, noise, travel and gaps as the one-switch example, with a phase effect of exactly zero. The phase alternates every seven days, so phase and calendar time separate: the trend column barely predicts phase, and the interval for B minus A sits around zero.
Raw difference, B minus A
Descriptive mean difference on the exact model sample.
Adjusted for a linear trend, B minus A
Each bar counts resampled fits of the primary setting. The shaded band is the 95% interval and the solid line is the adjusted estimate.
Scroll horizontally to inspect the full chart on a small screen. Exact observations are in the row table below.
Circles: phase A. Squares: phase B. Pale points: excluded rows. Bottom crosses: missing outcome. Dashed line: fitted complete cases, broken at gaps and resampling boundaries. Dotted verticals: phase changes, labelled with the phase that starts. Open rings: rows with leverage above 2p/n.
Residual = observed minus fitted. A pattern over time means the model has missed something, however smooth the fitted line looks.
Each bar is the correlation between residuals that many days apart inside one complete run. The short dotted marks sit at plus and minus 2 divided by the square root of the pair count, the usual spread for independent residuals.
Intervals come from the primary block bootstrap. The IID standard error assumes independent errors and is shown for comparison.
| Term | Estimate | 95% interval | IID SE |
|---|
These cells reuse observations. Travel exclusion changes the population, and longer blocks may find no eligible source windows; such a cell says why it has no interval.
| Sample | Cases A / B | Block days | Adjusted B - A | 95% interval | Resampling audit |
|---|
All rows are listed. Multiple reasons can apply to one excluded row, so reason counts can add up to more than the excluded rows.
| CSV line | Date | Phase | Outcome | Travel | Disposition |
|---|
Paste a file downloaded from this page. The CSV and options inside it are analyzed again here, and every value is compared: numbers within 1e-9, everything else exactly.
Nothing compared yet.
The model is outcome = intercept + phase B + centered calendar weeks + travel + optional sequence intercepts. Constant travel is omitted and disclosed. The time coefficient is per seven calendar days; the intercept refers to mean sample time, phase A, travel 0 when included, and the first sorted sequence label.
Both contrasts use the same complete cases: selected outcome and travel must be present. Missing values stay missing, the other outcome is ignored, and phase labels describe what happened rather than assign it. With a single switch, phase and anything else that changed on that date are the same column; alternating the phases, as in the second example, is what separates them from calendar time.
Column-scaled, column-pivoted Householder QR avoids normal-equation inversion. A relative 1e-10 rank threshold rejects aliased columns; a rank failure leaves only the descriptive comparison. Diagnostics include the scaled triangular condition number, leverage, residual error, phase predictability from nuisance columns and adjacent-day residual correlation.
Residual correlation at lag h pairs residuals h calendar days apart inside one complete run with matching sequence and block labels; lag 1 is the adjacent-day figure in the diagnostics. Gaps end a run, so long lags rest on fewer pairs. The plus or minus 2 over root-pairs marks are a reading aid. VIF is 1 / (1 - R-squared) for phase regressed on the nuisance columns. Rows with leverage above 2p/n, twice the average, are ringed on the trajectory.
A fixed-design residual moving-block bootstrap samples overlapping blocks with replacement inside sequence/block pools. Missing or excluded rows, label changes and date gaps split runs. A full source window is required; only the last sampled block at a target-run boundary is truncated. Residuals are centered and multiplied by sqrt(n / residual degrees of freedom).
Intervals use the 2.5th and 97.5th percentiles, linearly interpolated at (replicates - 1) times the quantile. They condition on linear mean structure and stationary, exchangeable residual blocks within each pool. Short runs truncate dependence; few source windows can make intervals misleadingly narrow. These are pointwise intervals for an association.
JSON contains the exact CSV, normalized source rows, missingness, original line numbers, all exclusions, options, derived seeds, coefficients, IID standard errors, fitted values, residuals, leverage, bootstrap phase draws, intervals, pool sizes and method references. The engine version and the inputs fix the computation, so the same file always gives the same numbers.
Computation is capped at 366 rows, 6 sequences and 1,000 replicates per cell. Small scheduled batches allow cancellation. An input change invalidates old results and disables export. The check panel reruns the CSV and options inside a pasted export and walks both results key by key; it reports the first differences by JSON pointer.
The references name where each method comes from, and the page only links to them. Missing-not-at-random data, nonlinear drift, carryover and unmeasured confounding remain outside the model.