Approach summary:For streaming daily p-values we should use an online FDR procedure (BH is batch) — practical choices are alpha-investing / LORD / SAFFRON which control FDR sequentially without storing all past p-values. I'll sketch a simple LORD-style algorithm (allocates significance levels over time based on past rejections) plus notes on data structures, cost, and practical integration.Pseudocode (python-like):python
# LORD-lite: allocate alpha_t each test based on initial wealth w0 and rejections
def init(alpha=0.05, w0=0.05, gamma_seq=None):
# gamma_seq: precomputed non-increasing sequence summing to 1, e.g., gamma_t ~ C / t^1.6
return {"alpha": alpha, "w": w0, "gamma": gamma_seq, "t": 0, "R": 0}
def next_threshold(state):
state["t"] += 1
t = state["t"]
# base allocation scaled by remaining wealth
alloc = state["alpha"] * state["gamma"][t-1]
# use min(alloc, current wealth)
thresh = min(alloc, state["w"])
return thresh
def process_pvalue(state, p):
thresh = next_threshold(state)
reject = p <= thresh
if reject:
# reward: increase wealth by fixed amount (here thresh)
state["w"] += state["alpha"] * state["gamma"][state["t"]-1]
state["R"] += 1
else:
# spend the threshold
state["w"] -= thresh
# prevent negative wealth
state["w"] = max(state["w"], 0.0)
return reject, thresh
Key concepts & data structures:- Maintain small state per stream: current time index t, current alpha-wealth w, count of rejections R, and precomputed gamma_seq. Memory O(1) per segmented test stream.- If you must run BH across aggregated windows, store p-values for that window (list) and run offline BH. Memory O(m) for window size.Computational cost:- LORD per p-value: O(1) time, O(1) memory (per stream).- Aggregated BH on daily batch of m p-values: O(m log m) to sort.Ensuring FDR control over time:- Use proven online procedures (LORD, SAFFRON, alpha-investing) which have theoretical FDR guarantees under independence or certain dependence assumptions. Choose variant based on dependence properties of tests.- Choose gamma sequence summing to 1, initial wealth w0 and reward schedule per paper recommendations.- Monitor empirical FDR via rolling windows (store decisions and true outcomes if available) and simulate expected FDR with past data.- Guardrails: floor p-value entry checks, cap test rate, reset policy if wealth depleted (e.g., pause non-critical tests), and log decisions for audit.Practical notes for BI:- Implement per-segment state as a small table (stream_id, t, w, R) in DB; apply thresholds in ETL; surface thresholds and rejections on dashboards.- Provide alerts when alpha-wealth low or when large sudden rejection bursts occur.- If tests are dependent (same metric across segments), prefer SAFFRON or run batched BH on grouped tests periodically.