Base class for the binomial models whose posterior is available in closed form.
Both the separate-analysis and the pooled-analysis models place a uniform
prior on the control rate and, conditionally on it, a uniform prior on the
treatment effect over (-control_rate, 1 - control_rate). That interval has
width 1 whatever the control rate, so the joint prior density is constant and
the pair (control_rate, treatment_rate) is uniform on the unit square, i.e.
independent Beta(1, 1) priors on the two arm response rates. The binomial
likelihood factorises over arms, so the posterior is a product of two
independent Beta distributions:
$$p_c \mid D \sim Beta(s_c + 1, n_c - s_c + 1), \quad p_t \mid D \sim Beta(s_t + 1, n_t - s_t + 1)$$
and the treatment effect is their difference. Moments are available
analytically; the distribution function of the difference is obtained by
one-dimensional quadrature over the control rate - see
beta_difference_expectation() - and inverted numerically for quantiles, so
no Monte Carlo error enters the operating characteristics.
Super class
Model -> BinomialConjugate
Public fields
control_shape1First shape parameter of the control rate posterior.
control_shape2Second shape parameter of the control rate posterior.
treatment_shape1First shape parameter of the treatment rate posterior.
treatment_shape2Second shape parameter of the treatment rate posterior.
n_quadrature_nodesGauss-Legendre nodes per smooth piece of the integral over the control rate.
interval_memoCredible intervals of the current posterior, by level.
Methods
Inherited methods
Model$calibrate_for_design()Model$check_data()Model$create()Model$empirical_bayes_update()Model$estimate_bayesian_operating_characteristics()Model$estimate_frequentist_operating_characteristics()Model$hypothesis_space_transformation()Model$inference()Model$inference_cache_scope()Model$plot_pdfs()Model$plot_posterior_pdf()Model$plot_prior_pdf()Model$posterior_beta_mixture()Model$posterior_mean()Model$posterior_to_RBesT()Model$print_model_summary()Model$prior_elir_ess()Model$prior_to_RBesT()Model$simulation_for_given_treatment_effect()Model$test_decision()Model$vectorised_replicate_inference()
BinomialConjugate$new()
Initialize the BinomialConjugate object
Usage
BinomialConjugate$new(prior, mcmc_config = NULL)BinomialConjugate$summary_rows()
Rows of the model summary, with the shape parameters of the Beta posteriors on the two response rates
BinomialConjugate$prepare_data()
Assemble the event counts the posterior conditions on. Subclasses must implement the 'prepare_data' method.
BinomialConjugate$posterior_ess()
Effective sample sizes of the current posterior
The posterior variance is available in closed form and the credible interval comes from the same quadrature the rest of the class uses, so both effective sample sizes are evaluated directly. The inherited route would instead fit a mixture to a finite sample drawn from the posterior, which costs a mixture fit per replicate and leaves Monte Carlo error in a quantity that has no need of it.
BinomialConjugate$prior_given_control_rate()
The prior of the treatment effect given the target control rate
The marginal prior averages over a uniform control rate and spans
(-1, 1); a trial whose control rate is known can only have an effect in
(-control_rate, 1 - control_rate), and given the control rate the
effect is uniform there.