Package 'BayesAT'

Title: Bayesian Adaptive Trial
Description: Bayesian adaptive trial algorithm implements multiple-stage interim analysis. Package includes data generating function, and Bayesian hypothesis testing function.
Authors: Yuan Zhong [aut, cre], Zeynep Baskurt [aut], Wei Xu [aut]
Maintainer: Yuan Zhong <[email protected]>
License: GPL-3
Version: 0.1.0
Built: 2025-02-06 06:05:30 UTC
Source: https://github.com/cran/BayesAT

Help Index


Bayesian inference for survival analysis

Description

Bayes_test conduct hypothesis test through Bayesian survival model

Usage

Bayes_test(data, alpha, beta, test, threshold, type, pred, diagnosis = FALSE)

Arguments

data

Matrix. The data contains both survival time and event status.

alpha

Numerical. Gamma distribution alpha parameter.

beta

Numerical. Gamma distribution beta parameter (rate = 1/scale).

test

Categorical. Three types of hypothesis includes "greater", "less", or "two_sided".

threshold

Numerical. The value tested against hypothesis or evidence.

type

Categorical. The types of Bayesian inference include "Posterior" for estimation of parameters or "Predictive" for predicted survival rate.

pred

Numerical. The time point for predicted survival rate, for example, 2 years, or 5 years survival probability.

diagnosis

Logical. If diagnosis == TRUE, the Bayes factor is calculated, and the formulation of Bayesian factors is given in details.

Value

Bayesian test provide mean, sd, CI, z_score, prob, and bf.

mean Posterior mean is estimated by calculating the mean of MCMC outputs.

sd Posterior standard deviation is estimated as the standard deviation of MCMC outputs.

CISummary statistics provides the credible intervals and specific quantile.

z_score Standardized test of statistics is calculated based on MCMC outputs. For example,

λ^λ0SD(λ^) or S^S0SD(S^),\frac{\hat{\lambda} - \lambda_0}{SD( \hat{\lambda} )} \text{ or } \frac{ \hat{S} - S_0}{SD( \hat{S} )},

where λ^\hat{\lambda} is the estimated posterior mean of hazard rate, and S^\hat{S} is the predicted survival probability. Both λ0\lambda_0 and S0S_0 are threshold used for test against hypothesis or evidence.

prob Posterior probability: P(λ^>λ0)P(\hat{\lambda} > \lambda_0) if test is "greater", P(λ^λ0)P(\hat{\lambda} \le \lambda_0) if test is "less", and 2min(P(λ^>λ0),P(λ^λ0))2 min( P(\hat{\lambda} > \lambda_0),P(\hat{\lambda} \le \lambda_0)) if test is "two-sided".

bf Bayes Factor is calculated if diagnosis = TRUE, and the comparison model is non-informative prior, Jeffreys prior, π1/λ\pi \propto 1/\lambda.

References

Jeffreys, H. (1946). An invariant form for the prior probability in estimation problems. Proceedings of the Royal Society of London. Series A. Mathematical and Physical Sciences, 186(1007), 453-461.

Kass, R. E., & Raftery, A. E. (1995). Bayes factors. Journal of the american statistical association, 90(430), 773-795.

Examples

data <- Simulate_Enroll(n = c(50,20,20), lambda = 0.03,
                        event = 0.1, M = 1, group = 3,
                        maxt = 5, accrual = 3, censor = 0.9,
                        followup = 2,partition = "Uneven")
test <- Bayes_test(data, alpha = 3, beta = 82, test = "greater",
                   pred = 2, threshold = 0.9, type = "Predictive",
                   diagnosis = TRUE)
print(test)

Bayesian adaptive trial interim analysis

Description

BayesAT conducts Bayesian adaptive trials through multiple-stage interim analysis.

Usage

BayesAT(
  data,
  D,
  stage,
  threshold,
  start,
  objective,
  alpha,
  beta,
  boundary = NULL
)

Arguments

data

Matrix. The data contains both survival time and event status.

D

Numerical. The duration of interim analysis, matching the length of enrollment time.

stage

Integer. Numbers of interim analysis stages.

threshold

Numerical. The value tested against hypothesis or evidence.

start

Numerical. The time point when the interim analysis starts.

objective

Numerical. The time point for predicted survival rate, for example, 2 years, or 5 years survival probability.

alpha

Numerical. Gamma distribution alpha parameter.

beta

Numerical. Gamma distribution beta parameter (rate = 1/scale).

boundary

The stopping criterion for interim analysis, and the default sets at 5% significance level and calculate quantiles by qnorm() for each stages.

Value

Interim analysis reporting Bayesian adaptive trial results.

If there is one data set applied to BayesAT, the result will provide a table containing:

⁠Upper bound⁠ can be used as stopping criterion for efficacy;

⁠Lower bound⁠ can be used as stopping criterion for futility;

⁠Z score⁠ Z statistic is calculated based on the predicted survival probability:

S^S0SD(S^)\frac{\hat{S} - S_0}{SD( \hat{S} )}

with predicted mean survival rate S^\hat{S} and test evidence or threshold S0S_0.

⁠Efficacy Prob⁠ and ⁠Futility Prob⁠ Predictive probability measures the efficacy or futility, such as P(S^>Efficacy)P(\hat{S} > \text{Efficacy}) and P(S^<Futility)P(\hat{S} < \text{Futility}).

Efficacy and Futility indicate the interim analysis results: + means the trial reach the stopping criterion, otherwise it is -.

Examples

data <- Simulate_Enroll(n = c(30,20,20,15,30), lambda = 0.03,
                        event = 0.1, M = 3, group = 5, maxt = 5,
                        accrual = 3,  censor = 0.9, followup = 2,
                        partition = "Uneven")
## assign patients in each group analyzed at each stage of time points
IA <- BayesAT(data,D = 3,stage = 5,threshold = 0.9, start = 1.5,
              objective = 2, alpha = 3, beta = 82)
summary(IA)
plot(IA)

Survival data simulation

Description

Simulate_Enroll generates multiple streams of data sets with survival time, censoring status, and enrollment time.

Usage

Simulate_Enroll(
  n,
  lambda,
  event,
  M,
  group,
  maxt,
  accrual,
  censor,
  followup,
  partition = "Even"
)

Arguments

n

Integer. Sample size of patients

lambda

Numerical range 0 and 1. Hazard rate of expoential distribution

event

Numerical range 0 and 1. Event rate

M

Integer. Number of trials generated for multiple streams of MCMC

group

Integer. Number of subgroup for patient enrollment

maxt

Numerical. The maximum time length of entire trial

accrual

Numerical. The duration of patient enrolment

censor

Numerical range 0 and 1. The censoring rate of patients leaving before trial ends.

followup

Integer. The time length of follow up.

partition

Logical. If ⁠partition == "Even", the trial recruits equal numbers of patients in each stage; and if ⁠partition == "Uneven", the trial recruits unequal numbers of patients in each stage.

Value

Simulated survival data contain both survival time, censoring status, and enrollment time.

Examples

data <- Simulate_Enroll(n = c(50,20,20), lambda = 0.03,
                        event = 0.1, M = 3, group = 3, maxt = 5,
                        accrual = 3,  censor = 0.9, followup = 2,
                        partition = "Uneven")
head(data[[1]])
head(data[[2]])
head(data[[3]])