Title: | Tipping Point Analysis for Bayesian Dynamic Borrowing |
---|---|
Description: | Tipping point analysis for clinical trials that employ Bayesian dynamic borrowing via robust meta-analytic predictive (MAP) priors. Further functions facilitate expert elicitation of a primary weight of the informative component of the robust MAP prior and computation of operating characteristics. Intended use is the planning, analysis and interpretation of extrapolation studies in pediatric drug development, but applicability is generally wider. |
Authors: | Christian Stock [aut, cre] , Morten Dreher [aut], Emma Torrini [ctb], Boehringer Ingelheim Pharma GmbH & Co. KG [cph, fnd] |
Maintainer: | Christian Stock <[email protected]> |
License: | Apache License 2.0 |
Version: | 0.5.3 |
Built: | 2024-11-06 06:14:27 UTC |
Source: | https://github.com/boehringer-ingelheim/tipmap |
Creates a vector containing data on the new trial in the target population. This may be hypothetical data in the planning stage.
create_new_trial_data(n_total, est, se)
create_new_trial_data(n_total, est, se)
n_total |
The total sample size. |
est |
Treatment effect estimate. |
se |
Standard error of the treatment effect estimate. |
A numeric vector with data on the new trial, incl. quantiles of an assumed normal data likelihood.
[create_posterior_data()] and [create_tipmap_data()].
new_trial_data <- create_new_trial_data( n_total = 30, est = 1.27, se = 0.95 )
new_trial_data <- create_new_trial_data( n_total = 30, est = 1.27, se = 0.95 )
Returns a data frame containing the default quantiles of posterior mixture distributions or bounds of highest posterior density intervals, generated with varying weights on the informative component of the MAP prior.
create_posterior_data( map_prior, new_trial_data, sigma, null_effect = 0, interval_type = "equal-tailed", n_samples = 10000 )
create_posterior_data( map_prior, new_trial_data, sigma, null_effect = 0, interval_type = "equal-tailed", n_samples = 10000 )
map_prior |
A MAP prior containing information about the trial(s) in
the source population, created using |
new_trial_data |
A vector containing information about the new trial.
See |
sigma |
Standard deviation to be used for the weakly informative component of the MAP prior, recommended to be the unit-information standard deviation. |
null_effect |
The mean of the robust component of the MAP prior. Defaults to 0. |
interval_type |
The type of credible interval (character of length 1), either 'equal-tailed' (default) or 'hpdi', the highest posterior density interval. |
n_samples |
Number of samples to compute highest posterior density intervals (hence, only applicable if the 'interval_type' is 'hpdi'). |
Highest posterior density intervals are based on 'coda::HPDinterval()' and are an experimental feature.
A data frame containing the default quantiles of posterior mixture distributions or bounds of highest posterior density intervals.
Best, N., Price, R. G., Pouliquen, I. J., & Keene, O. N. (2021). Assessing efficacy in important subgroups in confirmatory trials: An example using Bayesian dynamic borrowing. Pharm Stat, 20(3), 551–562. https://doi.org/10.1002/pst.2093
[create_new_trial_data()] and [create_prior_data()]
# create vector containing data on new trial new_trial_data <- create_new_trial_data( n_total = 30, est = 1.27, se = 0.95 ) # read MAP prior created by RBesT map_prior <- load_tipmap_data("tipmapPrior.rds") # create posterior data - with interval_type = equal_tailed # (the default for tipping point plots) posterior_data1 <- create_posterior_data( map_prior = map_prior, new_trial_data = new_trial_data, sigma = 12, interval_type = "equal-tailed" ) # create posterior data - with interval_type = hpdi posterior_data2 <- create_posterior_data( map_prior = map_prior, new_trial_data = new_trial_data, sigma = 12, interval_type = "hpdi", n_samples = 1e4 )
# create vector containing data on new trial new_trial_data <- create_new_trial_data( n_total = 30, est = 1.27, se = 0.95 ) # read MAP prior created by RBesT map_prior <- load_tipmap_data("tipmapPrior.rds") # create posterior data - with interval_type = equal_tailed # (the default for tipping point plots) posterior_data1 <- create_posterior_data( map_prior = map_prior, new_trial_data = new_trial_data, sigma = 12, interval_type = "equal-tailed" ) # create posterior data - with interval_type = hpdi posterior_data2 <- create_posterior_data( map_prior = map_prior, new_trial_data = new_trial_data, sigma = 12, interval_type = "hpdi", n_samples = 1e4 )
Assembling information from trials in the source population in a structured way (required as a pre-processing step for MAP prior creation).
create_prior_data(study_label = NULL, n_total, est, se)
create_prior_data(study_label = NULL, n_total, est, se)
study_label |
An optional vector containing trial labels. |
n_total |
A vector containing total sample sizes. |
est |
A vector containing treatment effect estimates. |
se |
A vector containing standard errors of the effect estimates. |
A data frame containing data on the trials in the source population.
[create_new_trial_data()] and [create_posterior_data()].
prior_data <- create_prior_data( n_total = c(160, 240, 320), est = c(1.23, 1.40, 1.51), se = c(0.4, 0.36, 0.31) )
prior_data <- create_prior_data( n_total = c(160, 240, 320), est = c(1.23, 1.40, 1.51), se = c(0.4, 0.36, 0.31) )
Combines new trial data created by createTargetData()
, a posterior distribution created by create_posterior_data()
and a
robust MAP prior using RBesT::automixfit()
and an optional meta-analysis, e.g. created using the meta
package, into a data frame
needed for the functions tipmap_plot()
and get_tipping_point()
.
create_tipmap_data(new_trial_data, posterior, map_prior, meta_analysis = NULL)
create_tipmap_data(new_trial_data, posterior, map_prior, meta_analysis = NULL)
new_trial_data |
A data frame containing data on the new trial in the target population. See |
posterior |
A mixture combining MAP prior and target population. See |
map_prior |
A robust MAP prior created by |
meta_analysis |
A data frame containing a meta-analysis of trial(s) to be borrowed from. See |
A data frame ready to be used for tipmap_plot()
and get_tipping_point()
[create_new_trial_data()], [create_posterior_data()], [tipmap_plot()] and [get_tipping_points()].
# specify new trial data new_trial_data <- create_new_trial_data(n_total = 30, est = 1.5, se = 2.1) # read MAP prior data map_prior <- load_tipmap_data("tipmapPrior.rds") # read posterior data posterior <- load_tipmap_data("tipPost.rds") tip_dat <- create_tipmap_data( new_trial_data = new_trial_data, posterior = posterior, map_prior = map_prior )
# specify new trial data new_trial_data <- create_new_trial_data(n_total = 30, est = 1.5, se = 2.1) # read MAP prior data map_prior <- load_tipmap_data("tipmapPrior.rds") # read posterior data posterior <- load_tipmap_data("tipPost.rds") tip_dat <- create_tipmap_data( new_trial_data = new_trial_data, posterior = posterior, map_prior = map_prior )
Default quantiles
default_quantiles
default_quantiles
An object of class numeric
of length 13.
Default weights
default_weights
default_weights
An object of class numeric
of length 201.
Draws samples from a mixture of beta distributions, representing pooled weights on the informative component of a robust MAP prior, as elicited from experts via the roulette method.
draw_beta_mixture_nsamples(n, chips_mult, expert_weight = NULL)
draw_beta_mixture_nsamples(n, chips_mult, expert_weight = NULL)
n |
Numeric value, the number of samples to be drawn. |
chips_mult |
Numeric matrix, containing expert weighting (distributions of chips). Rows should represent experts, columns should represent bins / weight intervals. |
expert_weight |
An optional numeric vector, containing the weight assigned to each expert (defaults to equal weights). |
A numeric vector containing samples from a pooled distribution of expert opinions.
[fit_beta_mult_exp()] and [get_summary_mult_exp()].
rweights <- draw_beta_mixture_nsamples( n = 50, chips_mult = rbind( c(0, 0, 0, 0, 2, 3, 3, 2, 0, 0), c(0, 0, 0, 1, 2, 4, 2, 1, 0, 0), c(0, 0, 0, 2, 2, 2, 2, 2, 0, 0) ), expert_weight = rep(1/3, 3) ) print(rweights) ## Not run: hist(rweights) ## End(Not run)
rweights <- draw_beta_mixture_nsamples( n = 50, chips_mult = rbind( c(0, 0, 0, 0, 2, 3, 3, 2, 0, 0), c(0, 0, 0, 1, 2, 4, 2, 1, 0, 0), c(0, 0, 0, 2, 2, 2, 2, 2, 0, 0) ), expert_weight = rep(1/3, 3) ) print(rweights) ## Not run: hist(rweights) ## End(Not run)
Fit beta distribution to data elicited from one expert via the roulette method.
fit_beta_1exp(df)
fit_beta_1exp(df)
df |
A dataframe generated by |
This function is based on SHELF::fitdist
and yields identical results.
Parameters (alpha
and beta
) of a beta fit.
[get_model_input_1exp()] and [fit_beta_mult_exp()].
chips <- c(0, 2, 3, 2, 1, 1, 1, 0, 0, 0) x <- get_cum_probs_1exp(chips) y <- get_model_input_1exp(x) fit_beta_1exp(df = y)["par"]
chips <- c(0, 2, 3, 2, 1, 1, 1, 0, 0, 0) x <- get_cum_probs_1exp(chips) y <- get_model_input_1exp(x) fit_beta_1exp(df = y)["par"]
Fit beta distributions to data elicited from multiple experts via the roulette method.
fit_beta_mult_exp(chips_mult)
fit_beta_mult_exp(chips_mult)
chips_mult |
A dataframe or matrix containing weights. It should contain one row per expert and 10 columns, one for each bin, representing weights from 0 to 1. |
A dataframe containing the parameters of the individual beta distributions.
[fit_beta_1exp()].
beta_fits <- fit_beta_mult_exp( chips_mult = rbind( c(0, 0, 0, 0, 2, 3, 3, 2, 0, 0), c(0, 0, 0, 1, 2, 4, 2, 1, 0, 0), c(0, 0, 0, 2, 2, 2, 2, 2, 0, 0) ) ) print(beta_fits)
beta_fits <- fit_beta_mult_exp( chips_mult = rbind( c(0, 0, 0, 0, 2, 3, 3, 2, 0, 0), c(0, 0, 0, 1, 2, 4, 2, 1, 0, 0), c(0, 0, 0, 2, 2, 2, 2, 2, 0, 0) ) ) print(beta_fits)
Get cumulative probabilities from distribution of chips of one expert
get_cum_probs_1exp(chips)
get_cum_probs_1exp(chips)
chips |
Vector of integers, representing the distribution of chips assigned by one expert, as elicited through the roulette method. Each element of the vector represents one bin in the grid. |
A numeric vector with the cumulative distribution of chips.
[get_model_input_1exp()] and [fit_beta_1exp()].
chips <- c(0, 2, 3, 2, 1, 1, 1, 0, 0, 0) x <- get_cum_probs_1exp(chips) print(x)
chips <- c(0, 2, 3, 2, 1, 1, 1, 0, 0, 0) x <- get_cum_probs_1exp(chips) print(x)
Transform cumulative probabilities to fit beta distributions
get_model_input_1exp(cum_probs, w = NULL)
get_model_input_1exp(cum_probs, w = NULL)
cum_probs |
Numeric vector, containing cumulative probabilities of weights for one expert, as elicited through the roulette method. Each element of the vector represents one bin in the grid. |
w |
Numeric vector, upper interval limit of bin (defaults to |
Dataframe to be used as input to fit beta distributions by [fit_beta_1exp()].
[get_cum_probs_1exp()] and [fit_beta_1exp()].
chips <- c(0, 2, 3, 2, 1, 1, 1, 0, 0, 0) x <- get_cum_probs_1exp(chips) print(x) y <- get_model_input_1exp(x) print(y)
chips <- c(0, 2, 3, 2, 1, 1, 1, 0, 0, 0) x <- get_cum_probs_1exp(chips) print(x) y <- get_model_input_1exp(x) print(y)
Returns quantiles of the posterior distribution of the treatment effect for one or more specified weights.
get_posterior_by_weight(posterior, weight)
get_posterior_by_weight(posterior, weight)
posterior |
The posterior data to be filtered (see [create_posterior_data()]). |
weight |
The weight(s) to be filtered by. |
The filtered posterior values
[create_posterior_data()].
get_posterior_by_weight( posterior = load_tipmap_data("tipPost.rds"), weight = c(0.05, 0.1) )
get_posterior_by_weight( posterior = load_tipmap_data("tipPost.rds"), weight = c(0.05, 0.1) )
Computes minimum, maximum, mean and quartiles for expert weights.
get_summary_mult_exp(chips_mult, n = 500, expert_weight = NULL)
get_summary_mult_exp(chips_mult, n = 500, expert_weight = NULL)
chips_mult |
Numeric matrix, containing expert weights. |
n |
Number of samples to be drawn to obtain summary statistics (defaults to 500). |
expert_weight |
Weights assigned to each expert (defaults to equal weights). |
A vector containing summary statistics.
get_summary_mult_exp( chips_mult = rbind( c(0, 0, 0, 0, 2, 3, 3, 2, 0, 0), c(0, 0, 0, 1, 2, 4, 2, 1, 0, 0), c(0, 0, 0, 2, 2, 2, 2, 2, 0, 0) ), n = 50 )
get_summary_mult_exp( chips_mult = rbind( c(0, 0, 0, 0, 2, 3, 3, 2, 0, 0), c(0, 0, 0, 1, 2, 4, 2, 1, 0, 0), c(0, 0, 0, 2, 2, 2, 2, 2, 0, 0) ), n = 50 )
Identifies the weights closest to tipping points for specified quantiles.
get_tipping_points(tipmap_data, quantile, null_effect = 0)
get_tipping_points(tipmap_data, quantile, null_effect = 0)
tipmap_data |
A data frame created by |
quantile |
The quantile(s) of the tipping point. Possible values are 0.025, 0.05, 0.1, 0.2, 0.8, 0.9, 0.95 and 0.975. |
null_effect |
The null treatment effect. Defaults to 0. |
The weight closest to the tipping point for the specified quantile
[create_tipmap_data()].
tip_dat <- load_tipmap_data("tipdat.rds")#' get_tipping_points(tip_dat, quantile = 0.025) get_tipping_points(tip_dat, quantile = c(0.025, 0.05, 0.1, 0.2), null_effect = 0.1)
tip_dat <- load_tipmap_data("tipdat.rds")#' get_tipping_points(tip_dat, quantile = 0.025) get_tipping_points(tip_dat, quantile = c(0.025, 0.05, 0.1, 0.2), null_effect = 0.1)
Loads one of three exemplary datasets in the package.
load_tipmap_data(file)
load_tipmap_data(file)
file |
The dataset to be loaded. |
A pre-saved dataset.
load_tipmap_data(file = "tipdat.rds") load_tipmap_data(file = "tipmapPrior.rds") load_tipmap_data(file = "tipPost.rds")
load_tipmap_data(file = "tipdat.rds") load_tipmap_data(file = "tipmapPrior.rds") load_tipmap_data(file = "tipPost.rds")
Assessment of absolute bias in posterior means and medians for a given weight and evidence level, using simulated data as input.
oc_bias( m, se, true_effect, weights = seq(0, 1, by = 0.01), map_prior, sigma, n_cores = 1, eval_strategy = "sequential" )
oc_bias( m, se, true_effect, weights = seq(0, 1, by = 0.01), map_prior, sigma, n_cores = 1, eval_strategy = "sequential" )
m |
Numerical vector of simulated effect estimates. |
se |
Numerical vector of simulated standard errors ( |
true_effect |
Numerical value, representing the true treatment effect (usually the mean of the simulated |
weights |
Vector of weights of the informative component of the MAP prior (defaults to |
map_prior |
A MAP prior containing information about the trials in the source population, created using |
sigma |
Standard deviation of the weakly informative component of the MAP prior, recommended to be the unit-information standard deviation. |
n_cores |
Integer value, representing the number of cores to be used (defaults to 1); only applies if |
eval_strategy |
Character variable, representing the evaluation strategy, either "sequential", "multisession", or "multicore" (see documentation of |
A 2-dimensional array containing results on bias.
[oc_pos()] and [oc_coverage()].
set.seed(123) n_sims <- 5 # small number for exemplary application sim_dat <- list( "m" = rnorm(n = n_sims, mean = 1.15, sd = 0.1), "se" = rnorm(n = n_sims, mean = 1.8, sd = 0.3) ) results <- oc_bias( m = sim_dat[["m"]], se = sim_dat[["se"]], true_effect = 1.15, weights = seq(0, 1, by = 0.01), map_prior = load_tipmap_data("tipmapPrior.rds"), sigma = 16.23, eval_strategy = "sequential", n_cores = 1 ) print(results)
set.seed(123) n_sims <- 5 # small number for exemplary application sim_dat <- list( "m" = rnorm(n = n_sims, mean = 1.15, sd = 0.1), "se" = rnorm(n = n_sims, mean = 1.8, sd = 0.3) ) results <- oc_bias( m = sim_dat[["m"]], se = sim_dat[["se"]], true_effect = 1.15, weights = seq(0, 1, by = 0.01), map_prior = load_tipmap_data("tipmapPrior.rds"), sigma = 16.23, eval_strategy = "sequential", n_cores = 1 ) print(results)
Assessment of coverage of posterior intervals for a given weight and evidence level, using simulated data as input.
oc_coverage( m, se, true_effect, weights = seq(0, 1, by = 0.01), map_prior, sigma, n_cores = 1, eval_strategy = "sequential" )
oc_coverage( m, se, true_effect, weights = seq(0, 1, by = 0.01), map_prior, sigma, n_cores = 1, eval_strategy = "sequential" )
m |
Numerical vector of simulated effect estimates. |
se |
Numerical vector of simulated standard errors ( |
true_effect |
Numerical value, representing the true treatment effect (usually the mean of the simulated |
weights |
Vector of weights of the informative component of the MAP prior (defaults to |
map_prior |
A MAP prior containing information about the trials in the source population, created using |
sigma |
Standard deviation of the weakly informative component of the MAP prior, recommended to be the unit-information standard deviation. |
n_cores |
Integer value, representing the number of cores to be used (defaults to 1); only applies if |
eval_strategy |
Character variable, representing the evaluation strategy, either "sequential", "multisession", or "multicore" (see documentation of |
A 2-dimensional array containing results on coverage.
[oc_pos()] and [oc_bias()].
set.seed(123) n_sims <- 5 # small number for exemplary application sim_dat <- list( "m" = rnorm(n = n_sims, mean = 1.15, sd = 0.1), "se" = rnorm(n = n_sims, mean = 1.8, sd = 0.3) ) results <- oc_coverage( m = sim_dat[["m"]], se = sim_dat[["se"]], true_effect = 1.15, weights = seq(0, 1, by = 0.01), map_prior = load_tipmap_data("tipmapPrior.rds"), sigma = 16.23 ) print(results)
set.seed(123) n_sims <- 5 # small number for exemplary application sim_dat <- list( "m" = rnorm(n = n_sims, mean = 1.15, sd = 0.1), "se" = rnorm(n = n_sims, mean = 1.8, sd = 0.3) ) results <- oc_coverage( m = sim_dat[["m"]], se = sim_dat[["se"]], true_effect = 1.15, weights = seq(0, 1, by = 0.01), map_prior = load_tipmap_data("tipmapPrior.rds"), sigma = 16.23 ) print(results)
Assessment of the probability of truly or falsely (depending on simulated scenario) rejecting the null hypothesis of interest for a given weight and evidence level, using simulated data as input.
oc_pos( m, se, probs, weights = seq(0, 1, by = 0.01), map_prior, sigma, null_effect = 0, direction_pos = T, n_cores = 1, eval_strategy = "sequential" )
oc_pos( m, se, probs, weights = seq(0, 1, by = 0.01), map_prior, sigma, null_effect = 0, direction_pos = T, n_cores = 1, eval_strategy = "sequential" )
m |
Numerical vector of simulated effect estimates. |
se |
Numerical vector of simulated standard errors ( |
probs |
Vector of quantiles q, with 1 minus q representing an evidence level of interest (where positive effect estimate indicate a beneficial treatment). |
weights |
Vector of weights of the informative component of the MAP prior (defaults to |
map_prior |
A MAP prior containing information about the trials in the source population, created using |
sigma |
Standard deviation of the weakly informative component of the MAP prior, recommended to be the unit-information standard deviation. |
null_effect |
Numerical value, representing the null effect (defaults to 0). |
direction_pos |
Logical value, |
n_cores |
Integer value, representing the number of cores to be used (defaults to 1); only applies if |
eval_strategy |
Character variable, representing the evaluation strategy, either "sequential", "multisession", or "multicore" (see documentation of |
A 2-dimensional array containing probabilities, either of truly (probability of success) or falsely rejecting the null hypothesis of interest for a given weight and evidence level.
[oc_bias()] and [oc_coverage()].
set.seed(123) n_sims <- 5 # small number for exemplary application sim_dat <- list( "m" = rnorm(n = n_sims, mean = 1.15, sd = 0.1), "se" = rnorm(n = n_sims, mean = 1.8, sd = 0.3) ) results <- oc_pos( m = sim_dat[["m"]], se = sim_dat[["se"]], probs = c(0.025, 0.05, 0.1, 0.2), weights = seq(0, 1, by = 0.01), map_prior = load_tipmap_data("tipmapPrior.rds"), sigma = 16.23, null_effect = 0, direction_pos = TRUE, eval_strategy = "sequential", n_cores = 1 ) print(results)
set.seed(123) n_sims <- 5 # small number for exemplary application sim_dat <- list( "m" = rnorm(n = n_sims, mean = 1.15, sd = 0.1), "se" = rnorm(n = n_sims, mean = 1.8, sd = 0.3) ) results <- oc_pos( m = sim_dat[["m"]], se = sim_dat[["se"]], probs = c(0.025, 0.05, 0.1, 0.2), weights = seq(0, 1, by = 0.01), map_prior = load_tipmap_data("tipmapPrior.rds"), sigma = 16.23, null_effect = 0, direction_pos = TRUE, eval_strategy = "sequential", n_cores = 1 ) print(results)
Custom dark blue
tipmap_darkblue
tipmap_darkblue
An object of class character
of length 1.
Custom light red
tipmap_lightred
tipmap_lightred
An object of class character
of length 1.
Uses a data frame created by create_tipmap_data()
to visualize the tipping point analysis.
tipmap_plot( tipmap_data, target_pop_lab = "Trial in target\n population", y_range = NULL, y_breaks = NULL, title = NULL, y_lab = "Mean difference", x_lab = "Weight on informative component of robust MAP prior", map_prior_lab = "MAP\nprior", meta_analysis_lab = "MA", legend_title = "Posterior quantile", null_effect = 0 )
tipmap_plot( tipmap_data, target_pop_lab = "Trial in target\n population", y_range = NULL, y_breaks = NULL, title = NULL, y_lab = "Mean difference", x_lab = "Weight on informative component of robust MAP prior", map_prior_lab = "MAP\nprior", meta_analysis_lab = "MA", legend_title = "Posterior quantile", null_effect = 0 )
tipmap_data |
A data frame containing tipping point data, generated by [create_tipmap_data()]. |
target_pop_lab |
A label for the trial in the target population. |
y_range |
An optional argument specifying range of the y-axis. |
y_breaks |
An optional vector specifying breaks on the y-axis. |
title |
The plot title. |
y_lab |
The label for the y axis. Defaults to "Mean difference". |
x_lab |
The label for the x axis. Defaults to "Weight on informative component of MAP prior". |
map_prior_lab |
The label for the MAP prior. Defaults to "MAP prior" |
meta_analysis_lab |
An optional label for a meta-analysis (if included). |
legend_title |
An optional title for the plot legend. Defaults to "Posterior quantiles". |
null_effect |
The null treatment effect, determining where tipping points are calculated. Defaults to 0. |
A ggplot
object of the tipping point plot
[create_tipmap_data()].
tipmap_data <- load_tipmap_data("tipdat.rds") tipmap_plot(tipmap_data)
tipmap_data <- load_tipmap_data("tipdat.rds") tipmap_plot(tipmap_data)