What does Synthetic Control for Site Redesigns conclude, in numbers, about “Eastern and Western Sources: "Take by Kind, Give by Kind" in the Mozi and Mill's Method of Difference”?

Answer: Literal twins number only 0.325 per panel on average, and only 0.260 of the panels have at least one. The kind of instance Mill asks for simply does not exist in about three shops in four with thirty-four sites. Before-after, as two moments of the same object, has a bias of +33.64 and a root mean squared error of 35.61. The single twin has a pre-period error of 9.43 and a bias of only +1.86, but a root mean squared error of 8.63. Its bias is small because the shift removes the difference in level, but it brings all of its own noise with it, and the random swings of a single site pass straight into the estimate. The synthetic site has a pre-period error of 6.84, a bias of +3.90 and a root mean squared error of 5.42, the smallest of the three. By averaging several sites it dilutes the noise of any one of them, at the cost of a little bias from interpolation.

Scope of the numbers: On an illustrative panel of thirty-four sites with a true lift of twelve orders a week, before-after reports 37.77, mostly because of the season; weighting thirty-three untouched donor sites with simplex-constrained weights into a synthetic site gives 8.83. Over two hundred panels the root mean squared error is 35.61 for before-after and 5.42 for synthetic control.

中文版

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.260, 0.325, 1.86, 3.90, 33.64, 35.61

literal twins within 10% on 3 traits: mean 0.325 per panel,
share of panels with at least one: 0.260
methodpreRMSPEbiaslift RMSE
before-aftern/a+33.6435.61
single twin9.43+1.868.63
synthetic6.84+3.905.42
Show the full program
# Chapter 7. p71: Mill's method of difference with one twin site.
# Mill asks for two instances with "every circumstance in common save
# one". Panel as in p11 (illustrative, true lift +12), 200 panels.
# (a) How often does any of the 33 donors match the redesigned site
#     within 10 per cent on level, season loading and market loading
#     at once (a literal twin)? (b) Three comparisons: the same site
#     before and after (Mill's two instances in time), the single best
#     pre-fitted donor shifted to the site's level (a twin in space),
#     and the synthetic site (a twin assembled from many donors).
import math
import random
from operator import mul

# 示意面板:每站周订单 = 基准 + 季节载荷 * 季节 + 大盘载荷 * 大盘 + 噪声
T0, POST, NS = 52, 12, 34


def panel(rep=0, n=NS, t0=T0, post=POST, tau=12.0, start=10):
    rng = random.Random(20261113 + 7919 * rep)
    weeks = t0 + post
    mk = [0.0]
    for _ in range(weeks - 1):
        mk.append(mk[-1] + rng.gauss(0.05, 0.25))
    ss = [math.sin(2.0 * math.pi * (start + t) / 52.0)
          for t in range(weeks)]
    ys, cf, pars = [], [], []
    for i in range(n):
        if i == 0:
            mu, ra, rb, sd = 240.0, 0.20, 1.30, 7.0
        else:
            mu = rng.uniform(120.0, 360.0)
            ra = rng.uniform(0.04, 0.22)
            rb = rng.uniform(0.5, 1.7)
            sd = rng.uniform(5.0, 9.0)
        a, b = mu * ra, mu * rb / 20.0
        y = [mu + a * ss[t] + b * mk[t] + rng.gauss(0.0, sd)
             for t in range(weeks)]
        cf.append(y[:])
        if i == 0:
            for t in range(t0, weeks):
                y[t] = y[t] + tau
        ys.append(y)
        pars.append((mu, a, b, sd))
    return ys, cf, pars, ss, mk


def dot(a, b):
    return math.fsum(map(mul, a, b))


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


def rmspe(xs):
    return math.sqrt(math.fsum([x * x for x in xs]) / len(xs))


def gram(ys, t0):
    n = len(ys)
    pre = [y[:t0] for y in ys]
    g = [[0.0] * n for _ in range(n)]
    for i in range(n):
        for k in range(i, n):
            v = dot(pre[i], pre[k]) / t0
            g[i][k] = v
            g[k][i] = v
    return g


def solve(a, b):
    m = len(b)
    r = [row[:] + [b[i]] for i, row in enumerate(a)]
    for c in range(m):
        p = max(range(c, m), key=lambda i: abs(r[i][c]))
        r[c], r[p] = r[p], r[c]
        for i in range(c + 1, m):
            f = r[i][c] / r[c][c]
            if f:
                r[i] = [x - f * y for x, y in zip(r[i], r[c])]
    x = [0.0] * m
    for i in range(m - 1, -1, -1):
        s = math.fsum([r[i][k] * x[k] for k in range(i + 1, m)])
        x[i] = (r[i][m] - s) / r[i][i]
    return x


def eq_qp(g, c, sup):
    m = len(sup)
    a = [[2.0 * g[i][k] for k in sup] + [1.0] for i in sup]
    a.append([1.0] * m + [0.0])
    b = [2.0 * c[i] for i in sup] + [1.0]
    return solve(a, b)[:m]


def simplex_ls(g, c, tol=1e-10):
    # 精确有效集法:min w'Gw - 2c'w,w >= 0,权重和为 1
    j = len(c)
    k0 = min(range(j), key=lambda k: g[k][k] - 2.0 * c[k])
    w = [0.0] * j
    w[k0] = 1.0
    sup = [k0]
    for _ in range(4 * j + 20):
        gr = [2.0 * (math.fsum([g[i][k] * w[k] for k in sup]) - c[i])
              for i in range(j)]
        nu = -math.fsum([gr[k] for k in sup]) / len(sup)
        out = [k for k in range(j) if k not in sup]
        if not out:
            break
        kb = min(out, key=lambda k: gr[k] + nu)
        if gr[kb] + nu >= -tol:
            break
        sup = sorted(sup + [kb])
        while True:
            z = eq_qp(g, c, sup)
            if min(z) > 0.0:
                for k, v in zip(sup, z):
                    w[k] = v
                break
            step = min(w[k] / (w[k] - v) for k, v in zip(sup, z)
                       if v <= 0.0)
            for k, v in zip(sup, z):
                w[k] = w[k] + step * (v - w[k])
            sup = [k for k in sup if w[k] > 1e-12]
            for k in range(j):
                if k not in sup:
                    w[k] = 0.0
    return w


def synth(ys, g, tr, donors):
    gs = [[g[i][k] for k in donors] for i in donors]
    cs = [g[i][tr] for i in donors]
    w = simplex_ls(gs, cs)
    weeks = len(ys[tr])
    gap = [ys[tr][t] - dot(w, [ys[d][t] for d in donors])
           for t in range(weeks)]
    return w, gap


def ratio(gap, t0=T0):
    return rmspe(gap[t0:]) / rmspe(gap[:t0])


def placebo(ys, g, tr, pool, t0=T0):
    # 逐个捐赠站当处理站;处理站本身不进入安慰剂的捐赠池
    out = {}
    for j in pool:
        dn = [k for k in pool if k != j]
        out[j] = synth(ys, g, j, dn)[1]
    return out


if __name__ == "__main__":
    donors = list(range(1, NS))
    twins, est = [], {"before-after": [], "single twin": [],
                      "synthetic": []}
    pre = {"single twin": [], "synthetic": []}
    for r in range(200):
        ys, cf, pars, ss, mk = panel(r)
        p0 = pars[0]
        n = len([d for d in donors
                 if all(abs(pars[d][k] / p0[k] - 1.0) <= 0.10
                        for k in range(3))])
        twins.append(n)
        est["before-after"].append(mean(ys[0][T0:]) -
                                   mean(ys[0][T0 - 12:T0]))
        g = gram(ys, T0)
        w, gap = synth(ys, g, 0, donors)
        est["synthetic"].append(mean(gap[T0:]))
        pre["synthetic"].append(rmspe(gap[:T0]))
        best = None
        for d in donors:
            sh = mean(ys[0][:T0]) - mean(ys[d][:T0])
            gp = [ys[0][t] - ys[d][t] - sh for t in range(T0 + POST)]
            f = rmspe(gp[:T0])
            if best is None or f < best[0]:
                best = (f, gp)
        est["single twin"].append(mean(best[1][T0:]))
        pre["single twin"].append(best[0])
    have = len([n for n in twins if n > 0]) / len(twins)
    print("literal twins within 10% on 3 traits: mean {:.3f} per panel,"
          .format(mean(twins)))
    print("  share of panels with at least one: {:.3f}".format(have))
    print("method          preRMSPE    bias   lift RMSE")
    for k, xs in est.items():
        pr = "{:8.2f}".format(mean(pre[k])) if k in pre else "     n/a"
        print("{:<14s} {}  {:+6.2f}  {:9.2f}".format(
            k, pr, mean(xs) - 12.0, rmspe([x - 12.0 for x in xs])))

Single source and citation

Fan, Y. (2026). Synthetic Control and the Causal Effect of a Single-Site Redesign: Rebuilding the Counterfactual from Weighted Donor Sites and Placebo Permutation Tests (Version 1.0.0), Chapter 7: Eastern and Western Sources: "Take by Kind, Give by Kind" in the Mozi and Mill's Method of Difference. 5D Library. DOI pending

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

BibTeX
@book{fan2026304,
  author    = {Fan, Yafu},
  title     = {Synthetic Control and the Causal Effect of a Single-Site Redesign: Rebuilding the Counterfactual from Weighted Donor Sites and Placebo Permutation Tests},
  year      = {2026},
  publisher = {5D Library},
  edition   = {1.0.0},
  note      = {DOI pending}
}

Other chapter answers in this book