Computes \(\Pr(\pi_t - \pi_c \le q)\) (or the upper tail \(\Pr(\pi_t - \pi_c > q)\)) for independent \(\pi_t \sim \textrm{Beta}(a_t, b_t)\) and \(\pi_c \sim \textrm{Beta}(a_c, b_c)\). This is the posterior probability used for a single binary endpoint.
Value
A numeric vector of probabilities. All arguments except
lower.tail are recycled to a common length; each must have length
1 or the common length.
Details
The upper tail is computed as
$$\Pr(\pi_t - \pi_c > q) = \Pr(\pi_c < -q) +
\int f_c(x) \Pr(\pi_t > x + q) \, dx,$$
where the integral runs over the values of \(x\) with
\(0 \le x + q \le 1\), and the first term is zero for
\(q \ge 0\). The integral is evaluated by adaptive Gauss-Kronrod
quadrature (the QUADPACK routine used by integrate),
with the range split at quantiles of both Beta distributions so that
concentrated distributions are integrated accurately. When the density of
\(\pi_c\) is unbounded at 0 (\(a_c < 1\)) or at 1 (\(b_c < 1\)), the
integral on that side of the median of \(\pi_c\) is evaluated in the
variable \(s = x^{a_c}\) or \(s = (1 - x)^{b_c}\), in which the
integrand is bounded. The lower tail is
computed directly from the same formula with the roles of the two groups
exchanged, so both tails are accurate near 0.
See also
Other distributions:
cellprob_binary2(),
pbetabinomdiff(),
phazardratio(),
psurvdiff(),
ptdiff(),
rdirichlet()
