Calculate Bayesian Posterior Probability or Bayesian Posterior Predictive Probability for a Clinical Trial When Outcome is Continuous
Source:R/pPPsinglecontinuous.R
pPPsinglecontinuous.RdThis 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 three calculation methods: numerical integration, Monte Carlo simulation, and Welch-Satterthwaite approximation. For external control designs, power priors are incorporated using exact conjugate representation as Normal-Inverse-Chi-squared distributions, enabling closed-form computation without MCMC sampling.
Usage
pPPsinglecontinuous(
prob = "posterior",
design = "controlled",
prior = "vague",
CalcMethod = "NI",
theta0,
nMC = NULL,
n1,
n2,
m1 = NULL,
m2 = NULL,
kappa01 = NULL,
kappa02 = NULL,
nu01 = NULL,
nu02 = NULL,
mu01 = NULL,
mu02 = NULL,
sigma01 = NULL,
sigma02 = NULL,
bar.y1,
bar.y2,
s1,
s2,
r = NULL,
ne1 = NULL,
ne2 = NULL,
alpha01 = NULL,
alpha02 = NULL,
bar.ye1 = NULL,
bar.ye2 = NULL,
se1 = NULL,
se2 = NULL,
lower.tail = TRUE
)Arguments
- prob
A character string specifying the type of probability to use (
prob = 'posterior'orprob = 'predictive').- design
A character string specifying the type of trial design (
design = 'controlled',design = 'uncontrolled', ordesign = 'external').- prior
A character string specifying the prior distribution (
prior = 'N-Inv-Chisq'orprior = 'vague').- CalcMethod
A character string specifying the calculation method (
CalcMethod = 'NI'for numerical integration,CalcMethod = 'MC'for Monte Carlo method, orCalcMethod = 'WS'for Welch-Satterthwaite approximation).- theta0
A numeric value representing the pre-specified threshold value.
- nMC
A positive integer representing the number of iterations for Monte Carlo simulation (required if
CalcMethod = 'MC').- n1
A positive integer representing the number of patients in group 1 for the 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 the outcomes for group 1.
- sigma02
A positive numeric value representing the prior standard deviation of the outcomes for group 2.
- 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 ratio of the hypothesized values for the null hypotheses (required if
design = 'uncontrolled').- ne1
A positive integer representing the number of patients in group 1 for the external data (required if external treatment data available).
- ne2
A positive integer representing the number of patients in group 2 for the external data (required if external control data available).
- alpha01
A numeric value in
[0, 1]: representing the scale parameter (power prior) for group 1 (required if external treatment data available). Controls the degree of borrowing: 0 = no borrowing, 1 = full borrowing.- alpha02
A numeric value in
[0, 1]representing the scale parameter (power prior) for group 2 (required if external control data available). Controls the degree of borrowing: 0 = no borrowing, 1 = full borrowing.- bar.ye1
A numeric value representing the external sample mean of group 1 (required if external treatment data available).
- bar.ye2
A numeric value representing the external sample mean of group 2 (required if external control data available).
- se1
A positive numeric value representing the external sample standard deviation of group 1 (required if external treatment data available).
- se2
A positive numeric value representing the external sample standard deviation of group 2 (required if external control data available).
- lower.tail
logical; if TRUE (default), probabilities are P(theta <= theta0), otherwise, P(theta > theta0)
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.
For controlled and uncontrolled designs, three 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
For external control designs, power priors are incorporated using exact conjugate representation:
Power priors for normal data are mathematically equivalent to Normal-Inverse-Chi-squared distributions
This enables closed-form posterior computation without MCMC sampling
Alpha parameters control the degree of borrowing (0 = no borrowing, 1 = full borrowing)
The method preserves complete Bayesian rigor with no approximation
The external design supports:
External control data only (ne2, alpha02, bar.ye2, se2)
External treatment data only (ne1, alpha01, bar.ye1, se1)
Both external control and treatment data
Examples
# Example 1: Numerical Integration (NI) method with N-Inv-Chisq prior
pPPsinglecontinuous(
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, lower.tail = FALSE
)
#> [1] 0.4167132
# Example 2: Monte Carlo (MC) method with vague prior
pPPsinglecontinuous(
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, lower.tail = FALSE
)
#> [1] 0.9501
# Example 3: Welch-Satterthwaite (WS) approximation with N-Inv-Chisq prior
pPPsinglecontinuous(
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, lower.tail = FALSE
)
#> [1] 0.5429566
# Example 4: External control design with power prior (NI method)
pPPsinglecontinuous(
prob = 'posterior', design = 'external', prior = 'vague', CalcMethod = 'NI',
theta0 = 1.5, n1 = 12, n2 = 12, bar.y1 = 4, bar.y2 = 2, s1 = 1.2, s2 = 1.1,
ne2 = 20, alpha02 = 0.5, bar.ye2 = 1.8, se2 = 1.0, lower.tail = FALSE
)
#> [1] 0.9116773
# Example 5: External design with both treatment and control data
pPPsinglecontinuous(
prob = 'posterior', design = 'external', prior = 'N-Inv-Chisq', CalcMethod = 'WS',
theta0 = 1.0, n1 = 15, n2 = 15, bar.y1 = 3.5, bar.y2 = 2.0, s1 = 1.3, s2 = 1.1,
kappa01 = 2, kappa02 = 2, nu01 = 3, nu02 = 3, mu01 = 3, mu02 = 2,
sigma01 = 1.5, sigma02 = 1.5,
ne1 = 25, ne2 = 25, alpha01 = 0.7, alpha02 = 0.7,
bar.ye1 = 3.2, bar.ye2 = 1.9, se1 = 1.4, se2 = 1.2, lower.tail = FALSE
)
#> [1] 0.8868462