Skip to contents

This function computes Bayesian posterior probability or posterior predictive probability for binary outcome clinical trials. The function supports controlled, uncontrolled, and external control designs, using beta-binomial conjugate priors. External data can be incorporated through power priors.

Usage

pPPsinglebinary(
  prob = "posterior",
  design = "controlled",
  theta0,
  n1,
  n2,
  y1,
  y2,
  a1,
  a2,
  b1,
  b2,
  m1,
  m2,
  ne1,
  ne2,
  ye1,
  ye2,
  ae1,
  ae2,
  lower.tail = TRUE
)

Arguments

prob

A character string specifying the type of probability to calculate. Options are 'posterior' for posterior probability or 'predictive' for posterior predictive probability.

design

A character string specifying the type of trial design. Options are 'controlled' for randomized controlled trials, 'uncontrolled' for single-arm studies, or 'external' for designs incorporating external data.

theta0

A numeric value representing the pre-specified threshold value for the treatment effect (difference in response rates).

n1

A positive integer representing the number of patients in group 1 (treatment) for the proof-of-concept (PoC) trial.

n2

A positive integer representing the number of patients in group 2 (control) for the PoC trial.

y1

A non-negative integer representing the observed number of responders in group 1 for the PoC trial (must satisfy 0 ≤ y1 ≤ n1).

y2

A non-negative integer representing the observed number of responders in group 2 for the PoC trial (must satisfy 0 ≤ y2 ≤ n2).

a1

A positive numeric value representing the first shape parameter (α) of the prior beta distribution for group 1.

a2

A positive numeric value representing the first shape parameter (α) of the prior beta distribution for group 2.

b1

A positive numeric value representing the second shape parameter (β) of the prior beta distribution for group 1.

b2

A positive numeric value representing the second shape parameter (β) of the prior beta distribution for group 2.

m1

A positive integer representing the number of patients in group 1 for the future trial (required if prob = 'predictive').

m2

A positive integer representing the number of patients in group 2 for the future trial (required if prob = 'predictive').

ne1

A positive integer representing the number of patients in group 1 for the external data (required if design = 'external').

ne2

A positive integer representing the number of patients in group 2 for the external data (required if design = 'external').

ye1

A non-negative integer representing the observed number of responders in group 1 for the external data (required if design = 'external').

ye2

A non-negative integer representing the observed number of responders in group 2 for the external data (required if design = 'external').

ae1

A numeric value in (0, 1] representing the power prior scale parameter for group 1 (required if design = 'external'). Controls the degree of borrowing: 0 = no borrowing, 1 = full borrowing.

ae2

A numeric value in (0, 1] representing the power prior scale parameter for group 2 (required if design = 'external'). Controls the degree of borrowing: 0 = no borrowing, 1 = full borrowing.

lower.tail

A logical value; if TRUE (default), probabilities are P(treatment effect ≤ theta0), otherwise P(treatment effect > theta0).

Value

A numeric value in [0, 1] representing the Bayesian posterior probability or posterior predictive probability that the treatment effect exceeds (or is below) the threshold theta0.

Details

The function computes probabilities based on beta-binomial conjugate analysis:

  • Prior: The proportion of responders (πj) for each group (j = 1, 2) follows a beta distribution: πj ~ Beta(aj, bj)

  • Posterior: After observing data, the posterior distribution is also beta: πj | yj ~ Beta(aj + yj, bj + nj - yj)

  • Posterior predictive: The predictive distribution of future trial data follows a beta-binomial distribution

For external control designs, power priors are used to incorporate historical data. The effective prior becomes Beta(aj + aej × yej, bj + aej × (nej - yej)), where aej controls the degree of borrowing (0 = ignore external data, 1 = full weight).

Probability types:

  • Posterior probability: P(π1 - π2 > theta0 | current data)

  • Posterior predictive probability: P(future trial success | current data)

Examples

# Calculate posterior probability for controlled design
pPPsinglebinary(
  prob = 'posterior', design = 'controlled', theta0 = 0.15,
  n1 = 12, n2 = 15, y1 = 7, y2 = 5, a1 = 0.5, a2 = 0.5, b1 = 0.5, b2 = 0.5,
  m1 = NULL, m2 = NULL, ne1 = NULL, ne2 = NULL, ye1 = NULL, ye2 = NULL,
  ae1 = NULL, ae2 = NULL, lower.tail = FALSE
)
#> [1] 0.6860634

# Calculate posterior predictive probability for controlled design
pPPsinglebinary(
  prob = 'predictive', design = 'controlled', theta0 = 0.1,
  n1 = 12, n2 = 15, y1 = 7, y2 = 5, a1 = 0.5, a2 = 0.5, b1 = 0.5, b2 = 0.5,
  m1 = 30, m2 = 30, ne1 = NULL, ne2 = NULL, ye1 = NULL, ye2 = NULL,
  ae1 = NULL, ae2 = NULL, lower.tail = FALSE
)
#> [1] 0.710533

# Calculate posterior probability with external control data (50% borrowing)
pPPsinglebinary(
  prob = 'posterior', design = 'external', theta0 = 0.15,
  n1 = 12, n2 = 15, y1 = 7, y2 = 9, a1 = 0.5, a2 = 0.5, b1 = 0.5, b2 = 0.5,
  m1 = NULL, m2 = NULL, ne1 = 12, ne2 = 12, ye1 = 6, ye2 = 6,
  ae1 = 0.5, ae2 = 0.5, lower.tail = FALSE
)
#> [1] 0.1399401

# Calculate posterior predictive probability with external control
pPPsinglebinary(
  prob = 'predictive', design = 'external', theta0 = 0.05,
  n1 = 12, n2 = 15, y1 = 7, y2 = 7, a1 = 0.5, a2 = 0.5, b1 = 0.5, b2 = 0.5,
  m1 = 12, m2 = 12, ne1 = 12, ne2 = 12, ye1 = 6, ye2 = 6,
  ae1 = 0.5, ae2 = 0.5, lower.tail = FALSE
)
#> [1] 0.5559926