Skip to contents

Computes \(\Pr(\lambda_t / \lambda_c \le q)\) (or the upper tail \(\Pr(\lambda_t / \lambda_c > q)\)) for hazards with independent Gamma distributions, \(\lambda_t \sim \textrm{Gamma}(a_t, b_t)\) and \(\lambda_c \sim \textrm{Gamma}(a_c, b_c)\) (shape and rate). This is the posterior probability used for a time-to-event endpoint evaluated by the hazard ratio with a concurrent, external or hypothetical control.

Usage

phazardratio(q, shape_t, rate_t, shape_c, rate_c, lower.tail = TRUE)

Arguments

q

Numeric vector of quantiles (hazard ratios).

shape_t, rate_t

Positive shape and rate of the treatment hazard.

shape_c, rate_c

Positive shape and rate of the control hazard.

lower.tail

Logical; if TRUE (default), probabilities are \(\Pr(\lambda_t / \lambda_c \le q)\), otherwise \(\Pr(\lambda_t / \lambda_c > q)\).

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

Because \(2 b_k \lambda_k\) has the chi-squared distribution with \(2 a_k\) degrees of freedom, \((b_t \lambda_t / a_t) / (b_c \lambda_c / a_c)\) has the F distribution with \(2 a_t\) and \(2 a_c\) degrees of freedom, and $$\Pr(\lambda_t / \lambda_c \le q) = F_{2 a_t, 2 a_c}\left(\frac{q \, a_c \, b_t}{a_t \, b_c}\right),$$ which is computed exactly by pf.

Examples

# Posterior probability that the hazard ratio is below 0.7 with 20 events
# in 300 months of follow-up versus 30 events in 250 months (Gamma(0.1, 1)
# priors)
phazardratio(0.7, shape_t = 20.1, rate_t = 301, shape_c = 30.1,
             rate_c = 251)
#> [1] 0.7923543