Saturday, November 07, 2026

Survival PMF for Binomial Events in n Clinical Trials

A mathematical and practical guide to discrete survival functions, cumulative binomial probability mass functions, exact confidence intervals, and Python, R, and SAS implementation in biostatistics.


In clinical trials and biostatistical research, primary endpoints frequently involve binary outcomes—such as tumor response versus non-response, patient survival status at fixed milestone horizons (e.g., 1-year overall survival), or the occurrence of dose-limiting toxicities (DLTs). When evaluating a cohort of n independent patients, continuous time-to-event methods are often discretized into milestone evaluations or multi-stage trial designs. Under these conditions, the foundational statistical engine shifts from continuous probability density functions (PDFs) to the Binomial Probability Mass Function (PMF) and its associated Discrete Survival Function.

This article explores the mathematical formulation of binomial survival frameworks, derives discrete hazard rates, examines clinical trial designs governed by binomial distributions, and provides complete implementations in Python, R, and SAS.


1. Mathematical Foundations: Binomial PMF, CDF, and Survival

Let X represent the random variable denoting the total number of successes (e.g., patient survivals or treatment responses) observed in n independent clinical trials, where each trial has a success probability p. The Binomial Probability Mass Function (PMF) defines the exact probability of observing precisely k successes:

P(X = k) = C(n, k) ⋅ pk ⋅ (1 − p)n − k,   k = 0, 1, 2, …, n

Where C(n, k) = n! / [k!(n − k)!] is the binomial coefficient. In survival analysis contexts, researchers are frequently interested in the Cumulative Distribution Function (CDF)—representing the probability of observing k or fewer successes—and its complement, the Discrete Survival Function (Reliability Function), which denotes the probability of observing at least k successes:

F(k) = P(X ≤ k) = ∑i=0k C(n, i) ⋅ pi ⋅ (1 − p)n − i

S(k) = P(X ≥ k) = 1 − F(k − 1) = ∑i=kn C(n, i) ⋅ pi ⋅ (1 − p)n − i

The Discrete Hazard Rate

Analogous to continuous hazard functions in Cox proportional hazards models, the discrete hazard rate h(k) measures the conditional probability that the process terminates or achieves an event exactly at state k, given that it has survived up to state k:

h(k) = P(X = k ∣ X ≥ k) = P(X = k) / S(k)


2. Clinical Trial Applications

Discrete binomial survival frameworks govern several critical methodologies in clinical research:

  • Milestone Survival Analysis: In oncology trials, overall survival is frequently evaluated at fixed landmark times (e.g., 1-year or 3-year progression-free survival). When patient accrual is complete and follow-up is uniform, the number of surviving patients follows a binomial distribution Bin(n, p).
  • Simon’s Two-Stage Phase II Designs: Phase II oncology trials utilize binomial survival thresholds to evaluate early-stage efficacy. Stage 1 treats n1 patients; if fewer than r1 responses are observed, the trial terminates for futility. The exact binomial PMF calculates the exact Type I and Type II error rates under null response probabilities p0 and target response probabilities p1.
  • Safety Monitoring and Adverse Event Bounds: Monitoring dose-limiting toxicities (DLTs) in Phase I dose-escalation trials relies on exact binomial confidence bounds (such as Clopper-Pearson intervals) to ensure toxicity rates do not exceed safety thresholds (e.g., 33%).

3. Software Implementation in Python, R, and SAS

Python Implementation (Using scipy.stats.binom)

import numpy as np
import scipy.stats as stats

# Parameters: n = 50 patients, true underlying response probability p = 0.60
n = 50
p = 0.60

# 1. Compute Binomial PMF for exact successes k
k_values = np.arange(0, n + 1)
pmf_values = stats.binom.pmf(k_values, n, p)

# 2. Compute Discrete Survival Function S(k) = P(X >= k)
survival_values = stats.binom.sf(k_values - 1, n, p)

# 3. Exact Clopper-Pearson 95% Confidence Interval for observed successes k = 32
k_obs = 32
ci_low, ci_high = stats.binomtest(k_obs, n).proportion_ci(confidence_level=0.95, method='exact')

print(f"Observed Successes: {k_obs}/{n} ({k_obs/n:.2%})")
print(f"Exact 95% Clopper-Pearson CI: [{ci_low:.4f}, {ci_high:.4f}]")
print(f"Survival Probability S(32) = P(X >= 32): {survival_values[32]:.4f}")

R Implementation (Using Base Stats Package)

# Parameters: n = 50 patients, p = 0.60
n <- 50
p <- 0.60

# 1. Compute Binomial PMF and Survival Function S(k) = P(X >= k)
k_values <- 0:n
pmf_values <- dbinom(k_values, size = n, prob = p)
survival_values <- 1 - pbinom(k_values - 1, size = n, prob = p)

# 2. Exact Clopper-Pearson Confidence Interval for k = 32 successes
k_obs <- 32
exact_test <- binom.test(k_obs, n, conf.level = 0.95)

print(exact_test)
cat("Survival Probability S(32):", survival_values[33], "\n")

SAS Implementation (Using DATA Step & PROC FREQ)

/****************************************************************/
/* 1. COMPUTE BINOMIAL PMF, CDF, AND DISCRETE SURVIVAL FUNCTION */
/****************************************************************/
data binomial_survival;
    /* Trial Parameters: n = 50 patients, true response probability p = 0.60 */
    n = 50;
    p = 0.60;
    
    do k = 0 to n;
        /* Probability Mass Function P(X = k) */
        pmf = pdf('Binomial', k, p, n);
        
        /* Cumulative Distribution Function P(X <= k) */
        cdf = cdf('Binomial', k, p, n);
        
        /* Discrete Survival Function S(k) = P(X >= k) = 1 - P(X <= k - 1) */
        if k = 0 then survival = 1.0;
        else survival = 1.0 - cdf('Binomial', k - 1, p, n);
        
        output;
    end;
run;

/* Print results around the expected mean (np = 30) */
proc print data=binomial_survival(where=(k between 25 and 40));
    var k pmf cdf survival;
    title "Binomial PMF and Discrete Survival Function (n=50, p=0.60)";
run;


/****************************************************************/
/* 2. EXACT CLOPPER-PEARSON CONFIDENCE INTERVALS (PROC FREQ)    */
/****************************************************************/
/* Suppose we observed k_obs = 32 successes out of n = 50 patients */
data clinical_trial_summary;
    input response $ count;
    datalines;
    Success 32
    Failure 18
    ;
run;

proc freq data=clinical_trial_summary order=data;
    weight count;
    tables response / binomial(exact cl=clopperpearson);
    exact binomial;
    title "Exact Clopper-Pearson 95% Confidence Interval for Response Rate";
run;

4. Best Practices for Applied Biostatisticians

  1. Account for Censoring in Fixed Horizons: If patients drop out prior to the milestone window without experiencing the event, standard binomial models will overestimate failure rates unless adjusted via censoring-weights (e.g., Kaplan-Meier binomial effective sample size corrections).
  2. Exact vs. Asymptotic Intervals: For small sample sizes (n < 30) or extreme response probabilities (p < 0.10 or p > 0.90), Wald asymptotic normal intervals produce inaccurate coverage. Always rely on exact Clopper-Pearson or Wilson score intervals.
  3. Multiplicity Adjustments: When evaluating multiple milestone timepoints across interim monitoring looks, apply appropriate alpha-spending boundaries (such as O'Brien-Fleming or Pocock) to control family-wise error rates.

No comments: