estim: Calculate the Posterior Mean and Mean Squared Error for a...

View source: R/estim.R

estimR Documentation

Calculate the Posterior Mean and Mean Squared Error for a Basket Trial Design

Description

Generic function for calculating the posterior mean and mean squared error of a basket trial design. It defaults to the function estim.default which does not rely on any baskwrap-specific function.

Usage

estim(design, ...)

## Default S3 method:
estim(design, ...)

## S3 method for class 'fujikawa_x'
estim(
  design,
  n,
  p1,
  lambda = NULL,
  epsilon,
  tau,
  logbase = 2,
  iter = 1000,
  weight_fun = weights_jsd,
  weight_params = list(epsilon = epsilon, tau = tau, logbase = logbase),
  globalweight_fun = NULL,
  globalweight_params = list(),
  ...
)

Arguments

design

An object created with one of the setup_ functions from the basksim package or the baskwrap package.

...

Further arguments.

n

The sample size per basket.

p1

Probabilities under the alternative hypothesis. If length(p1) == 1, then this is a common probability for all baskets.

lambda

The posterior probability threshold.

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.

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.

Details

estim.default is in fact just a wrapper of basksim::get_details() that select posterior mean and mean squared error.

Value

A list containing means of the posterior distribution and the mean squared errors for all baskets.

Examples

# Example for a basket trial with Fujikawa's Design
design <- setup_fujikawa_x(k = 3, p0 = 0.2)
estim(design = design, n = 20, p1 = c(0.2, 0.5, 0.5), lambda = 0.95,
     epsilon = 2, tau = 0, iter = 100)

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