What does Continuous Glucose Curves and the Minimal Model conclude, in numbers, about “Closing the Loop: A-B-A Logs, Randomised Blocks and Pre-Registration”?

Answer: Chapter 8 gives a personal log procedure, the Postprandial Curve Area Calculator and a pre-registered plan: a naive test on an A-B-A log raises false alarms at 0.206, randomised blocks of three days at 0.043, and three weeks can detect a log difference of 0.257. Marked boxes separate published evidence, runnable Python calculations (18 programs), classical sources and the author's hypotheses.

Scope of the numbers: It is not medical advice, claims no effect of any kind and offers no dietary, fasting or medication plan; any self-experiment must first be discussed with a licensed physician. Its parameters are illustrative; all calculations are generated by its programs.

中文版

Data table

The numbers below are printed verbatim by the chapter's Python program and can be reproduced by running it. standard-library Python onlyprinted values that match the answer: 0.043, 0.206

designbiassdnaive t>2rand. testpower t / rand
A-B-A +0.0015 0.1581 0.206 - 0.575 / -
A-B +0.0759 0.1769 0.242 - 0.670 / -
blocks-0.00220.09190.0230.0430.552 / 0.657
Show the full program
# Chapter 8. p81: three ways to run a 3-week personal log of one test
# meal per day. Outcome = log of the 2-h iAUC. Day-to-day noise is
# AR(1) (rho 0.4, sd 0.25) plus a slow linear drift of 0.01 per day; all
# illustrative. Designs (21 days, condition B on 7 of them):
#   A-B-A   days 1-7 A, 8-14 B, 15-21 A; estimate B - mean(A1, A2)
#   A-B     days 1-7 A, 8-14 B (14 days only); estimate B - A
#   blocks  7 blocks of 3 days, one day per block drawn as B at random
#           (seeded); estimate B - A; p-value by re-drawing the
#           assignment 200 times (a randomisation test)
# Reported under no true effect: bias, sd, and how often a naive t-test
# (days treated as independent, |t| > 2.0) or the randomisation test
# flags an effect; and the power for a true difference of 0.25.
import math
import random

rng = random.Random(20261120)
RHO, SD, DRIFT = 0.4, 0.25, 0.01


def series(n, delta, lab):
    e = [rng.gauss(0.0, SD)]
    for _ in range(n - 1):
        e.append(RHO * e[-1] + rng.gauss(0.0, SD * math.sqrt(1 - RHO ** 2)))
    return [DRIFT * d + x + (delta if lab[d] else 0.0)
            for d, x in enumerate(e)]


def mean(v):
    return math.fsum(v) / len(v)


def naive_t(a, b):
    va = math.fsum((x - mean(a)) ** 2 for x in a) / (len(a) - 1)
    vb = math.fsum((x - mean(b)) ** 2 for x in b) / (len(b) - 1)
    return (mean(b) - mean(a)) / math.sqrt(va / len(a) + vb / len(b))


def blocks():
    lab = []
    for _ in range(7):
        k = rng.randrange(3)
        lab += [j == k for j in range(3)]
    return lab


def run(design, delta, sims=1000):
    est, flag_t, flag_r = [], 0, 0
    for _ in range(sims):
        if design == "A-B-A":
            lab = [False] * 7 + [True] * 7 + [False] * 7
        elif design == "A-B":
            lab = [False] * 7 + [True] * 7
        else:
            lab = blocks()
        y = series(len(lab), delta, lab)
        a = [v for v, l in zip(y, lab) if not l]
        b = [v for v, l in zip(y, lab) if l]
        if design == "A-B-A":
            d = mean(b) - (mean(a[:7]) + mean(a[7:])) / 2.0
        else:
            d = mean(b) - mean(a)
        est.append(d)
        if abs(naive_t(a, b)) > 2.0:
            flag_t += 1
        if design == "blocks":
            more = 0
            for _ in range(200):
                lp = blocks()
                dp = (mean([v for v, l in zip(y, lp) if l])
                      - mean([v for v, l in zip(y, lp) if not l]))
                if abs(dp) >= abs(d):
                    more += 1
            if (more + 1) / 201 <= 0.05:
                flag_r += 1
    m = mean(est)
    sd = math.sqrt(math.fsum((x - m) ** 2 for x in est) / (sims - 1))
    return m, sd, flag_t / sims, flag_r / sims


print("design   bias     sd     naive t>2   rand. test   power t / rand")
for dz in ("A-B-A", "A-B", "blocks"):
    m, sd, ft, fr = run(dz, 0.0)
    _, _, pt, pr = run(dz, 0.25)
    rt = "%.3f" % fr if dz == "blocks" else "  -  "
    rp = "%.3f" % pr if dz == "blocks" else "  -  "
    print("%-7s %+.4f  %.4f    %.3f       %s       %.3f / %s"
          % (dz, m, sd, ft, rt, pt, rp))

Single source and citation

Fan, Y. (2026). Areas under Continuous Glucose Curves, the Two-Compartment Minimal Model of Insulin Action and the Dynamics of the Switch to Ketone Metabolism (Version 1.0.0), Chapter 8: Closing the Loop: A-B-A Logs, Randomised Blocks and Pre-Registration. 5D Library. DOI pending

DOI pending · monograph page goes live after publication · 5DL-B-286 · v1.0.0 · CC-BY-NC-ND-4.0

BibTeX
@book{fan2026286,
  author    = {Fan, Yafu},
  title     = {Areas under Continuous Glucose Curves, the Two-Compartment Minimal Model of Insulin Action and the Dynamics of the Switch to Ketone Metabolism},
  year      = {2026},
  publisher = {5D Library},
  edition   = {1.0.0},
  note      = {DOI pending}
}

Other chapter answers in this book