Title: | Bayesian Adaptive Trial Simulator Software (BATSS) for Generalised Linear Models |
---|---|
Description: | Defines operating characteristics of Bayesian Adaptive Trials considering a generalised linear model response via Monte Carlo simulations of Bayesian GLM fitted via integrated Laplace approximations (INLA). |
Authors: | Dominique-Laurent Couturier [aut, cre] , Liz Ryan [aut] , Rainer Puhr [aut], Thomas Jaki [aut] , Stephane Heritier [aut] |
Maintainer: | Dominique-Laurent Couturier <[email protected]> |
License: | GPL-2 |
Version: | 1.0.0 |
Built: | 2024-11-01 06:10:42 UTC |
Source: | https://github.com/batss-dev/batss |
alloc.balanced first allocates the largest possible number of units to the different groups given their exact target probabilities and then assigns randomly the remaining units to the different groups according to multinomial draws. This method leads to observed allocation probabilities matching the target ones when m*prob is an integer for each group and to observed allocation probabilities (on average) closer to the target ones compared to alloc.simple.
alloc.balanced(m, prob)
alloc.balanced(m, prob)
m |
the 'BATSS' ingredient ' |
prob |
the 'BATSS' ingredient ' |
alloc.balanced returns an object of class factor of length 'm
' with levels matching the names of the vector 'prob
'.
alloc.simple()
, another group allocation function.
alloc.balanced(100, prob = c(A=.4,B=.6)) table(alloc.balanced(100, prob = c(A=.4,B=.6))) table(alloc.balanced(100, prob = c(A=.4,B=.6)))
alloc.balanced(100, prob = c(A=.4,B=.6)) table(alloc.balanced(100, prob = c(A=.4,B=.6))) table(alloc.balanced(100, prob = c(A=.4,B=.6)))
alloc.simple independently randomises each unit to a group (i.e., flips a coin for each unit) so that the observed allocation probabilities may be far from the target ones. This strategy is often considered to be a poor choice.
alloc.simple(m, prob)
alloc.simple(m, prob)
m |
the 'BATSS' ingredient ' |
prob |
the 'BATSS' ingredient ' |
alloc.simple returns an object of class factor of length 'm
' with levels matching the names of the vector 'prob
'.
alloc.balanced()
, another group allocation function.
alloc.simple(100, prob = c(A=.4,B=.6)) table(alloc.simple(100, prob = c(A=.4,B=.6))) table(alloc.simple(100, prob = c(A=.4,B=.6)))
alloc.simple(100, prob = c(A=.4,B=.6)) table(alloc.simple(100, prob = c(A=.4,B=.6))) table(alloc.simple(100, prob = c(A=.4,B=.6)))
Combines different evaluations of batss.glm considering the same trial design but different sets of seeds. This function is useful when the evaluation of Monte Carlo samples generated by different seeds was split in sets computed by different nodes/cpus. The output of this function is of class 'batss' meaning that the usual generic functions (print, summary, plot) can be used.
batss.combine(paths, force = FALSE)
batss.combine(paths, force = FALSE)
paths |
Vector indicating the paths to the rdata files containing the outputs of the function batss.glm considering the same trial design but different set of seeds. This requires the argument ' |
force |
a logical with default |
an object of class 'batss'. Refer to the section 'Value' in batss.glm for details about this object structure.
batss.glm()
, the function allowing to simulate Bayesian adaptive trials with GLM endpoint for different seeds.
Simulation of Bayesian adaptive trials with GLM endpoint using Integrated Nested Laplace Approximation (INLA).
batss.glm( model, var, var.control = NULL, family = "gaussian", link = "identity", beta, which, alternative = "greater", R = 10000, N, interim, prob0, delta.eff = 0, delta.fut = delta.eff, delta.RAR = 0, eff.arm, eff.arm.control = NULL, eff.trial = NULL, eff.trial.control = NULL, fut.arm, fut.arm.control = NULL, fut.trial = NULL, fut.trial.control = NULL, RAR = NULL, RAR.control = NULL, H0 = TRUE, computation = "parallel", mc.cores = getOption("mc.cores", 3L), extended = 0, ... )
batss.glm( model, var, var.control = NULL, family = "gaussian", link = "identity", beta, which, alternative = "greater", R = 10000, N, interim, prob0, delta.eff = 0, delta.fut = delta.eff, delta.RAR = 0, eff.arm, eff.arm.control = NULL, eff.trial = NULL, eff.trial.control = NULL, fut.arm, fut.arm.control = NULL, fut.trial = NULL, fut.trial.control = NULL, RAR = NULL, RAR.control = NULL, H0 = TRUE, computation = "parallel", mc.cores = getOption("mc.cores", 3L), extended = 0, ... )
model |
an object of class 'formula' indicating a symbolic description of the model to be fitted (as in the lm and glm functions). |
var |
A list. Each entry corresponds to a variable described under ' |
var.control |
An optional list of control parameters for the functions indicated in ' |
family |
A character string indicating the name of the conditional distribution as described in the package INLA (check inla.list.models). Default set to ' |
link |
A character string describing the link function to be used in the model to relate the outcome to the set of predictors: 'identity', 'log', 'logit', 'probit', 'robit', 'cauchit', 'loglog' and 'cloglog' are the currently available options. Default set to 'identity'. |
beta |
A numerical vector of parameter values for the linear predictor. Its length has to match the number of column of the X matrix induced by the formula indicated under ' |
which |
A numerical vector indicating the position of the target |
alternative |
A vector of strings providing the one-sided direction of the alternative hypothesis corresponding to each target parameter indicated under ' |
R |
a vector of natural numbers to be used as seeds (check set.seed) for the different Monte Carlo trials (the vector length will thus correspond to the number of Monte Carlo trials). When |
N |
A scalar indicating the maximum sample size. |
interim |
A list of parameters related to interim analyses. Currently, only ' |
prob0 |
A named vector with initial allocation probabilities. Names need to correspond to the levels of the grouping variable. If |
delta.eff |
A vector (of length equal to the number of looks (i.e., number of interims + 1)) of clinically meaningful treatment effect values (on the linear predictor scale) to be used to define the efficacy-related posterior probabilities for each target parameter at each look. If a scalar is provided, the same value is used at each look. The default is |
delta.fut |
A vector (of length equal to the number of looks (i.e., number of interims + 1)) of clinically meaningful treatment effect values (on the linear predictor scale) to be used to define the futility-related posterior probabilities for each target parameter at each look. If a scalar is provided, the same value is used at each look. The default is |
delta.RAR |
A vector (of length equal to the number of looks (i.e., number of interims + 1)) of clinically meaningful treatment effect values (on the linear predictor scale) to be used to define the RAR-related posterior probabilities for each target parameter at each look. If a scalar is provided, the same value is used at each interim analysis. The default is |
eff.arm |
A function defining if efficacy has been achieved at a given look given the information available at that stage a given target parameter. The output of this function must be a logical (of length 1). Arguments of this function will typically consider 'BATSS' ingredients. Check eff.arm.simple and eff.arm.infofract for examples. |
eff.arm.control |
An optional list of parameters for the function indicated in ' |
eff.trial |
A function defining if the trial can be stopped for efficacy given the output of the function indicated in ' |
eff.trial.control |
An optional list of parameters for the function indicated in ' |
fut.arm |
A function defining if futility has been achieved at a given look given the information available at that stage for each target parameter. The output of this function must be a logical (of length 1). Arguments of this function will typically consider 'BATSS' ingredients. Check fut.arm.simple to see an example of such a function. |
fut.arm.control |
An optional list of parameters for the function indicated in ' |
fut.trial |
A function defining if the trial can be stopped for futility given the output of the function indicated in ' |
fut.trial.control |
An optional list of parameters for the function indicated in ' |
RAR |
A function defining the response-adaptive randomisation probabilities of each group - reference group included - with the same group names and ordering as used in ' |
RAR.control |
An optional list of control parameters for the function provided in ' |
H0 |
A logical indicating whether the simulation should also consider the case with all target parameters set to 0 to check the probability of rejecting the hypothesis that the target parameter value is equal to 0 individually (pairwise type I error) or globally (family-wise error rate). Default set to |
computation |
A character string indicating how the computation should be performed. Possibilities are 'parallel' or 'sequential' with default |
mc.cores |
An integer indicating the number of CPUs to be used when |
extended |
an integer indicating the type of results to be returned. 0 (default) provides summary statistics, 1 adds the results of each Monte Carlo trial and 2 additionally returns each Monte Carlo dataset. batss.combine requires extended > 0 as the function needs to merge results of different sets of seeds. |
... |
Additional arguments to control fitting in inla. |
The function batss.glm returns an S3 object of class 'batss' with available print/summary/plot functions
beta - A data frame providing information related to the beta parameter vector, like parameter names and values, for example.
look - A data frame providing information related to looks, like sample size of a given interim (m) and cumulative sample size at a given interim (n), for example.
par - A list providing different information, like the used seeds (seed) and the groups (group), for example.
H1 - A list providing trial results under the alternative, like the estimates per target parameter when the corresponding arm was stopped (estimate), the efficacy and futility probabilites per target parameter and overall (target, efficacy and futility), the sample size per group and trial (sample), the probabilities associated to each combination of efficacy and futility per group (scenario), the detailed results per trial (trial), for example.
H0 - A list providing trial results under the global null hypothesis (same structure as H1).
call - The matched call.
type - The type of 'BATSS' analysis (only 'glm' is currently available).
summary.batss and plot.batss for detailed summaries and plots, and batss.combine to combine different evaluations of batss.glm considering the same trial design but different sets of seeds (useful for cluster computation).
# Example: # * Gaussian conditional distribution with sigma = 5 # * 3 groups with group means 'C' = 1 (ref), 'T1' = 2, 'T2' = 3, # where higher means correspond to better outcomes # * 5 interim analyses occurring when n = 100, 120, 140, 160, and 180 # * fixed and equal allocation probabilities per arm (i.e., no RAR) # * max sample size = 200 # * efficacy stop per arm when the prob of the corresponding parameter # being greater than 0 is greater than 0.975 (?eff.arm.simple) # * futility stop per arm when the prob of the corresponding parameter # being greater than 0 is smaller than 0.05 (?fut.arm.simple) # * trial stop once all arms have stopped (?eff.trial.all and ?fut.trial.all) # or the max sample size was reached sim = batss.glm(model = y ~ group, var = list(y = rnorm, group = alloc.balanced), var.control = list(y = list(sd = 5)), beta = c(1, 1, 2), which = c(2:3), alternative = "greater", R = 20, N = 200, interim = list(recruited = seq(100, 180, 20)), prob0 = c(C = 1/3, T1 = 1/3, T2 = 1/3), eff.arm = eff.arm.simple, eff.arm.control = list(b = 0.975), fut.arm = fut.arm.simple, fut.arm.control = list(b = 0.05), computation = "parallel", H0 = TRUE, mc.cores = 2)# better: parallel::detectCores()-1
# Example: # * Gaussian conditional distribution with sigma = 5 # * 3 groups with group means 'C' = 1 (ref), 'T1' = 2, 'T2' = 3, # where higher means correspond to better outcomes # * 5 interim analyses occurring when n = 100, 120, 140, 160, and 180 # * fixed and equal allocation probabilities per arm (i.e., no RAR) # * max sample size = 200 # * efficacy stop per arm when the prob of the corresponding parameter # being greater than 0 is greater than 0.975 (?eff.arm.simple) # * futility stop per arm when the prob of the corresponding parameter # being greater than 0 is smaller than 0.05 (?fut.arm.simple) # * trial stop once all arms have stopped (?eff.trial.all and ?fut.trial.all) # or the max sample size was reached sim = batss.glm(model = y ~ group, var = list(y = rnorm, group = alloc.balanced), var.control = list(y = list(sd = 5)), beta = c(1, 1, 2), which = c(2:3), alternative = "greater", R = 20, N = 200, interim = list(recruited = seq(100, 180, 20)), prob0 = c(C = 1/3, T1 = 1/3, T2 = 1/3), eff.arm = eff.arm.simple, eff.arm.control = list(b = 0.975), fut.arm = fut.arm.simple, fut.arm.control = list(b = 0.05), computation = "parallel", H0 = TRUE, mc.cores = 2)# better: parallel::detectCores()-1
allows stopping an arm for efficacy at a given look when the probability of the corresponding target parameter being greater or smaller (depending on the argument 'alternative'
of batss.glm) than delta.eff
is greater than a function of the information fraction at that look.
eff.arm.infofract(posterior, b, n, N, p)
eff.arm.infofract(posterior, b, n, N, p)
posterior |
the 'BATSS' ingredient ' |
b |
a tuning parameter (to be defined in |
n |
the 'BATSS' ingredient ' |
N |
the 'BATSS' ingredient 'āNā corresponding to the maximum (planned) sample size. |
p |
a tuning parameter (to be defined in |
eff.arm.infofract returns a logical constant.
allows stopping an arm for efficacy at a given look when the probability of the corresponding target parameter being greater or smaller (depending on the argument 'alternative'
of batss.glm) than delta.eff
is greater than a fixed value b
.
eff.arm.simple(posterior, b)
eff.arm.simple(posterior, b)
posterior |
the 'BATSS' ingredient ' |
b |
the cut-off value used to declare efficacy (to be defined in |
eff.arm.simple returns a logical constant.
allows stopping the trial for efficacy if all target parameters reached efficacy at the look of interest or before.
eff.trial.all(eff.target)
eff.trial.all(eff.target)
eff.target |
the 'BATSS' ingredient ' |
eff.trial.all returns a logical constant.
allows stopping the trial for efficacy if at least one target parameter reached efficacy at the look of interest.
eff.trial.any(eff.target)
eff.trial.any(eff.target)
eff.target |
the 'BATSS' ingredient ' |
eff.trial.any returns a logical constant.
allows stopping an arm for futility when the probability of the corresponding target parameter being greater or smaller (depending on the argument 'alternative'
of batss.glm) than 'delta.fut
' is smaller than a fixed value 'b
'
fut.arm.simple(posterior, b)
fut.arm.simple(posterior, b)
posterior |
the 'BATSS' ingredient ' |
b |
the cut-off value used to declare futility (to be defined in |
fut.arm.simple returns a logical constant.
allows stopping the trial for efficacy if all active treatment reached futility at the look of interest or before.
fut.trial.all(fut.target)
fut.trial.all(fut.target)
fut.target |
the 'BATSS' ingredient ' |
fut.trial.all returns a logical constant.
Plot for objects of class 'batss'
## S3 method for class 'batss' plot( x, type = "size", hypothesis = "H1", title = TRUE, legend = TRUE, col = c("#008B0040", "#8B3A3A40", "#8B897040", "#FF990075", "blue"), ... )
## S3 method for class 'batss' plot( x, type = "size", hypothesis = "H1", title = TRUE, legend = TRUE, col = c("#008B0040", "#8B3A3A40", "#8B897040", "#FF990075", "blue"), ... )
x |
An object of class 'batss' (i.e., output of the function batss.glm). |
type |
A character string indicating the type of plot with options 'size' (default) to display the total and per group sample size observed in the Monte Carlo trials, and 'estimates' to display the Monte Carlo trial target estimates as a function of the sample size. |
hypothesis |
A character string indicating which alternative hypothesis to use for analyses considering both "H0" and "H1", with options "H1" (default) and "H0". |
title |
Either a logical indicating if a title should be added or a string (of class character) indicating the title to be added. If |
legend |
a logical (with default set to |
col |
a vector of length 5 specifiying the colour respectively assigned to i/ efficacy, ii/ futility, iii/ neither or iv/ both when color-coding trials when |
... |
Additional arguments affecting the plot produced, like ylim and ylab. |
Generates graphical displays of results for objects of class 'batss'.
batss.glm()
, the function generating S3 objects of class 'batss'.
Print method function for objects of class 'batss' (i.e., output of the function batss.glm).
## S3 method for class 'batss' print(x, ...)
## S3 method for class 'batss' print(x, ...)
x |
An object of class 'batss'. |
... |
Additional arguments affecting the print produced. |
Prints information for objects of class 'batss'.
batss.glm()
, the function generating S3 objects of class 'batss'.
technically not response adaptive but keeps allocation ratio to control at the square root of active intervention arms
RAR.optimal(active)
RAR.optimal(active)
active |
the 'BATSS' ingredient ' |
RAR.optimal returns a vector of probabilities with length of active.
define the group allocation probabilities based on the response adaptive randomisation rule of Trippa et al. (2012)
RAR.trippa(posterior, n, N, ref, active, gamma, eta, nu)
RAR.trippa(posterior, n, N, ref, active, gamma, eta, nu)
posterior |
the 'BATSS' ingredient ' |
n |
the 'BATSS' ingredient ' |
N |
the 'BATSS' ingredient 'āNā corresponding to the maximum (planned) sample size. |
ref |
the 'BATSS' ingredient ' |
active |
the 'BATSS' ingredient ' |
gamma |
a scaling factor (to be defined in |
eta |
a scaling factor (to be defined in |
nu |
a scaling factor (to be defined in |
RAR.trippa returns a vector of probabilities with length of active.
Summary method function for objects of class 'batss'.
## S3 method for class 'batss' summary(object, full = FALSE, ...)
## S3 method for class 'batss' summary(object, full = FALSE, ...)
object |
An object of class 'batss' (i.e., output of the function batss.glm). |
full |
A logical indicating if a standard (full = FALSE, default) or extended output (full = TRUE) should be returned. |
... |
Additional arguments affecting the summary produced. |
Prints a summary for objects of class 'batss'.
batss.glm()
, the function generating S3 objects of class 'batss'.