get_details.fujikawa_x: Get Details of a Basket Trial Simulation with Fujikawa's...

View source: R/get_details.R

get_details.fujikawa_xR Documentation

Get Details of a Basket Trial Simulation with Fujikawa's Design

Description

This wrapper functions returns details for basket trial design.

Usage

## S3 method for class 'fujikawa_x'
get_details(
  design,
  ...,
  n,
  p1 = NULL,
  lambda,
  level = 0.95,
  epsilon,
  tau,
  logbase = 2,
  iter = 1000,
  data = NULL,
  weight_fun = weights_jsd,
  weight_params = list(epsilon = epsilon, tau = tau, logbase = logbase),
  globalweight_fun = NULL,
  globalweight_params = list(),
  which_details = "all",
  verbose = TRUE
)

Arguments

design

An object of class fujikawa_x.

...

Further arguments.

n

The sample size per basket.

p1

Probabilities used for the simulation. If NULL then all probabilities are set to p0.

lambda

The posterior probability threshold.

level

Level of the credibility intervals.

epsilon

Tuning parameter that determines the amount of borrowing. See setup_fujikawa).

tau

Tuning parameter that determines how similar the baskets have to be that information is shared. See setup_fujikawa).

logbase

Tuning parameter. The base of the logarithm that is used to calculate the Jensen-Shannon divergence.

iter

The number of iterations in the simulation. Is ignored if data is specified.

data

A data matrix with k column with the number of responses for each basket. Has to be generated with get_data. If data is used, then iter is ignored.

weight_fun

Which functions should be used to calculated the pairwise weights? Default is weights_jsd.

weight_params

A list of tuning parameters specific to weight_fun. By default, it takes the function arguments epsilon, tau and logbase.

globalweight_fun

Which functions should be used to calculated the global weights? Currently, this is only supported for the exact backend.

globalweight_params

A list of tuning parameters specific to globalweight_fun.

which_details

A character vector specifying which details should be calculated. This is used only for backend = "exact", where the number of details is relevant for runtime. Default is "all", see details for explanation.

verbose

A logical, should message be shown if EWP or FWER is 0. Default is TRUE.

Details

It calculates the details using backends from two different R packages:

  • If design$backend == "sim", the details are calculated using basksim::get_details.fujikawa.

  • If design$backend == "exact", the details are calculated using baskexact::toer, baskexact::pow and baskexact::estim. Note that the standard weight function weights_jsd calculates the weights anew for each of the three function calls. This may compromise performance and can be fixed by manually calculating the weights beforehand.

For the baskexact backend, the number of details is a relevant factor for the function's runtime. Hence, one can select precisely which details should be calculated:

  • If which_details == "all", everything will be calculated.

  • If "FWER" %in% which_details, then FWER will be calculated.

  • If "EWP" %in% which_details, then EWP will be calculated.

  • If "Rejection_Probabilities" %in% which_details, then per-basket rejection probabilities will be calculated.

  • If "ECD" %in% which_details, then ECD will be calculated.

  • If "Mean" %in% which_details, then mean response rate and its MSE will be calculated. The mean is the expected posterior mean conditional under the assumption that p1 is true, and the MSE is the expected squared deviation of the posterior mean from this true value.

Value

A list containing the rejection probabilites, posterior means, mean squared errors and mean limits of HDI intervals for all baskets as well as the family-wise error rate and the experiment-wise power.

Examples

design <- setup_fujikawa_x(k = 3, p0 = 0.2)
get_details(design = design, n = 20, p1 = c(0.2, 0.5, 0.5), lambda = 0.95,
            epsilon = 2, tau = 0, iter = 100)
design_x <- setup_fujikawa_x(k = 3, p0 = 0.2, backend = "exact")
get_details(design = design_x, n = 20, p1 = c(0.2, 0.5, 0.5), lambda = 0.95,
            epsilon = 2, tau = 0, weight_fun = baskexact::weights_fujikawa,
            logbase = exp(1))
# If you call get_details() with backend = "exact" multiple without
# changing design and n, it can make sense to save the weights and supply
# them separately using a custom function. This can save run time.
weight_mat_vanilla <- weights_jsd_vanilla(design_x, n = 20,
                                               logbase = exp(1))
weights_from_save <- function(epsilon,
                              tau,
                              ...) {
  return(weights_fujikawa_tuned(weight_mat_vanilla,
                                epsilon = epsilon,
                                tau = tau))
}
get_details(design = design_x,
            n = 20,
            p1 = c(0.2, 0.5, 0.5),
            lambda = 0.95,
            epsilon = 2, tau = 0,
            weight_fun = weights_from_save,
            logbase = NULL)

baskwrap documentation built on March 19, 2026, 5:09 p.m.