This class implements the Test-Then-Pool framework for Bayesian borrowing in clinical trials.
Details
The TestThenPool class provides methods for testing and inference with the Test-then-Pool method.
Super class
Model -> TestThenPool
Public fields
poolingPooling model
separateSeparate model
poolPooling indicator
inference_methodInference method
summary_measure_likelihoodSummary measure distribution
source_treatment_effect_estimateSource treatment effect estimate
source_standard_errorSource standard error
methodMethod name
empirical_bayesIndicator that the method uses empirical Bayes
Methods
Inherited methods
Model$calibrate_for_design()Model$check_data()Model$create()Model$estimate_bayesian_operating_characteristics()Model$estimate_frequentist_operating_characteristics()Model$hypothesis_space_transformation()Model$inference_cache_scope()Model$plot_pdfs()Model$plot_posterior_pdf()Model$plot_prior_pdf()Model$posterior_beta_mixture()Model$posterior_mean()Model$posterior_moments()Model$posterior_quantile()Model$print_model_summary()Model$simulation_for_given_treatment_effect()Model$summary_rows()
TestThenPool$new()
Initializes a TestThenPool object.
Usage
TestThenPool$new(prior, mcmc_config = NULL)TestThenPool$vectorised_test_pvalue()
p-value of the test, for every replicate at once
Subclasses override this with the vectorised form of test_pvalue().
Returning NULL means "no fast path" and keeps the replicate loop.
TestThenPool$vectorised_pool()
Whether to pool, for every replicate at once
Subclasses override this to turn vectorised_test_pvalue() into a
pooling decision, since the two variants read the test in opposite
directions.
TestThenPool$vectorised_replicate_inference()
Run every replicate at once
The test picks a prior per replicate, and both branches are conjugate Gaussian models with the same prior mean, so the whole simulation is a single normal-prior update with a per-replicate variance.
Usage
TestThenPool$vectorised_replicate_inference(
target_data,
samples,
to_return,
critical_value,
theta_0,
confidence_level,
null_space
)Arguments
target_dataTarget study data.
samplesData frame of generated replicates.
to_returnCharacter vector of requested outputs.
critical_valueCritical value for hypothesis testing.
theta_0Null hypothesis value.
confidence_levelConfidence level for the credible interval.
null_spaceThe null space for hypothesis testing.
TestThenPool$empirical_bayes_update()
Performs the empirical Bayes update with the Test-then-Pool method.
TestThenPool$posterior_pdf()
Calculates the posterior probability density function with the Test-then-Pool method.
TestThenPool$prior_pdf()
Calculates the prior probability density function with the Test-then-Pool method.
TestThenPool$posterior_cdf()
Calculates the posterior cumulative distribution function with the Test-then-Pool method.
TestThenPool$sample_posterior()
Samples from the posterior distribution with the Test-then-Pool method.
TestThenPool$posterior_ess()
Effective sample sizes of the current posterior
The posterior is the one of the component the test selected, so the effective sample sizes are that component's. Delegating rather than inheriting also keeps whichever fast route the component has: the binomial branch holds two conjugate models, which report both quantities in closed form.
TestThenPool$prior_elir_ess()
ELIR effective sample size of the current prior
The prior is whichever component the test selected, and neither component's prior depends on the data, so each component reports its own, fitted once. The inherited route treats the method as empirical Bayes and refits a mixture to fresh prior draws for every replicate, although only two priors can ever come out of the test. On a binomial endpoint that refit was nine tenths of the method's run time.
TestThenPool$test_decision()
Return the test decision based on the posterior distribution. The decision rule is: \(P(\theta_T > \theta_0 \mid \mathbf{D}_S, \mathbf{D}_T) > ) \eta\) (if null_space is right).
TestThenPool$plot_test_vs_drift()
Plot the pooling test decision as a function of drift in treatment effect
Usage
TestThenPool$plot_test_vs_drift(
source_treatment_effect_estimate,
target_data,
min_drift,
max_drift,
resolution
)TestThenPool$plot_test_pvalue_vs_drift()
Plot the pooling test p-value as a function of drift in treatment effect
Usage
TestThenPool$plot_test_pvalue_vs_drift(
source_treatment_effect_estimate,
target_data,
min_drift,
max_drift,
resolution
)