5D Library › Shareholder Free-Riding Games, Dynamic Vesting Mechanisms and Defection Early-Warning Models · 中文

Chapter 5. Early Warning with Wald’s Sequential Test

The signal and the test

A partner preparing to leave and compete rarely announces it. What may show is a pattern of small, individually explicable moves of key resources out of the firm: a client relationship moved to a private channel, code kept in a private repository, a supplier contract re-signed in another name. Each week either brings such an event or does not. If such events are rare in normal times (a rate of 0.02 a week) and more frequent in the months before a defection (0.10 a week), the question of whether to raise an alarm is a test between two hypotheses.

Wald’s sequential probability ratio test answers it with the fewest observations on average (Wald 1945). After each week it adds the log of the likelihood ratio to a running sum and stops when the sum crosses one of two bounds set by the tolerated error rates.

Calculation

# Chapter 5. p09: Wald's sequential probability ratio test. Each week a
# partner either does or does not move a key resource outside the firm
# without an agreed reason (a client moved to a private channel, code
# kept in a private repository, a supplier contract re-signed in
# another name). Normal rate p0 = 0.02 a week; rate when preparing to
# defect p1 = 0.10. Error targets alpha = 0.01 (false alarm) and
# beta = 0.05 (miss). Wald's bounds: A = (1 - beta) / alpha and
# B = beta / (1 - alpha) on the likelihood ratio. Simulated error rates
# and average weeks to a decision, against the shortest fixed-length
# test with the same error targets. 20,000 runs each, seed 93.
import random
from math import log

P0, P1, ALPHA, BETA = 0.02, 0.10, 0.01, 0.05
UP, DOWN = log((1 - BETA) / ALPHA), log(BETA / (1 - ALPHA))
YES, NO = log(P1 / P0), log((1 - P1) / (1 - P0))

def binom_tail(n, k, p):
    # P(X >= k) for X ~ binomial(n, p)
    c, tot = 1.0, 0.0
    for i in range(n + 1):
        if i >= k:
            tot += c * p ** i * (1 - p) ** (n - i)
        c = c * (n - i) / (i + 1)
    return tot

def fixed_test():
    for n in range(1, 400):
        for k in range(n + 1):
            if binom_tail(n, k, P0) <= ALPHA:
                if 1 - binom_tail(n, k, P1) <= BETA:
                    return n, k
                break
    return None

def sprt(rng, p, cap=520):
    s = 0.0
    for week in range(1, cap + 1):
        s += YES if rng.random() < p else NO
        if s >= UP:
            return "alarm", week
        if s <= DOWN:
            return "clear", week
    return "none", cap

if __name__ == "__main__":
    rng = random.Random(93)
    print("   bounds on log LR: {:.3f} and {:.3f}".format(UP, DOWN))
    print("   step per event {:+.3f}; per quiet week {:+.4f}".format(YES, NO))
    print("   events needed with no quiet weeks: {:.1f}".format(UP / YES))
    for lab, p in (("normal partner", P0), ("defecting partner", P1)):
        res = [sprt(rng, p) for _ in range(20000)]
        al = sum(1 for r in res if r[0] == "alarm") / len(res)
        wk = sum(r[1] for r in res) / len(res)
        print("   {:<18} alarm rate {:.4f}   mean weeks {:5.1f}".format(
            lab, al, wk))
    n, k = fixed_test()
    print("   fixed test with the same targets: {} weeks, alarm at {}"
          " events".format(n, k))
#    bounds on log LR: 4.554 and -2.986
#    step per event +1.609; per quiet week -0.0852
#    events needed with no quiet weeks: 2.8
#    normal partner     alarm rate 0.0055   mean weeks  57.8
#    defecting partner  alarm rate 0.9534   mean weeks  56.8
#    fixed test with the same targets: 116 weeks, alarm at 7 events

With a false-alarm target of 0.01 and a miss target of 0.05, the bounds are 4.554 and -2.986. Each event adds 1.609, each quiet week subtracts 0.0852; with no quiet weeks between them, 2.8 events would be enough. In simulation the test raises a false alarm on 0.0055 of normal partners and catches 0.9534 of defecting ones, deciding after 57.8 and 56.8 weeks on average. A fixed-length test with the same error targets would need 116 weeks. Sequential testing halves the waiting time, but a year of observation is still a year: a warning system of this kind sees slow preparations, not sudden ones.

Running log likelihood ratio for two normal partners (green) and two defecting partners (red), with the two bounds (p09).

How many alarms are true?

Calculation

# Chapter 5. p10: How many alarms are true? Suppose 2% of partners in a
# year are actually preparing to defect. A test with false-alarm rate
# alpha and detection rate 1 - beta raises alarms on
#   0.02 (1 - beta) + 0.98 alpha
# of partners, of whom the true share (positive predictive value) is
#   0.02 (1 - beta) / (0.02 (1 - beta) + 0.98 alpha).
# Then a firm watches 10 partners each year: the chance of at least one
# false alarm over five years (50 partner-years).
if __name__ == "__main__":
    print("   alpha    1 - beta   true share of alarms   P(false alarm,"
          " 10 x 5 yrs)")
    for alpha, power in ((0.01, 0.95), (0.05, 0.95), (0.001, 0.80),
                         (0.10, 0.99)):
        tp = 0.02 * power
        fp = 0.98 * alpha
        ppv = tp / (tp + fp)
        five = 1 - (1 - alpha) ** 50
        print("   {:5.3f}   {:8.2f}   {:20.3f}   {:28.3f}".format(
            alpha, power, ppv, five))
    print("   base rate 10% instead, alpha 0.01: {:.3f}".format(
        0.10 * 0.95 / (0.10 * 0.95 + 0.90 * 0.01)))
#    alpha    1 - beta   true share of alarms   P(false alarm, 10 x 5 yrs)
#    0.010       0.95                  0.660                          0.395
#    0.050       0.95                  0.279                          0.923
#    0.001       0.80                  0.942                          0.049
#    0.100       0.99                  0.168                          0.995
#    base rate 10% instead, alpha 0.01: 0.913

Defection is rare. If 2% of partners are preparing to defect in a year, a test with a false-alarm rate of 0.01 and detection 0.95 gives alarms of which 0.660 are true; with a false-alarm rate of 0.05 only 0.279 are. A firm watching ten partners for five years with the first test faces a chance of 0.395 of at least one false alarm, and 0.923 with the second. A very strict test (false alarms 0.001, detection 0.80) raises the share of true alarms to 0.942 and the five-year chance of a false alarm falls to 0.049. If the base rate were 10%, the first test’s alarms would be true 0.913 of the time. The arithmetic does not forbid early warning; it forbids treating an alarm as a verdict.

Hypothesis · not established

The author’s interpretation (not yet tested): before an executive leaves to compete, the weekly rate of unexplained transfers of key resources rises measurably in the preceding months. What would show it wrong: in a pre-registered study using lawfully collected and anonymised event logs, the rate of such transfers in the months before competitive departures does not differ from that of executives who stay.

Note

Law and privacy. Any monitoring of employees or partners must be lawful, proportionate, disclosed in advance where the law requires, and limited to business systems. An alarm should open a fair inquiry in which the person can explain, never an accusation.

Summary

Wald’s test detects a slow change in the rate of resource transfers about twice as fast as a fixed test with the same error targets. Because defection is rare, a large share of alarms will be false unless the test is very strict, so an alarm should start an inquiry, not end one.

References

Wald, Abraham. 1945. “Sequential Tests of Statistical Hypotheses.” The Annals of Mathematical Statistics 16 (2): 117 to 186.

Fan, Y. (2026). Shareholder Free-Riding Games, Dynamic Vesting Mechanisms and Defection Early-Warning Models: Moral-Hazard Equity Dilution, Shotgun Buy-Sell Clauses and Behavioral Divergence Signals [股东搭便车博弈、动态股权成熟与背刺早期预警模型] (Version 1.0.0). 5D Library. https://doi.org/10.5281/zenodo.24090243 · Licensed under Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0).