Tutorials › Joint Modeling of Longitudinal and Time-to-Event Data › Sampling Baseline Hazard Parameters

Bayesian Joint Models · Tutorial 304 of 697

Sampling Baseline Hazard Parameters

Learn to construct and sample baseline hazard parameter posteriors, including conjugate Gamma updates and nonconjugate parametric targets.

Advanced 12 min read

What You'll Learn

  • Write the conditional survival likelihood for baseline hazard parameters given the other joint-model quantities.
  • Distinguish the event contribution from the exposure contribution shared by events and right-censored observations.
  • Derive Gamma posterior updates for a constant baseline hazard and for piecewise-constant hazards.
  • Identify conjugate scale updates in a parametric hazard model and construct a nonconjugate target when needed.
  • Check exposure calculations, units, assumptions, and common implementation errors.

Why Baseline Hazard Updates Need the Whole Follow-Up

In a shared random-effects joint model, the survival likelihood depends on the baseline hazard as well as on each subject’s current risk, which is determined by covariates and latent effects. Updating baseline hazard parameters therefore requires accounting for both the hazard at observed event times and the cumulative hazard over each subject’s follow-up. The latter contribution applies to censored subjects too.

Here the baseline hazard is \(h_0(t;\theta)\), with cumulative baseline hazard \(H_0(t;\theta)=\int_0^t h_0(u;\theta)\,du\). Let \(Y_i=\min(T_i,C_i)\) be subject \(i\)’s observed follow-up time and let \(\delta_i=1\) if the event is observed, and \(0\) if the observation is right-censored. Conditional on the current random effects and other model parameters, write the subject-specific hazard as \(h_i(t)=h_0(t;\theta)r_i(t)\), where \(r_i(t)>0\) is the subject-specific risk multiplier. For example, it may be the exponential of a linear predictor involving covariates and the subject’s latent longitudinal trajectory.

Definition: A conditional baseline-hazard update is the posterior distribution of \(\theta\) given the observed survival data and the current values of the other joint-model quantities. Under conditionally independent subjects and an ignorable right-censoring mechanism, its kernel is the prior density \(p(\theta)\) multiplied by the survival likelihood $$ p(\theta\mid\text{rest},\mathcal D)\ \propto\ p(\theta)\prod_i \left\{h_0(Y_i;\theta)r_i(Y_i)\right\}^{\delta_i} \exp\left\{-\int_0^{Y_i}h_0(u;\theta)r_i(u)\,du\right\}. $$ The integral term is present whether \(\delta_i=1\) or \(\delta_i=0\); only the event-hazard factor is omitted for a censored observation.

This is a conditional posterior, not a posterior that treats the latent effects or association parameters as known forever. In an MCMC algorithm they have current sampled values during this update and are updated in other steps. The longitudinal likelihood need not be repeated in the baseline-hazard update if it contains no baseline-hazard parameter: it is constant with respect to \(\theta\) conditional on the rest.

How Events and Censoring Enter

For an observed event, the likelihood includes the hazard at the event time as well as survival up to that time. A censored subject contributes survival up to the censoring time, but no event-hazard factor there. This distinction follows directly from the right-censored likelihood: the observed-data contribution is a density for an event and a survival probability for a censored time.

The censoring mechanism is assumed independent of the event process conditional on the modeled information, so its distribution can be omitted from this parameter update. If censoring is informative even after conditioning on that information, this likelihood is not adequate without modeling the censoring process. In all the calculations below, exposure means the integrated risk multiplier over the observed time, not simply the number of subjects at risk.

Worked Example: Exponential Baseline With Right Censoring

Suppose the baseline hazard is constant, \(h_0(t;\lambda)=\lambda\), and the risk multipliers are all 1. Follow-up times are 2 and 3 time units for two observed events, and 4 time units for one censored subject. Assume independent censoring conditional on the model, and place a Gamma prior on \(\lambda\) with shape \(a=2\) and rate \(b=1\). The Gamma density is proportional to \(\lambda^{a-1}\exp(-b\lambda)\); under this rate convention its mean is \(a/b\).

The event count is \(D=\sum_i\delta_i=2\). Total exposure is the sum of all observed follow-up times, including the censored subject: \(E=2+3+4=9\) time units. Thus the likelihood as a function of \(\lambda\), omitting factors that do not involve \(\lambda\), is \(\lambda^2\exp(-9\lambda)\). Combining this with the prior gives

$$ p(\lambda\mid\text{rest},\mathcal D) \propto \lambda^{2-1}e^{-1\lambda}\lambda^2e^{-9\lambda} =\lambda^{3}e^{-10\lambda}. $$

Therefore \(\lambda\mid\text{rest},\mathcal D\sim\operatorname{Gamma}(4,10)\), using shape-rate order. Its conditional posterior mean is \(4/10=0.4000\) per time unit. The censored subject adds four time units to exposure and no event to the count; omitting its exposure would incorrectly give rate parameter \(1+2+3=6\).

Conjugate Updates for Constant and Piecewise Hazards

The constant-hazard calculation is a special case of a useful conjugate pattern. If the baseline hazard is constant within a time interval, its likelihood contains a power of that interval’s hazard parameter, from events in the interval, and an exponential penalty involving accumulated exposure in the interval. A Gamma prior then yields a Gamma conditional posterior.

For a piecewise-constant baseline, partition follow-up time into intervals \((a_{k-1},a_k]\), and let the baseline hazard on interval \(k\) be \(\lambda_k\). Define \(d_k\) as the number of observed events in that interval and define its total risk-weighted exposure as \(A_k=\sum_i\int_{(a_{k-1},a_k]\cap[0,Y_i]}r_i(u)\,du\). The integral stops at each subject’s observed follow-up time. With independent priors \(\lambda_k\sim\operatorname{Gamma}(a_k^*,b_k^*)\), the conditional posterior for each interval is \(\operatorname{Gamma}(a_k^*+d_k,b_k^*+A_k)\). Here \(a_k^*,b_k^*\) are prior shape and rate parameters; they are distinct from the interval boundary notation \(a_k\).

Result: For each piecewise-constant interval, the event count increments the Gamma shape and the integrated risk-weighted exposure increments the Gamma rate. The update follows because the interval-specific likelihood kernel is \(\lambda_k^{d_k}\exp(-A_k\lambda_k)\). Censoring contributes to \(A_k\) up to the censoring time, even though it does not increment \(d_k\).

This update remains conjugate when \(r_i(u)\) varies over time: its integral contributes a quantity that is fixed with respect to \(\lambda_k\) in this conditional update. The risk multiplier must be evaluated using the current values of the other parameters. If the model instead imposes a prior linking the \(\lambda_k\)’s, the conditional distribution for a single interval generally no longer has this independent Gamma form.

Worked Example: Two Piecewise-Constant Intervals

Let the intervals be \((0,2]\) and \((2,5]\), with risk multiplier 1 for every subject. Three subjects have these hypothetical records: an event at time 1, an event at time 4, and censoring at time 3. Use independent \(\operatorname{Gamma}(1,0.5)\) priors on the two interval hazards, with rate parameter 0.5 per time unit.

In the first interval, the event at time 1 contributes 1 time unit of exposure, while the other two subjects each contribute 2. Thus \(A_1=1+2+2=5\), and \(d_1=1\). In the second interval, the subject with an event at 4 contributes 2 time units and the subject censored at 3 contributes 1; the subject who had an event at 1 contributes none. Thus \(A_2=2+1=3\), and \(d_2=1\).

Applying the shape-rate updates gives \(\lambda_1\mid\text{rest},\mathcal D\sim\operatorname{Gamma}(1+1,0.5+5)=\operatorname{Gamma}(2,5.5)\) and \(\lambda_2\mid\text{rest},\mathcal D\sim\operatorname{Gamma}(1+1,0.5+3)=\operatorname{Gamma}(2,3.5)\). The conditional posterior means are \(2/5.5=0.3636\) and \(2/3.5=0.5714\) per time unit, respectively. The censored subject contributes one unit to the second interval’s exposure but no event count.

Parametric Hazards Beyond a Constant Rate

For a parametric baseline hazard, the same event-and-exposure likelihood applies, but the integral may couple several parameters and prevent a closed-form update. A useful strategy is to identify any parameters that retain conjugate conditional distributions, then sample the remaining parameters from their conditional posterior kernels using an appropriate transition method. The posterior kernel must include the prior and every likelihood term that depends on the parameter being updated.

For example, consider a Gompertz baseline \(h_0(t;a,b)=a\exp(bt)\), where \(a>0\) is a scale parameter and \(b\) is a shape parameter. For fixed \(b\), define \(q_b(t)=\int_0^t\exp(bu)\,du\), which equals \((\exp(bt)-1)/b\) when \(b\ne0\), and \(t\) when \(b=0\). With risk multipliers equal to 1, the event likelihood contributes \(a^D\exp(b\sum_{\delta_i=1}Y_i)\), while survival contributes \(\exp\{-a\sum_i q_b(Y_i)\}\). Thus a Gamma prior on \(a\) gives a Gamma conditional update. If \(b\) is unknown, its conditional posterior generally has no Gamma form and must retain its own prior and the likelihood terms that depend on \(b\).

Worked Example: Conditional Scale Update in a Gompertz Model

Use \(h_0(t;a,b)=a\exp(bt)\), with \(b=0.1\) per time unit held fixed for this conditional update. Suppose two subjects have observed events at times 1 and 2, and one subject is censored at time 3; all risk multipliers are 1. Give \(a\) a \(\operatorname{Gamma}(1.5,0.5)\) prior, with rate convention.

There are \(D=2\) events. The integrated exposure for each observed time is \(q_b(t)=(\exp(0.1t)-1)/0.1\). Numerically, \(q_b(1)=1.0517\), \(q_b(2)=2.2140\), and \(q_b(3)=3.4986\), so the total is \(A=1.0517+2.2140+3.4986=6.7643\) time units. The event-time factor \(\exp(0.1(1+2))\) does not involve \(a\), so it is constant in the conditional update for \(a\).

The likelihood kernel in \(a\) is \(a^2\exp(-6.7643a)\). Multiplying by the prior kernel \(a^{1.5-1}\exp(-0.5a)\) gives \(a^{3.5-1}\exp(-7.2643a)\). Therefore \(a\mid b,\text{rest},\mathcal D\sim\operatorname{Gamma}(3.5,7.2643)\), with conditional posterior mean \(3.5/7.2643=0.4818\) per time unit. The censored subject contributes \(q_b(3)\) to the exposure, just as an event subject contributes exposure through its event time.

Derivation, Sampling, and Checks

The conjugate update can be derived directly rather than memorized. For a constant hazard \(\lambda\) on one interval, an observed event contributes \(\lambda\) from its hazard term and every subject contributes \(\exp(-\lambda \times \text{risk-weighted time})\) from survival. Multiplying over subjects gives the likelihood kernel \(\lambda^d\exp(-A\lambda)\). Multiplying by a Gamma prior kernel yields

$$ \lambda^{a-1}e^{-b\lambda}\,\lambda^d e^{-A\lambda} =\lambda^{(a+d)-1}e^{-(b+A)\lambda}. $$

The expression on the right is the kernel of a Gamma distribution with shape \(a+d\) and rate \(b+A\). This also explains why a rate parameter, not a scale parameter, is added to exposure. If software uses a Gamma scale parameter, it must instead receive the reciprocal of the rate.

A direct Gamma draw is an exact conditional update when the stated conjugacy conditions hold. For other parametric parameters, first form the log posterior kernel from the prior plus the event log-hazards minus the cumulative hazards. A proposed update must respect the parameter space, and its acceptance calculation must use the full conditional target, including any transformation Jacobian if sampling on a transformed scale. Do not treat an unavailable closed-form draw as evidence that a likelihood term can be dropped.

Useful checks include verifying that total exposure includes all observed follow-up, confirming that each event is assigned to exactly one interval, and checking that the calculated integrated hazard is nonnegative. For a constant hazard, increasing a subject’s follow-up while holding the event count fixed should increase the posterior rate and lower the conditional posterior mean. If a supposedly conjugate update produces a rate smaller than its prior rate despite positive exposure, inspect the exposure calculation and Gamma parameterization.

Comparison and Limitations

SpecificationConditional updateMain consideration
Constant exponential baselineGamma update under a Gamma priorOne hazard level; all follow-up contributes exposure.
Piecewise-constant baselineInterval-specific Gamma updates with independent Gamma priorsFlexible over time, but the result depends on interval placement and prior structure.
General parametric baselineMay be conjugate for some parameters; otherwise use the full conditional targetFewer structural parameters can improve parsimony, but misspecification of the hazard shape remains possible.

These are alternative ways to represent the baseline hazard, not interchangeable assumptions. A piecewise-constant model can adapt to different hazard levels across intervals but may be sensitive to sparse events or arbitrary cut points. A smooth parametric form is more compact, but imposes its chosen time pattern. Conditional updates also depend on the current latent effects and association parameters; uncertainty about those quantities is represented only through the full sequence of joint-model updates, not by a single baseline update.

Common mistake: “A censored subject had no event, so that subject contributes nothing to the hazard update.” This is wrong because censoring still establishes survival through the censoring time. The correct contribution is the survival factor, which adds integrated exposure to the likelihood; only the event-hazard factor is absent. Another frequent error is to count exposure only up to the beginning of an interval rather than integrating over the portion of the interval the subject actually remained under observation.

Key takeaway: Baseline-hazard updates are driven by two distinct summaries: event hazards at observed event times and cumulative risk-weighted exposure through every observed follow-up time. Keep those pieces separate when deriving and checking a conditional posterior.

Check Your Understanding

For each question, identify the update logic before checking the short solution.

  1. With a constant baseline hazard, one event occurs at time 2 and one subject is censored at time 5. What are the event count and total exposure?
  2. A piecewise interval has \(d_k=3\), \(A_k=8\), and prior \(\operatorname{Gamma}(2,1)\). Give the conditional posterior and its mean.
  3. Why does a censored subject contribute to the posterior rate in a Gamma baseline-hazard update?
  4. In a parametric model \(h_0(t;a,b)=a\exp(bt)\), which part of the conditional update for \(a\) is affected by an event-time factor involving \(b\), when \(b\) is held fixed?

Solutions. (1) The event count is \(1\); exposure is \(2+5=7\) time units, so the likelihood kernel is \(\lambda\exp(-7\lambda)\). (2) The posterior is \(\operatorname{Gamma}(2+3,1+8)=\operatorname{Gamma}(5,9)\), with mean \(5/9=0.5556\) in the reciprocal units of exposure. (3) Censoring establishes survival through the censoring time, so its survival probability includes the integrated hazard through that time; it adds exposure but no event. (4) With \(b\) fixed, a factor depending only on event times and \(b\) is constant with respect to \(a\), so it does not change the conditional posterior kernel for \(a\).

Clinical Biostats