Tutorials › Joint Modeling of Longitudinal and Time-to-Event Data › Updating Random-Effects Weights With Biomarker History

Dynamic Prediction · Tutorial 505 of 697

Updating Random-Effects Weights With Biomarker History

Use a patient’s observed biomarker values and measurement times to update the population distribution of shared random effects into a history-specific posterior.

Advanced 12 min read

What You'll Learn

  • Define the biomarker history used to update a patient’s random-effects distribution.
  • Derive the posterior density by combining the random-effects prior with the longitudinal likelihood.
  • Obtain the closed-form Gaussian posterior mean and covariance for a linear mixed model.
  • Calculate posterior weights for a discrete random-effects distribution and binary biomarker data.
  • Identify assumptions, numerical checks, and limitations of a history-based update.

From a Population Distribution to a Patient-Specific Distribution

A joint model represents a patient’s latent biomarker trajectory through shared random effects. Before observing that patient’s biomarker values, the random effects have a population distribution. After observing a history of values at particular times, the distribution should generally change: histories that are more compatible with some random-effect values than others shift probability toward those values. This update is the bridge between a population model and an individualized trajectory.

The task here is to update using the longitudinal observations and their measurement times. The update is conditional on the longitudinal model and its parameters. It is not obtained by simply substituting the observed measurements for latent trajectory values, nor by treating an estimated random effect as known without uncertainty.

Definition: For patient \(i\), let \(b_i\) be the vector of shared random effects, and let the observed biomarker history through time \(s\) be \(H_i(s)=\{(t_{ij},y_{ij}):j=1,\ldots,m_i,\ t_{ij}\le s\}\). Given model parameters \(\theta\) and relevant covariates \(x_i\), the history-updated random-effects distribution is \(p(b_i\mid H_i(s),t_i,x_i,\theta)\). It combines the prior distribution \(p(b_i\mid x_i,\theta)\) with the likelihood of the observed biomarker values conditional on \(b_i\) and their measurement times.

Bayes’ Rule for a Biomarker History

Suppose the longitudinal model implies conditional densities \(f(y_{ij}\mid b_i,t_{ij},x_i,\theta)\), and the measurements are conditionally independent given \(b_i\), their times, and the model parameters. Conditioning on the observed schedule \(t_i=(t_{i1},\ldots,t_{im_i})\), the history likelihood is

$$ L_i(b_i;H_i,\theta) =\prod_{j=1}^{m_i}f(y_{ij}\mid b_i,t_{ij},x_i,\theta). $$

The posterior density is this likelihood times the prior density, divided by a normalizing constant. The integral in the denominator makes the posterior integrate to one over the possible values of \(b_i\).

$$ p(b_i\mid H_i,t_i,x_i,\theta) = \frac{ L_i(b_i;H_i,\theta)\,p(b_i\mid x_i,\theta) }{ \displaystyle\int L_i(u;H_i,\theta)\,p(u\mid x_i,\theta)\,du }. $$

The times appear in the likelihood because the longitudinal model may assign different expected values, variances, or response probabilities at different times. If the schedule is fixed by design, or is ignorable under the analysis assumptions, conditioning on the observed times is appropriate. If visit timing itself carries information about \(b_i\) after conditioning on the model variables, this likelihood alone is not enough: a model for the visit process may also be needed.

This update is conditional on \(\theta\), which commonly includes population parameters estimated from the full data. Treating \(\theta\) as fixed gives a conditional posterior for \(b_i\); it does not automatically include uncertainty in estimating those parameters. The history likelihood also uses only the biomarker observations specified in \(H_i(s)\). Other information should enter only if it is explicitly part of the conditioning set or model.

Gaussian Linear Mixed Model: A Closed-Form Update

For a Gaussian linear mixed model, write the patient’s observations in vector form as

$$ y_i=X_i\beta+Z_i b_i+\varepsilon_i,\qquad b_i\sim N(0,D),\qquad \varepsilon_i\sim N(0,R_i). $$

Assume \(b_i\) and \(\varepsilon_i\) are independent, \(D\) and \(R_i\) are positive definite, and the errors are conditionally Gaussian with covariance \(R_i\). The matrices \(X_i\) and \(Z_i\) are formed using the patient’s covariates and measurement times. Given fixed model parameters, the posterior is normal, with covariance \(V_i\) and mean \(\mu_i\):

$$ V_i=(D^{-1}+Z_i^\mathsf{T}R_i^{-1}Z_i)^{-1}, \qquad \mu_i=V_iZ_i^\mathsf{T}R_i^{-1}(y_i-X_i\beta). $$

The covariance reflects both sources of information: \(D\), the population variation in random effects, and the precision of the patient’s longitudinal data. More precise observations generally contribute more to the update, while a small number of noisy observations usually leave substantial posterior uncertainty.

Why the Gaussian Formula Holds

Let \(r_i=y_i-X_i\beta\). The prior density contributes a quadratic term in \(b_i\) involving \(D^{-1}\); the Gaussian observation likelihood contributes a quadratic term involving \(Z_i^\mathsf{T}R_i^{-1}Z_i\). Their product has exponent, up to a constant independent of \(b_i\),

$$ -\frac{1}{2}\left[ b_i^\mathsf{T}D^{-1}b_i+ (r_i-Z_i b_i)^\mathsf{T}R_i^{-1}(r_i-Z_i b_i) \right]. $$

Expanding the second quadratic gives a coefficient of \(b_i^\mathsf{T}b_i\) equal to \(D^{-1}+Z_i^\mathsf{T}R_i^{-1}Z_i\), and a linear term in \(b_i\) equal to \(b_i^\mathsf{T}Z_i^\mathsf{T}R_i^{-1}r_i\). Completing the square therefore yields

$$ -\frac{1}{2}(b_i-\mu_i)^\mathsf{T}V_i^{-1}(b_i-\mu_i) +\text{a term not depending on }b_i, $$

where \(V_i^{-1}=D^{-1}+Z_i^\mathsf{T}R_i^{-1}Z_i\) and \(\mu_i=V_iZ_i^\mathsf{T}R_i^{-1}r_i\). This is the exponent of a multivariate normal density, establishing the stated posterior. Positive definiteness ensures the precision matrix is invertible and the covariance is well defined.

Worked Example: Updating a Random Intercept from Two Measurements

Suppose a hypothetical biomarker follows \(Y_i(t)=2+0.3t+b_i+\varepsilon_i(t)\), where \(b_i\sim N(0,1)\), and the independent measurement errors have variance \(1\). A patient has values \(y_{i1}=3.1\) at \(t_{i1}=1\) and \(y_{i2}=3.7\) at \(t_{i2}=3\). Treat the model parameters as known and assume the measurement times are fixed by design.

The fixed parts of the means are \(2+0.3(1)=2.3\) and \(2+0.3(3)=2.9\). Thus the residual vector after subtracting the fixed means is \(r_i=(3.1-2.3,\ 3.7-2.9)^\mathsf{T}=(0.8,\ 0.8)^\mathsf{T}\). For this random-intercept model, \(D=1\), \(R_i=I_2\), and \(Z_i=(1,\ 1)^\mathsf{T}\).

The posterior precision is \(1+1+1=3\), so the posterior variance is \(V_i=1/3=0.3333\). The posterior mean is

$$ \mu_i =\frac{1}{3}\{(1)(0.8)+(1)(0.8)\} =\frac{1.6}{3} =0.5333. $$

Consequently, \(b_i\mid H_i\sim N(0.5333,0.3333)\), with posterior standard deviation \(\sqrt{1/3}\approx 0.5774\) biomarker units. The observed values shift the estimated random intercept above its prior mean of zero, but the posterior standard deviation shows that the latent intercept is still uncertain.

Worked Example: Unequal Measurement Precision at Different Times

Consider another hypothetical random-intercept model with \(b_i\sim N(0,1)\) and known mean function \(1+0.2t+b_i\). A measurement at \(t=0\) is \(y_{i1}=2.0\) with error variance \(0.25\); a measurement at \(t=2\) is \(y_{i2}=0.8\) with error variance \(1\). Assume independent Gaussian errors and a fixed measurement schedule.

Subtract the time-specific fixed means: \(r_{i1}=2.0-1.0=1.0\) and \(r_{i2}=0.8-1.4=-0.6\). The prior precision is \(1\). The first observation has precision \(1/0.25=4\), while the second has precision \(1/1=1\). Therefore,

$$ V_i=\frac{1}{1+4+1}=\frac{1}{6}=0.1667, \qquad \mu_i=V_i\left\{4(1.0)+1(-0.6)\right\} =\frac{3.4}{6}=0.5667. $$

The more precise first measurement has four times the observation precision of the second, so it contributes more strongly to the posterior mean. The posterior standard deviation is \(\sqrt{1/6}\approx 0.4082\) biomarker units. Ignoring the unequal error variances would give the wrong relative weighting and hence a different posterior.

Non-Gaussian Biomarkers and Posterior Weights

For binary, count, ordinal, or other non-Gaussian biomarkers, the posterior update has the same Bayes-rule form, but it will not generally be normal or available in closed form. When random effects have a discrete distribution or are represented by quadrature nodes, the update can be implemented by reweighting. For node \(b^{(k)}\) with prior probability \(w_k\), calculate its history likelihood \(L_i(b^{(k)};H_i)\), multiply by \(w_k\), and normalize:

$$ w_{ik}^{\text{post}} = \frac{w_kL_i(b^{(k)};H_i)} {\displaystyle\sum_{\ell}w_\ell L_i(b^{(\ell)};H_i)}. $$

For a continuous random-effects distribution, quadrature or Monte Carlo methods approximate the corresponding integral. The likelihood must use the correct conditional response model; for example, a binary response contributes a Bernoulli probability, not a Gaussian density.

Worked Example: Reweighting Three Random-Effect Values for a Binary Marker

In a hypothetical illustrative model, \(b_i\) takes values \(-1,0,1\) with prior probabilities \(0.25,0.50,0.25\). At two observed times, \(t=1\) and \(t=4\), the binary marker outcomes are \(0\) and \(1\). Suppose the conditional probability of a value of \(1\) is \(0.5+0.2b_i\) at either time, and the two outcomes are conditionally independent given \(b_i\). These probabilities are \(0.3,0.5,0.7\) for \(b_i=-1,0,1\), respectively, so each is valid.

For \(b_i=-1\), the likelihood is \(P(Y_{i1}=0\mid b_i)P(Y_{i2}=1\mid b_i)=(0.7)(0.3)=0.21\). For \(b_i=0\), it is \((0.5)(0.5)=0.25\). For \(b_i=1\), it is \((0.3)(0.7)=0.21\). Multiplying by the prior probabilities gives unnormalized weights \(0.0525,\ 0.125,\ 0.0525\), whose sum is \(0.23\).

The normalized posterior probabilities, in order \(b_i=-1,0,1\), are

$$ \left( \frac{0.0525}{0.23}, \frac{0.125}{0.23}, \frac{0.0525}{0.23} \right) = (0.2283,\ 0.5435,\ 0.2283). $$

The posterior mean is \((-1)(0.2283)+(0)(0.5435)+(1)(0.2283)=0\), by symmetry. The posterior probability on \(b_i=0\) increases from \(0.50\) to \(0.5435\), because this history is somewhat more likely at \(b_i=0\) than at either extreme. This simple model is flat in time; in a model where response probabilities vary with time, the likelihood factor at each observed time must use that time-specific probability.

Computation, Diagnostics, and Alternatives

A posterior update should be checked as a calculation and as a model-based inference. In a discrete computation, confirm that all likelihoods and prior weights are nonnegative, the normalizing constant is positive, and the normalized weights sum to one, subject only to rounding. For a continuous computation, check numerical stability and whether quadrature or simulation adequately covers regions with appreciable posterior density. In high dimensions, likelihood products can underflow; summing log-likelihoods and using a log-sum-exp normalization avoids this problem.

The model assumptions also need scrutiny. Conditional independence may fail if residual serial correlation remains after including the random effects. A Gaussian posterior calculation can be misleading if the response distribution or error variance is badly misspecified. A visit schedule that depends on latent biomarker values may require a model for the visit process rather than conditioning on times as though they were noninformative. Sparse or noisy histories may leave a posterior close to the prior; an unexpectedly extreme posterior based on little information can signal a coding, scaling, or model problem.

ApproachWhat it providesMain caution
Posterior distributionA history-specific distribution for the random effects, including uncertaintyDepends on the prior and correctly specified longitudinal likelihood
Posterior mean or mode aloneA compact point summary of the updateDoes not convey posterior spread or possible skewness
Population prior without updatingThe random-effects distribution before using the patient’s biomarker historyDoes not reflect individual longitudinal information
Plug-in trajectory estimateA single fitted latent trajectory, often based on an estimated random effectTreating it as known can understate uncertainty

The posterior distribution is especially useful when a later calculation must average over uncertainty in the patient’s latent trajectory. A point estimate can be a convenient summary, but it is not generally a substitute for that distribution. The update also has limits: it is only as reliable as the fitted longitudinal model, the random-effects distribution, and the assumptions about the observation process. If population parameters are estimated with substantial uncertainty, a plug-in posterior can understate the full uncertainty unless parameter uncertainty is propagated.

Common Mistake

A common mistake is to set the patient’s random effect equal to the difference between one observed biomarker and its expected value, then use that value as if it were known. This ignores measurement error and the population distribution. For example, a large residual could reflect a large random effect, a noisy measurement, or both. The posterior update balances these explanations through the likelihood and prior; it also retains uncertainty about the random effect. In the Gaussian case, the posterior covariance \(V_i\) makes that remaining uncertainty explicit.

Key takeaway: Updating random-effects weights means multiplying the population prior by the longitudinal likelihood of the patient’s observed values at their measurement times, then normalizing. The result is a patient-specific distribution, not merely a substituted value.

Check Your Understanding

Try each question, then compare your reasoning with the solutions below.

  1. In the Gaussian model, why do the measurement times enter the update even when the random effect is a random intercept?
  2. Suppose a Gaussian random-intercept model has prior variance \(1\), two independent measurements with error variance \(1\), and residuals \(0.6\) and \(0.0\) after subtracting fixed means. Find the posterior mean and variance.
  3. For discrete random-effect values, what must be done to prior probability times likelihood in order to obtain posterior probabilities?
  4. Name one condition under which conditioning on the observed measurement times alone may be inadequate.

Solutions. (1) The fixed mean and potentially the error distribution can vary with time, so the residuals used in the likelihood depend on the times; the time design also determines which observations contribute. (2) The posterior variance is \(1/(1+1+1)=1/3=0.3333\). The posterior mean is \((1/3)\{0.6+0.0\}=0.2000\). (3) Normalize the products by dividing each by their sum across all random-effect values, provided that sum is positive. (4) Conditioning on times alone may be inadequate if visit timing is informative about latent biomarker values or random effects after conditioning on the modeled variables; a visit-process model may then be needed.

Clinical Biostats