From Posterior Draws to a Dynamic Risk
At a landmark time \(s\), a patient is known to be alive and their longitudinal measurements through \(s\) are available. The prediction of interest is often the probability of an event during the next \(w\) time units, conditional on that history and survival to \(s\). In a Bayesian joint model, this probability depends on uncertain population parameters and on the patient’s latent effects, which determine their underlying marker trajectory. Posterior draws provide a direct way to carry both sources of uncertainty into the prediction.
The key operation is to calculate the conditional risk for each joint draw, then average those risks. It is generally not equivalent to first average the model parameters and latent effects and then calculate one risk. The risk function is nonlinear, and the posterior dependence between parameters and patient effects is part of the prediction.
Write the event hazard conditional on a parameter value and latent effects as \(h_i(t\mid\theta,b_i)\). This hazard may depend on the latent marker trajectory, for example through a current-value association. The draw-specific risk is obtained from the cumulative hazard between \(s\) and \(s+w\). In applying the formulas below, assume the joint model specifies this hazard, the patient’s event history is correctly represented, and any future covariates needed for the hazard are fixed or otherwise specified for the prediction. This tutorial does not infer an unknown future covariate path.
Here \((\theta^{(m)},b_i^{(m)})\) is the \(m\)th joint posterior draw. The draw-specific risk is conditional on that draw’s parameters and latent effects. If the posterior draws target the distribution given the patient’s longitudinal history and survival to the landmark, the posterior predictive risk is estimated by
This is a Monte Carlo approximation to the posterior expectation of the draw-specific risk. The \(M\) draws may come from a Markov chain; in that case, they need not be independent. The average remains the basic estimator, but autocorrelation affects its Monte Carlo precision.
Why the Landmark Conditioning Matters
For fixed \(\theta\) and \(b_i\), the conditional survival probability from \(s\) through \(s+w\) is the ratio of survival probabilities at the two times. Under the hazard model, that ratio is the exponential of minus the cumulative hazard over the interval. Thus the conditional event risk for fixed latent quantities is one minus this survival probability.
Averaging this conditional probability over the posterior distribution given \(\mathcal{D}_i(s)\) and \(T_i>s\) gives the prediction. This conditioning is consequential: survival to the landmark is information about the patient’s latent risk and model parameters. If posterior draws are generated for a patient’s prediction, their target must incorporate the relevant event-free survival information up to \(s\), as well as the available longitudinal history.
The formula also explains the computational procedure: evaluate the bracketed risk at each posterior draw, then average. It is the risk—not the hazard, the marker value, or the parameters—that is averaged. The integral over time may be analytic for a simple hazard model or evaluated numerically when the hazard has a more complicated time dependence.
Worked Example: Constant Hazard Within Each Draw
Worked Example: Constant Hazard Within Each Draw
Suppose, hypothetically, that a joint model uses the hazard \(h_i(t\mid\theta,b_i)=\lambda\exp\{\gamma m_i(s)\}\) as constant over a two-year prediction horizon. Here \(\lambda\) is a baseline hazard in inverse years, \(\gamma\) is an association parameter, and \(m_i(s)\) is the latent marker value at the landmark. Assume three equally weighted posterior draws, already sampled conditional on the patient’s history and being event-free at \(s\).
For each draw, the integrated hazard is \(2\lambda\exp\{\gamma m_i(s)\}\), and the risk is one minus the exponential of its negative.
Draw 1. With \(\lambda=0.04\) per year, \(\gamma=0.8\), and \(m_i(s)=1.0\), \(2(0.04)\exp(0.8\times1.0)=0.178043\). The risk is \(1-\exp(-0.178043)\approx0.1631\), or about 16.31% over two years.
Draw 2. With \(\lambda=0.05\) per year, \(\gamma=0.7\), and \(m_i(s)=1.5\), \(2(0.05)\exp(0.7\times1.5)=0.285765\). The risk is \(1-\exp(-0.285765)\approx0.2486\), or about 24.86%.
Draw 3. With \(\lambda=0.03\) per year, \(\gamma=0.6\), and \(m_i(s)=0.8\), \(2(0.03)\exp(0.6\times0.8)=0.096964\). The risk is \(1-\exp(-0.096964)\approx0.09242\), or about 9.242%.
The posterior predictive estimate is the mean of the unrounded draw-specific risks: \((0.163094+0.248561+0.09242)/3\approx0.1680\). Thus the estimated posterior predictive risk is about 16.80% over two years. These three hypothetical draws illustrate the arithmetic; in an actual analysis, many more draws would normally be used, and Monte Carlo precision would be assessed.
Retaining Joint Parameter and Trajectory Uncertainty
The latent marker value is usually itself calculated from the longitudinal submodel and its patient-specific effects. For instance, a draw might imply \(m_i(s)=x_i(s)^\mathsf{T}\beta+z_i(s)^\mathsf{T}b_i\), where \(\beta\) and \(b_i\) are drawn together with the event-model parameters. A prediction must use the marker value implied by the same draw as the hazard parameters. Pairing is important because posterior draws can exhibit dependence: a larger latent marker level may be associated with a different value of the marker-event association parameter or other model parameters.
Worked Example: Calculating Risk With Paired Draws
Consider a hypothetical one-year prediction with \(h_i(t)=\lambda\exp\{\gamma m_i(s)\}\) constant over the horizon. The following four rows are joint posterior draws; the marker values are generated by each draw’s latent effects and longitudinal parameters.
Draw 1: \(\lambda=0.025\), \(\gamma=0.5\), \(m_i(s)=0.5\). The integrated hazard is \(0.025\exp(0.25)=0.03210\), giving risk \(1-\exp(-0.03210)\approx0.03159\).
Draw 2: \(\lambda=0.040\), \(\gamma=1.0\), \(m_i(s)=0.7\). The integrated hazard is \(0.040\exp(0.70)=0.08055\), giving risk \(1-\exp(-0.08055)\approx0.07739\).
Draw 3: \(\lambda=0.030\), \(\gamma=0.8\), \(m_i(s)=0.2\). The integrated hazard is \(0.030\exp(0.16)=0.03521\), giving risk \(1-\exp(-0.03521)\approx0.03459\).
Draw 4: \(\lambda=0.050\), \(\gamma=0.4\), \(m_i(s)=1.5\). The integrated hazard is \(0.050\exp(0.60)=0.09111\), giving risk \(1-\exp(-0.09110594)\approx0.08708\).
The mean risk is approximately \(0.05766\), or about 5.766% over one year. Each calculation uses a complete row of jointly drawn quantities. Combining, for example, the mean \(\lambda\), mean \(\gamma\), and mean marker value would discard the joint pairing and would not calculate this posterior average.
This calculation includes uncertainty in both the event-model parameters and the patient’s latent marker level, provided both are represented in the posterior draws. It does not mean that the marker’s measurement error is added directly to the event hazard as though an observed measurement were the true marker. Rather, uncertainty about the latent trajectory is represented through its posterior distribution conditional on the observed history and the fitted joint model.
Posterior Averaging Is Not a Plug-In Calculation
A plug-in prediction substitutes a single value, such as a posterior mean, for each unknown quantity and calculates one risk. Posterior-draw prediction instead calculates a risk at each draw and averages. Since exponentiation and the conversion from cumulative hazard to risk are nonlinear, these two operations generally differ. A plug-in calculation may be a useful quick summary, but it is not, in general, the Bayesian posterior predictive mean risk.
Worked Example: Averaging Risks Versus Plugging in Averages
Suppose two hypothetical, equally weighted joint posterior draws give a one-year constant hazard. In the first draw, \(\lambda=0.02\) per year and \(\gamma m_i(s)=0.4\). Its hazard is \(0.02e^{0.4}=0.02984\) per year and its risk is \(1-e^{-0.02984}\approx0.02940\).
In the second draw, \(\lambda=0.08\) per year and \(\gamma m_i(s)=1.2\). Its hazard is \(0.08e^{1.2}=0.2656\) per year and its risk is \(1-e^{-0.2656}\approx0.2332\). Averaging the two draw-specific risks gives \((0.02940+0.2332)/2\approx0.1313\), or 13.13%.
For comparison, the mean of the two \(\lambda\) values is \(0.05\), and the mean of the two \(\gamma m_i(s)\) values is \(0.8\). Plugging those means into the hazard gives \(0.05e^{0.8}=0.1113\) per year, and the resulting risk is \(1-e^{-0.1113}\approx0.1053\), or 10.53%. This is not the posterior average of the draw-specific risks. The difference is a consequence of the nonlinear calculation and, in a general model, can also reflect posterior dependence among the quantities.
Implementation Checks and Failure Modes
Before interpreting a prediction, check both the posterior computation and the risk calculation. Posterior draws should come from a well-mixed chain targeting the intended conditional posterior; simply having a large number of saved iterations does not ensure a large effective sample size. Inspect trace plots and standard convergence diagnostics for the model parameters and patient-specific effects that affect the prediction. For correlated draws, assess Monte Carlo error using an appropriate method such as batch means or an effective-sample-size-based calculation, rather than treating all iterations as independent.
For each draw, verify that the cumulative hazard is nonnegative and that the resulting risk lies between zero and one. If numerical integration is used, check that its time grid is sufficiently fine or compare it with a more accurate integration method. Confirm the prediction horizon and time units: a baseline hazard expressed per year must be integrated over years, not days. Also verify that the patient’s marker value or trajectory is evaluated at the times used by the event model.
A frequent failure is to obtain draws conditional on the longitudinal observations but omit the fact that the patient survived to the landmark. That targets the wrong posterior distribution for a landmark prediction. Another is to calculate one risk from posterior mean parameters and describe it as the posterior predictive risk. A third is to average hazards first and then convert the average hazard to risk; that is generally not equal to averaging draw-specific risks. In all cases, the correct target is an average of risks evaluated under draws from the appropriate joint posterior.
| Approach | What is calculated | Key consideration |
|---|---|---|
| Posterior-draw prediction | Risk at each joint draw, followed by an average | Retains posterior parameter and latent-effect uncertainty; requires suitable posterior sampling |
| Plug-in prediction | One risk using selected point estimates | Simple, but generally not the posterior mean risk |
| Likelihood-based integration or quadrature | Numerical integration over latent effects, often conditional on parameter estimates | May be useful when posterior draws are unavailable; its treatment of parameter uncertainty depends on the procedure |
| Laplace approximation | An approximation to an integral around a mode | Can reduce computation, but accuracy depends on the adequacy of the approximation |
The earlier material on Monte Carlo integration for risk predictions provides the general numerical-integration perspective. The Bayesian version here uses posterior draws to perform the integration over uncertain parameters and latent effects together. It is flexible, but it does not repair a poorly specified joint model or a chain that has not explored its target distribution. Prediction results remain conditional on the model assumptions, the observed history, and the treatment of future covariates.
Check Your Understanding
Answer each question, then compare your reasoning with the solutions below.
- Under a constant hazard of \(0.03\) per year for a two-year horizon, what is the conditional risk for one draw?
- Two equally weighted posterior draws imply risks of \(0.10\) and \(0.30\). What is their posterior-draw estimate of risk?
- Why should the posterior distribution used for a prediction at \(s\) account for the patient being event-free at \(s\)?
- What is lost if you independently combine posterior mean parameters and a posterior mean marker value instead of using each joint draw intact?
Solutions. (1) The integrated hazard is \(2(0.03)=0.06\), so the risk is \(1-e^{-0.06}\approx0.05824\), or 5.824% over two years. (2) The mean is \((0.10+0.30)/2=0.20\), or 20%. (3) Survival to the landmark is information about the patient’s risk and latent effects; omitting it targets a posterior distribution that does not match the stated conditional prediction. (4) Independent combination discards the joint posterior pairing and dependence among parameters and latent effects; the resulting plug-in risk is generally not the average of the risks under the joint draws.