From Trial Records to Posterior Comparisons
A survival analysis can look abstract when it begins with likelihoods and distributions. In a trial, however, the information entering the model is concrete: for each participant, the observed follow-up time and whether an event occurred or follow-up ended first. This tutorial works through how those records produce posterior inferences about each arm’s hazard, survival at a specified time, and the hazard ratio.
The model is deliberately simple: within each arm, event times have a constant hazard. This makes the calculations transparent, but also makes the assumption consequential. The results describe a hypothetical trial; they are not evidence about any actual treatment.
Model, Data, and Assumptions
The right-censored likelihood contribution from an event is the event-time density, \(\lambda_j\exp(-\lambda_jY_{ij})\). A censored observation contributes the probability of surviving through its observed time, \(\exp(-\lambda_jY_{ij})\). Multiplying the contributions gives a likelihood proportional to \(\lambda_j^{D_j}\exp(-\lambda_jE_j)\). Thus the data enter through two summaries: event count and total exposure.
The calculation requires several substantive assumptions. Event times within an arm follow a constant hazard over the modeled period; participants’ event processes are conditionally independent given the arm hazard; and censoring is noninformative for the event time, so censoring does not selectively hide events in a way left unaccounted for by the model. Follow-up times and event indicators must be recorded correctly. For a causal interpretation of an arm contrast, randomization and the trial’s conduct also matter; a hazard comparison alone does not establish that every modeling assumption is appropriate.
Use independent Gamma priors for the two arm hazards, with the shape-rate convention:
Here \(a_j\) is the shape and \(b_j\) is the rate parameter in the Gamma density. Because \(\lambda_j\) has units of inverse time, \(b_j\) has units of follow-up time, so \(b_j\lambda_j\) is dimensionless. Combining this prior with the likelihood gives:
Worked Example: Summarizing Participant Records
Worked Example: Summarizing Participant Records
Suppose a hypothetical trial records follow-up in months. In the control arm, six participants have observed times and event indicators \((4,1),(7,1),(9,1),(2,0),(3,0),(5,0)\). Each pair is \((Y_{ij},\delta_{ij})\). Calculate the event count and exposure.
The first three participants had events, so \(D_C=1+1+1+0+0+0=3\). Total exposure is \(E_C=4+7+9+2+3+5=30\) participant-months. The censored participants contribute exposure through their recorded follow-up times, even though no event was observed for them.
For the hypothetical treatment arm, take \((8,1),(14,1),(2,0),(3,0),(4,0),(5,0)\). Then \(D_T=2\), and \(E_T=8+14+2+3+4+5=36\) participant-months. These summaries, rather than a count that treats censored participants as event-free indefinitely, are what enter the likelihood.
Posterior Hazards and Fixed-Time Survival
For a complete worked analysis, assign each arm the prior \(\operatorname{Gamma}(1,12\text{ months})\). Its prior mean hazard is \(1/12\) per month. The prior rate of 12 months is a time quantity, consistent with a hazard measured per month. Applying the update to the records above gives:
The posterior mean of a Gamma(shape, rate) variable is shape divided by rate. Therefore the control-arm posterior mean hazard is \(4/42=0.09524\) events per participant-month, and the treatment-arm posterior mean hazard is \(3/48=0.06250\) events per participant-month. These are posterior summaries under the specified model and priors, not observed event rates that account for no uncertainty.
Worked Example: Posterior Survival at 12 Months
Find the posterior mean survival probability at 12 months in each arm. For a fixed hazard, survival is \(S_j(12)=\exp(-12\lambda_j)\). A posterior mean survival probability averages this quantity over the posterior distribution of the hazard.
If \(\lambda\sim\operatorname{Gamma}(a,b)\) with rate \(b\), its Laplace transform gives \(E[\exp(-t\lambda)]=(b/(b+t))^a\). Thus:
Under this model, posterior mean survival through 12 months is about 36.6% in control and 51.2% in treatment. The difference between these posterior means is about 14.6 percentage points. This is a summary of the posterior distributions, not a statement that the treatment caused the difference.
A common shortcut gives a different answer: substituting the posterior mean hazard into the survival function yields \(\exp(-12\times0.09524)\approx0.3189\) for control and \(\exp(-12\times0.06250)\approx0.4724\) for treatment. These are survival probabilities at the posterior mean hazards, not posterior mean survival probabilities. Since the exponential function is nonlinear, the two quantities need not agree.
Uncertainty about fixed-time survival can also be represented by transforming a credible interval for the hazard. Since \(S_j(t)=\exp(-t\lambda_j)\) decreases as \(\lambda_j\) increases, the hazard interval’s endpoints must be reversed when transformed. For example, approximate equal-tail 95% posterior intervals for the hazards are \(0.02595\) to \(0.2087\) per month in control and \(0.01289\) to \(0.1505\) per month in treatment. Transforming the upper hazard endpoint to the lower survival endpoint gives approximate 95% posterior intervals for 12-month survival of \(0.0817\) to \(0.7324\) in control and \(0.1643\) to \(0.8567\) in treatment. These wide intervals show why point summaries alone do not capture the uncertainty.
Comparing the Arms With a Hazard Ratio
Given independent priors and arm-specific data, the two posterior hazards are independent. In the example, the posterior mean hazard ratio can be computed using independence and the Gamma inverse-moment formula. If \(X\sim\operatorname{Gamma}(a,b)\) with \(a>1\), then \(E(1/X)=b/(a-1)\). Hence:
This posterior mean is dimensionless. It is distinct from the ratio of posterior mean hazards, \((3/48)/(4/42)=0.6563\); in general, the mean of a ratio is not the ratio of the means. To describe posterior uncertainty or the probability of a beneficial direction, use the joint posterior distribution rather than treating either point summary as definitive.
Worked Example: Posterior Probability the Treatment Hazard Is Lower
Calculate \(P(\mathrm{HR}<1\mid\text{data})\) for the example. Let \(X=48\lambda_T\) and \(Y=42\lambda_C\). The posterior distributions imply independent \(X\sim\operatorname{Gamma}(3,1)\) and \(Y\sim\operatorname{Gamma}(4,1)\). The event \(\lambda_T/\lambda_C<1\) is equivalent to:
For independent unit-rate Gamma variables, \(U=X/(X+Y)\) has a \(\operatorname{Beta}(3,4)\) distribution. The inequality \(X/Y<8/7\) is equivalent to \(U<8/15\). The Beta(3,4) cumulative distribution function is \(20u^3-45u^4+36u^5-10u^6\), so:
Given this model, prior, and hypothetical data, the posterior probability that the treatment hazard is lower is about 71.7%. This is not the probability that the null hypothesis is true, nor does it alone establish a clinically important benefit. Clinical importance depends on the magnitude and consequences of the effect, not only its direction.
Derivation, Diagnostics, and Alternatives
The conjugate update follows directly from multiplying the likelihood and prior. Suppressing constants that do not depend on \(\lambda_j\), the posterior density is proportional to:
This is the kernel of a Gamma density with shape \(a_j+D_j\) and rate \(b_j+E_j\), which justifies the update. Notice that an event increases the shape, while all observed follow-up—including censored follow-up—increases the rate. Both terms affect the posterior.
Diagnostics begin with the records and the model’s implied event-time behavior. Check that each participant contributes only the observed time up to event or censoring, that event indicators are coded correctly, and that exposure units are consistent with the prior rate and target time. The constant-hazard assumption implies an exponential survival curve; substantial time variation in the observed hazard is a warning that this model may be too restrictive. Informative censoring, such as loss to follow-up related to unobserved prognosis, can also undermine the analysis. A Gamma prior with little data may materially influence the result, so prior sensitivity is important.
The exponential model is concise and conjugate, but it is not the only approach. Kaplan–Meier estimation is a nonparametric frequentist alternative for describing survival under right censoring, while Weibull or piecewise-exponential models allow hazards to vary over time. Those alternatives answer related questions with different assumptions and inferential frameworks. The present calculation’s advantage is a direct posterior distribution for hazards and their functions; its limitation is that apparent precision cannot compensate for a misspecified constant hazard, problematic censoring, or a poorly chosen prior.
Check Your Understanding
Answer each question, then compare with the brief solutions below.
- In an arm with observed times 2, 5, and 7 months and event indicators 0, 1, and 1, what are \(D\) and \(E\)?
- With a \(\operatorname{Gamma}(2,10\text{ months})\) prior, 4 events, and 30 participant-months of exposure, what is the posterior hazard distribution?
- For a posterior hazard \(\operatorname{Gamma}(3,24\text{ months})\), calculate the posterior mean survival at 12 months.
- Why must the endpoints of a hazard credible interval be reversed when converted to a survival interval?
- Does a posterior probability of 0.95 that \(\mathrm{HR}<1\) mean there is a 95% probability the null hypothesis is true? Explain.
Solutions. (1) \(D=0+1+1=2\), and \(E=2+5+7=14\) participant-months. (2) The posterior is \(\operatorname{Gamma}(2+4,10+30)=\operatorname{Gamma}(6,40\text{ months})\). (3) \(E[S(12)\mid\text{data}]=(24/(24+12))^3=(2/3)^3\approx0.2963\). (4) Survival \(\exp(-12\lambda)\) decreases with \(\lambda\), so the largest hazard maps to the smallest survival. (5) No. It is a posterior probability of a directional parameter statement under the specified model and prior; it is not a probability assigned to the null hypothesis.