| Version: | 0.1 |
| Date: | 2026-03-03 |
| Author: | Samuel Pawel |
| Maintainer: | Samuel Pawel <samuel.pawel@uzh.ch> |
| Title: | Null Hypothesis Bayesian Response-Adaptive Randomization |
| Description: | Implements Bayesian response-adaptive randomization methods based on Bayesian hypothesis testing for multi-arm settings (Pawel and Held, 2025, <doi:10.48550/arXiv.2510.01734>). |
| License: | GPL-3 |
| Encoding: | UTF-8 |
| Imports: | mvtnorm |
| Suggests: | roxygen2, tinytest |
| NeedsCompilation: | no |
| RoxygenNote: | 7.3.3 |
| URL: | https://github.com/SamCH93/brar |
| BugReports: | https://github.com/SamCH93/brar/issues |
| Packaged: | 2026-03-03 09:26:06 UTC; sam |
| Repository: | CRAN |
| Date/Publication: | 2026-03-06 18:00:08 UTC |
Bayesian response-adaptive randomization for binomial outcomes
Description
This function computes Bayes factors, posterior probabilities, and response-adaptive randomization probabilities for binomial outcomes.
Usage
brar_binomial(
y,
n,
a0 = 1,
b0 = 1,
a = rep(1, length(y)),
b = rep(1, length(y)),
pH0 = 0.5,
...
)
Arguments
y |
Vector with number of successes in each group. The first element corresponds to the control group, and the remaining elements correspond to the treatment groups |
n |
Vector with number of trials in each group. The first element corresponds to the control group, and the remaining elements correspond to the treatment groups |
a0 |
Number of successes parameter of beta prior for common probability
under the null hypothesis. Defaults to |
b0 |
Number of failures parameter of beta prior for common probability
under the null hypothesis. Defaults to |
a |
Vector of number of successes parameters of beta priors for
probabilities in each group under the alternative hypothesis. The first
element corresponds to the control group, and the remaining elements
correspond to the treatment groups. Defaults to |
b |
Vector of number of failures parameters of beta priors for
probabilities in each group under the alternative hypothesis. The first
element corresponds to the control group, and the remaining elements
correspond to the treatment groups. Defaults to |
pH0 |
Prior probability of the null hypothesis (i.e., a common
probability in the control and all treatment groups). Defaults to
|
... |
Other arguments passed to |
Value
An object of type "brar", which is a list with the following
elements: "data" (input data), "prior" (prior probability
of the null hypothesis and prior probabilities of control/treatment
superiority), "BF_ij" (Bayes factor matrix), "posterior"
(posterior probability of the null hypothesis and posterior probabilities
of control/treatment superiority), and "prand" (response-adaptive
randomization probabilities).
Author(s)
Samuel Pawel
Examples
## 1 control and 1 treatment group
y <- c(15, 12)
n <- c(20, 15)
brar_binomial(y = y, n = n, pH0 = 0.5)
## 1 control and 5 treatment groups
y <- c(10, 10, 10, 10, 10, 10)
n <- c(15, 15, 20, 17, 13, 25)
brar_binomial(y = y, n = n, pH0 = 0.5)
Bayesian response-adaptive randomization for approximately normal effect estimates
Description
This function computes Bayes factors, posterior probabilities, and response-adaptive randomization probabilities for data summarized by approximately normal effect estimates.
Usage
brar_normal(estimate, sigma, pm = rep(0, length(estimate)), psigma, pH0 = 0.5)
Arguments
estimate |
Vector of effect estimates (e.g., a vector of mean differences or log odds/hazard/rate ratios). Each estimate quantifies the effect of a treatment relative to control |
sigma |
Covariance matrix of the effect estimate vector. In case, there is only one effect estimate, this is the squared standard error of the effect estimate |
pm |
Mean vector of the normal prior assigned to the effects under the
alternative. Defaults to |
psigma |
Covariance matrix of the normal prior assigned to the effects under the alternative. In case, there is only one effect estimate, this is the prior variance |
pH0 |
Prior probability of the point null hypothesis (i.e., all
treatment effects equal to 0). Defaults to |
Value
An object of type "brar", which is a list with the following
elements: "data" (input data), "prior" (prior probability
of the null hypothesis and prior probabilities of control/treatment
superiority), "BF_ij" (Bayes factor matrix), "posterior"
(posterior probability of the null hypothesis and posterior probabilities
of control/treatment superiority), and "prand" (response-adaptive
randomization probabilities).
Author(s)
Samuel Pawel
Examples
## simulate normal data from four treatment groups
set.seed(42)
n <- 10
muc <- 0
datc <- data.frame(y = rnorm(n, muc), group = "Control")
mu <- c(1, -0.5, 0, 0.25)
K <- length(mu)
datt <- do.call("rbind", lapply(seq(1, K), function(k) {
data.frame(y = rnorm(n, mu[k]), group = paste("Treatment", k))
}))
dat <- rbind(datc, datt)
fit <- lm(y ~ group, data = dat)
estimate <- fit$coef[-1]
sigma <- vcov(fit)[-1,-1]
pm <- rep(0, K)
## 0.5 correlated prior to distribute prior probability equally among treatments
rho <- 0.5
psigma <- matrix(rho, nrow = K, ncol = K)
diag(psigma) <- 1
brar_normal(estimate = estimate, sigma = sigma, pm = pm, psigma = psigma,
pH0 = 0.5)
## brar for only first treatment group
est <- summary(fit)$coefficients[2,1]
se <- summary(fit)$coefficients[2,2]
brar_normal(est, sigma = se^2, pm = 0, psigma = 1, pH0 = 0.5)