Skip to contents

This function computes Bayesian posterior probability or posterior predictive probability for continuous outcome clinical trials. The function supports controlled, uncontrolled, and external control designs with Normal-Inverse-Chi-squared or vague priors, using four calculation methods: numerical integration, Monte Carlo simulation, Welch-Satterthwaite approximation, and INLA.

Usage

BayesPostPredContinuous(
  prob = "posterior",
  design = "controlled",
  prior = "vague",
  CalcMethod = "NI",
  theta0,
  nMC = NULL,
  nINLAsample = NULL,
  n1,
  n2,
  m1,
  m2,
  kappa01,
  kappa02,
  nu01,
  nu02,
  mu01,
  mu02,
  sigma01,
  sigma02,
  bar.y1,
  bar.y2,
  s1,
  s2,
  r = NULL,
  ne1 = NULL,
  ne2 = NULL,
  alpha01 = NULL,
  alpha02 = NULL
)

Arguments

prob

A character string specifying the type of probability to calculate (prob = 'posterior' or prob = 'predictive').

design

A character string specifying the type of trial design (design = 'controlled', design = 'uncontrolled', or design = 'external').

prior

A character string specifying the prior distribution (prior = 'N-Inv-Chisq' or prior = 'vague').

CalcMethod

A character string specifying the calculation method (CalcMethod = 'NI' for numerical integration, CalcMethod = 'MC' for Monte Carlo method, CalcMethod = 'WS' for Welch-Satterthwaite approximation, or CalcMethod = 'INLA' for INLA).

theta0

A numeric value representing the pre-specified threshold value.

nMC

A positive integer representing the number of iterations for Monte Carlo simulation (required only if CalcMethod = 'MC').

nINLAsample

A positive integer representing the number of iterations for INLA sampling (required only if CalcMethod = 'INLA').

n1

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

n2

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

m1

A positive integer representing the number of patients in group 1 for the future trial data.

m2

A positive integer representing the number of patients in group 2 for the future trial data.

kappa01

A positive numeric value representing the prior precision parameter related to the mean for conjugate prior of Normal-Inverse-Chi-squared in group 1.

kappa02

A positive numeric value representing the prior precision parameter related to the mean for conjugate prior of Normal-Inverse-Chi-squared in group 2.

nu01

A positive numeric value representing the prior degrees of freedom related to the variance for conjugate prior of Normal-Inverse-Chi-squared in group 1.

nu02

A positive numeric value representing the prior degrees of freedom related to the variance for conjugate prior of Normal-Inverse-Chi-squared in group 2.

mu01

A numeric value representing the prior mean value of outcomes in group 1 for the PoC trial.

mu02

A numeric value representing the prior mean value of outcomes in group 2 for the PoC trial.

sigma01

A positive numeric value representing the prior standard deviation of outcomes in group 1 for the PoC trial.

sigma02

A positive numeric value representing the prior standard deviation of outcomes in group 2 for the PoC trial.

bar.y1

A numeric value representing the sample mean of group 1.

bar.y2

A numeric value representing the sample mean of group 2.

s1

A positive numeric value representing the sample standard deviation of group 1.

s2

A positive numeric value representing the sample standard deviation of group 2.

r

A positive numeric value representing the parameter value associated with the distribution of mean for group 2 when design = 'uncontrolled'.

ne1

A positive integer representing the sample size for group 1 in external trial (can be NULL if no external treatment data).

ne2

A positive integer representing the sample size for group 2 in external trial (can be NULL if no external control data).

alpha01

A positive numeric value representing the scale parameter of the power prior for group 1 (can be NULL if no external treatment data).

alpha02

A positive numeric value representing the scale parameter of the power prior for group 2 (can be NULL if no external control data).

Value

A numeric vector representing the Bayesian posterior probability or Bayesian posterior predictive probability. The function can handle vectorized inputs.

Details

The function can obtain:

  • Bayesian posterior probability

  • Bayesian posterior predictive probability

Prior distribution of mean and variance of outcomes for each treatment group (k=1,2) can be either (1) Normal-Inverse-Chi-squared or (2) Vague. The posterior distribution or posterior predictive distribution of outcome for each treatment group follows a t-distribution.

Four calculation methods are available:

  • NI: Numerical integration method for exact computation

  • MC: Monte Carlo simulation for flexible approximation

  • WS: Welch-Satterthwaite approximation for computational efficiency

  • INLA: Integrated Nested Laplace Approximation for external data incorporation

Examples

# Example 1: Numerical Integration (NI) method with N-Inv-Chisq prior
BayesPostPredContinuous(
  prob = 'posterior', design = 'controlled', prior = 'N-Inv-Chisq', CalcMethod = 'NI',
  theta0 = 2, n1 = 12, n2 = 12, kappa01 = 5, kappa02 = 5, nu01 = 5, nu02 = 5,
  mu01 = 5, mu02 = 5, sigma01 = sqrt(5), sigma02 = sqrt(5),
  bar.y1 = 2, bar.y2 = 0, s1 = 1, s2 = 1
)
#> [1] 0.2438672

# Example 2: Monte Carlo (MC) method with vague prior
BayesPostPredContinuous(
  prob = 'posterior', design = 'controlled', prior = 'vague', CalcMethod = 'MC',
  theta0 = 1, nMC = 10000, n1 = 12, n2 = 12,
  bar.y1 = 3, bar.y2 = 1, s1 = 1.5, s2 = 1.2
)
#> [1] 0.9502

# Example 3: Welch-Satterthwaite (WS) approximation with N-Inv-Chisq prior
BayesPostPredContinuous(
  prob = 'predictive', design = 'controlled', prior = 'N-Inv-Chisq', CalcMethod = 'WS',
  theta0 = 0.5, n1 = 15, n2 = 15, m1 = 100, m2 = 100,
  kappa01 = 3, kappa02 = 3, nu01 = 4, nu02 = 4, mu01 = 2, mu02 = 2,
  sigma01 = 2, sigma02 = 2, bar.y1 = 2.5, bar.y2 = 1.8, s1 = 1.8, s2 = 1.6
)
#> [1] 0.6288522

# \donttest{
# Example 4: INLA method with external control data (requires INLA package)
if (requireNamespace("INLA", quietly = TRUE)) {
  BayesPostPredContinuous(
    prob = 'posterior', design = 'external', prior = 'vague', CalcMethod = 'INLA',
    theta0 = 1.5, nINLAsample = 5000, n1 = 12, n2 = 12,
    bar.y1 = 4, bar.y2 = 2, s1 = 1.2, s2 = 1.1,
    ne2 = 20, alpha02 = 0.5
  )
}
#> [1] 0.6282
# }