Tutorials › Joint Modeling of Longitudinal and Time-to-Event Data › The MCMC Target in Bayesian Joint Models

Bayesian Joint Models · Tutorial 301 of 697

The MCMC Target in Bayesian Joint Models

Learn how to write and interpret the joint posterior sampled by MCMC, including the role of latent subject effects and the coupling of the two data sources.

Advanced 11 min read

What You'll Learn

  • Write the unnormalized joint posterior for global parameters and subject-specific random effects.
  • Distinguish population-level parameters from latent subject effects in the sampling target.
  • Explain how shared random effects connect longitudinal measurements with event-time information.
  • Calculate a subject’s joint likelihood contribution and a posterior-target ratio.
  • Identify common errors in interpreting a posterior density or omitting a model component.
  • Recognize assumptions, diagnostics, and alternatives relevant to the MCMC target.

What Distribution Does MCMC Target?

In a Bayesian joint model, MCMC is used to generate draws from a posterior distribution. To understand what those draws represent, it is essential to identify the target precisely: it includes both population-level model parameters and the subject-specific random effects treated as latent quantities. The target is not just the longitudinal likelihood, just the survival likelihood, or a list of fitted estimates. It is a probability distribution formed by combining the two data sources with the model’s prior distributions.

Let \(i=1,\ldots,n\) index subjects, and let \(j=1,\ldots,n_i\) index the longitudinal measurements for subject \(i\). Write \(y_{ij}\) for the measurement at time \(t_{ij}\). Let \(T_i\) be the observed event or follow-up time and \(\delta_i\) indicate whether an event was observed. Let \(b_i\) be subject \(i\)’s random-effects vector. Denote the collection of global model parameters by \(\theta\), including, as appropriate, longitudinal fixed effects and residual parameters, the random-effects covariance matrix, survival regression and baseline hazard parameters, and association parameters.

Definition: The joint posterior target is the posterior density of the global parameters \(\theta\) and latent subject effects \(b=(b_1,\ldots,b_n)\) given all observed longitudinal and event-time data. Under the usual factorization of the model and prior, its unnormalized form is
$$ \pi(\theta,b\mid \mathcal D) \propto p(\theta)\prod_{i=1}^n p(b_i\mid\theta) \prod_{i=1}^n L_{Yi}(\theta,b_i)L_{Ti}(\theta,b_i). $$

Here \(\mathcal D\) denotes all observed data, \(L_{Yi}\) is subject \(i\)’s conditional longitudinal likelihood, and \(L_{Ti}\) is that subject’s conditional survival likelihood. The proportionality omits the marginal data density, which is a constant with respect to \(\theta\) and \(b\). The prior factorization shown is a common specification: global parameters have prior density \(p(\theta)\), and subject effects are conditionally independent given the relevant parameters. If a model specifies a different joint prior, that prior replaces these factors; the likelihood construction is unchanged.

The elements of \(\theta\) are global or population-level unknowns. In contrast, \(b_i\) describes subject \(i\)’s deviation from the population trajectory or hazard structure. A random effect is a latent variable in the probability model, not an additional observed measurement. It is unknown and receives a posterior distribution, but it is not interchangeable with a population parameter such as a fixed-effect coefficient or an association parameter.

How the Two Likelihoods Enter

For a standard Gaussian longitudinal submodel with conditionally independent measurement errors, suppose \(y_{ij}\mid b_i,\theta\sim N\{m_i(t_{ij};b_i),\sigma^2\}\), where \(m_i(t;b_i)=x_i(t)^\mathsf T\beta+z_i(t)^\mathsf T b_i\). Then

$$ L_{Yi}(\theta,b_i) = \prod_{j=1}^{n_i} \frac{1}{\sqrt{2\pi\sigma^2}} \exp\left\{ -\frac{\{y_{ij}-m_i(t_{ij};b_i)\}^2}{2\sigma^2} \right\}. $$

For illustration, take a proportional-hazards specification in which the current longitudinal value enters the hazard: \(h_i(t\mid b_i,\theta)=h_0(t)\exp\{\gamma^\mathsf T w_i+\alpha m_i(t;b_i)\}\). With the usual event-time likelihood contribution, the survival factor is

$$ L_{Ti}(\theta,b_i) = \{h_i(T_i\mid b_i,\theta)\}^{\delta_i} \exp\left\{-\int_0^{T_i}h_i(u\mid b_i,\theta)\,du\right\}. $$

This form assumes that the longitudinal observations are conditionally independent given the random effects and model parameters, and that the event-time process has the specified hazard conditional on those same quantities and covariates. It also relies on the model’s censoring assumptions, including that the event-time contribution is appropriate for the observed follow-up. These assumptions should be checked against the study design and model specification; they are not consequences of using MCMC.

The shared \(b_i\) is the source of the coupling. It appears in the longitudinal mean and, through \(m_i(t;b_i)\), in the hazard. Consequently, longitudinal observations inform the posterior for \(b_i\), and that posterior information affects the survival likelihood; survival information also informs \(b_i\), and thereby the implied longitudinal trajectory. Conditional on \(b_i\) and the model parameters, the two likelihood factors can be multiplied. They are not generally independent after \(b_i\) is integrated out.

Worked Example: A Single Subject’s Joint Likelihood Contribution

Consider a hypothetical subject with one longitudinal measurement \(y=2.4\). At the parameter value under consideration, the model mean is \(2.0\) and the residual standard deviation is \(0.5\). Suppose the subject has an observed event under a constant hazard of \(0.2\) per year, at \(T=3.15485\) years. For this calculation, treat the model parameters and random effect as fixed at the stated values.

The longitudinal contribution is a normal density:

$$ L_Y = \frac{1}{\sqrt{2\pi(0.5)^2}} \exp\left\{-\frac{(2.4-2.0)^2}{2(0.5)^2}\right\} = 0.7978846\exp(-0.32) \approx 0.579383 \approx 0.5794. $$

Because an event was observed, the survival contribution is the hazard at the event time multiplied by survival to that time:

$$ L_T = 0.2\exp\{-0.2(3.15485)\} \approx 0.106415 \approx 0.1064. $$

The subject’s joint likelihood contribution is the product of the unrounded factors:

$$ L_YL_T \approx 0.579383(0.106415) \approx 0.061655 \approx 0.06166. $$

The value is a likelihood contribution at the specified parameter and random-effect values, not a posterior probability. The longitudinal density has units inverse to the measurement unit, while the event-time density has units inverse to time; their product is a joint density with the corresponding combined units.

Why the Posterior Is a Joint Target

The target follows directly from Bayes’ rule and the conditional likelihood factorization. Given \(\theta\) and \(b\), the model assigns the observed data a likelihood that factors by subject; within each subject it separates into longitudinal and survival contributions under the stated conditional-independence assumptions. Multiplying this likelihood by the prior density gives the posterior up to its normalizing constant:

$$ \begin{aligned} p(\theta,b\mid\mathcal D) &= \frac{p(\mathcal D\mid\theta,b)p(\theta,b)} {p(\mathcal D)},\\ p(\mathcal D\mid\theta,b) &= \prod_{i=1}^n L_{Yi}(\theta,b_i)L_{Ti}(\theta,b_i),\\ p(\theta,b) &= p(\theta)\prod_{i=1}^n p(b_i\mid\theta). \end{aligned} $$

Since \(p(\mathcal D)\) does not vary across candidate values of \(\theta\) and \(b\), it can be omitted when specifying the MCMC target. It cannot be omitted from a calculation that requires the normalized posterior density itself. MCMC targets the distribution represented by the resulting kernel, not a particular numerical value of that kernel.

This also explains why a subject effect should not be silently dropped from the target. If \(b_i\) is represented explicitly, its prior density and both conditional likelihood contributions belong in the joint posterior. A posterior for \(\theta\) alone would instead require integrating the subject effects out: \(p(\theta\mid\mathcal D)=\int p(\theta,b\mid\mathcal D)\,db\). That is a different representation of the posterior, not the same explicit joint target with the \(b_i\) terms omitted.

Worked Example: Comparing Two Candidate Target Values

Suppose two hypothetical candidate states differ in a subject effect. At the first state, the product of the random-effect prior and all longitudinal likelihood factors, relative to the second state, is \(0.9695\). The ratio of their survival likelihood factors is \(0.8825\). Suppose all remaining prior and likelihood factors have ratio \(1\). The ratio of the unnormalized posterior target at the first state to that at the second is therefore

$$ \frac{\tilde\pi(\theta,b^{(1)}\mid\mathcal D)} {\tilde\pi(\theta,b^{(2)}\mid\mathcal D)} = 0.9695\times0.8825 = 0.85558375 \approx 0.8556. $$

Thus the first state has about \(0.8556\) times the unnormalized target density of the second under the stated comparison. This ratio is not a posterior probability that one state is correct. It compares density values, and the common normalizing constant cancels. The calculation also shows why a likelihood ratio based on only one data source is not, by itself, the posterior-target ratio.

Worked Example: Separating a Latent Effect from Global Parameters

Return to the single-subject setup above, and suppose the random effect at this state is \(b=0\) with prior \(b\sim N(0,1)\). Suppose the global-parameter prior density at the specified global parameter values is \(p(\theta)=0.05000\). Using the unrounded joint likelihood contribution \(0.061655\), the joint posterior kernel is

$$ \tilde\pi(\theta,b\mid\mathcal D) = p(\theta)\,p(b\mid\theta)\,L_YL_T = 0.05000 \left\{ \frac{1}{\sqrt{2\pi}}\exp(0) \right\} (0.061655) \approx 0.001230. $$

The global parameters are held at the values used to obtain the likelihood and global prior density. The random effect \(b\) is a separate coordinate of the joint target, and its prior density contributes its own factor. This numerical kernel value depends on the units and parameterization of the densities; it is not the probability of the exact point \((\theta,b)\), which is zero for continuous variables.

Assumptions, Diagnostics, and Alternatives

Writing down the target is also a useful model check. Before interpreting its terms, verify that the longitudinal density matches the measurement scale and error structure, the hazard uses the intended association structure, the event-time contribution matches the observation and censoring scheme, and all prior factors correspond to the parameters in the model. Check that a random effect used in one component is the same subject’s effect in the other component. If the longitudinal and survival submodels use unrelated subject effects, the target no longer expresses the shared-random-effects model described here.

Several warning signs indicate that the target may have been assembled incorrectly:

  • A missing prior factor. A latent \(b_i\) included in the sampling state still needs its random-effects density in the posterior kernel.
  • A missing data component. Using only \(L_{Yi}\) or only \(L_{Ti}\) discards information and does not target the stated joint model.
  • Duplicated contributions. Each subject’s longitudinal and survival likelihood should enter once under the stated factorization, not once per MCMC iteration within the mathematical target.
  • Inconsistent dependence. If the survival hazard uses \(m_i(t;b_i)\), but the likelihood calculation treats that term as independent of \(b_i\), the shared-effect coupling has been lost.
  • Confusing kernel and density. Omitting a parameter-independent normalizing constant is valid for the MCMC target kernel, but it does not make the kernel a normalized posterior density.

A basic diagnostic is to inspect the written target term by term and check it at a fixed, simple parameter value, as in the worked calculations. Also verify that changing \(b_i\) can affect the appropriate longitudinal and survival factors, and that changing a global parameter affects precisely the components in which it appears. These checks can find coding or model-translation errors; they do not establish that a sampling algorithm has converged or that the model is substantively adequate.

The explicit joint target with \(b\) included is one computational representation. An alternative is to integrate the random effects out and target a marginal posterior for \(\theta\); this can avoid sampling those latent variables explicitly but requires evaluating the resulting marginal likelihood. Another alternative is to fit longitudinal and survival models separately, but separate fits generally do not use the shared random effect to transmit information between the two processes. Neither alternative changes the model automatically: the likelihood and prior must still encode the intended assumptions.

A common pitfall is to say, “MCMC samples the parameter posterior, so the random effects are only nuisance estimates and can be left out.” That reasoning confuses the marginal posterior for global parameters with the joint posterior used by an explicit latent-variable representation. If the algorithm’s state includes \(b\), the target must include \(p(b\mid\theta)\), \(L_Y(\theta,b)\), and \(L_T(\theta,b)\). A later marginal posterior for \(\theta\) can be obtained by integrating the joint posterior over \(b\), not by deleting its factors.

Key takeaway: In an explicit shared-random-effects formulation, the MCMC target is the joint posterior over global parameters and latent subject effects. Each subject’s longitudinal and survival information enters through its conditional likelihood factors, linked by the shared effect, and the prior completes the target.

Check Your Understanding

Answer each question, then compare your reasoning with the solutions.

  1. Which quantities are included in the explicit joint posterior target: global parameters, subject effects, or both?
  2. Why does a shared random effect couple the longitudinal and survival likelihoods?
  3. If the unnormalized target at one state is \(0.30\) times its value at another state, is \(0.30\) the posterior probability of the first state?
  4. What changes when the subject effects are integrated out of the posterior representation?

Solutions. (1) Both global parameters \(\theta\) and latent subject effects \(b\) are included when the target is written jointly. (2) The same subject effect enters the longitudinal mean and the hazard, so information from either process changes the posterior distribution of that effect and thereby connects the likelihood contributions. (3) No. It is a ratio of unnormalized density values; it is not a posterior probability. (4) The target becomes a marginal posterior for the global parameters, obtained by integrating the joint posterior over all subject effects; their prior and likelihood contributions are not simply discarded.

Clinical Biostats