Tutorials › Joint Modeling of Longitudinal and Time-to-Event Data › Spline Trajectories for Binary Biomarkers

Flexible Trajectories and Non-Gaussian Responses · Tutorial 493 of 697

Spline Trajectories for Binary Biomarkers

Learn to combine a flexible logistic spline trajectory and a survival hazard through shared random effects, and to interpret and check the resulting joint model.

Advanced 12 min read

What You'll Learn

  • Write a spline-based logistic mixed model for repeated binary biomarker measurements.
  • Link the biomarker and event processes through shared subject-level random effects.
  • Construct the subject-specific conditional likelihood and integrate over random effects.
  • Interpret trajectory probabilities and hazard ratios on their correct scales.
  • Identify key assumptions and practical diagnostics for fitting the joint model.

Why Link a Binary Trajectory to Event Risk?

A binary biomarker records whether a condition or threshold is present at each assessment. A logistic mixed model can describe how the probability of a positive result changes over time, but a simple linear time trend may be too restrictive. A spline lets the trajectory bend. In a joint model, subject-level random effects describe differences between individuals in these trajectories and also enter the time-to-event model. This creates a statistical link between the repeated binary measurements and event risk, while accounting for the fact that measurements from the same person are related.

The model has two scales to keep distinct. The longitudinal spline describes the biomarker’s log odds, which are converted to probabilities by the logistic function. The event submodel describes a hazard, conditional on the subject’s random effects. A spline coefficient is not itself a probability, and a hazard ratio is not a difference in probabilities.

Model Specification and Assumptions

For subject \(i\), let \(Y_{ij}\) be the binary biomarker measured at time \(t_{ij}\), where \(Y_{ij}=1\) denotes a positive result and \(Y_{ij}=0\) a negative result. Let \(b_i\) be a \(q\)-dimensional vector of subject-level random effects, with \(b_i\sim N_q(0,D)\), where \(D\) is a positive-definite covariance matrix. A spline-based logistic mixed model is

$$ Y_{ij}\mid b_i \sim \operatorname{Bernoulli}(p_{ij}),\qquad \operatorname{logit}(p_{ij}) = x_i^\mathsf{T}\beta+B(t_{ij})^\mathsf{T}\gamma+Z(t_{ij})^\mathsf{T}b_i. $$

Here \(p_{ij}=P(Y_{ij}=1\mid b_i)\), \(x_i\) contains baseline covariates, and \(B(t)\) is a fixed spline basis specified by its basis functions and knots. The coefficient vector \(\gamma\) describes the population-level spline trajectory on the log-odds scale. The vector \(Z(t)\) selects or constructs the spline components that vary by subject, and \(b_i\) gives that subject’s deviations. The logistic link is \(\operatorname{logit}(p)=\log\{p/(1-p)\}\), so \(p=1/\{1+\exp(-\operatorname{logit}(p))\}\). The basis and random-effects structure must be specified before interpreting fitted coefficients.

A proportional-hazards event submodel that shares these random effects is

$$ h_i(t\mid b_i)=h_0(t)\exp\{w_i^\mathsf{T}\theta+\alpha^\mathsf{T}b_i\}. $$

In this expression, \(h_0(t)\) is the baseline hazard, \(w_i\) contains baseline event covariates, and \(\alpha\) describes how the shared random effects are associated with event risk. Conditional on covariates and \(b_i\), the hazard ratio for two subjects with random effects \(b_i\) and \(b_k\) and identical \(w\) is \(\exp\{\alpha^\mathsf{T}(b_i-b_k)\}\). This is an association conditional on the model; it does not establish that changing a biomarker trajectory would cause an event-risk change.

Definition: A shared-random-effects joint model specifies a longitudinal response model and an event-time model that both depend on the same subject-specific latent vector \(b_i\). Conditional on \(b_i\) and covariates, the model treats the two processes as independent; marginally, they are associated because both depend on \(b_i\).

The usual assumptions include a correctly specified spline basis and link, an appropriate distribution for \(b_i\), and conditional independence of the repeated binary outcomes given \(b_i\) and covariates. The event submodel must also describe the hazard adequately. The visit schedule is treated as fixed or noninformative under the model; if assessment times depend on unobserved health status, that visit process may need its own model. Censoring is assumed noninformative conditional on the modeled information, so the censoring mechanism does not add an unmodeled dependence on the event time. These assumptions are substantive, not consequences of using splines.

Worked Example: From a Spline Predictor to a Biomarker Probability

Suppose a subject has one baseline covariate with value \(x_i=1\) and coefficient \(\beta=0.4\). At a particular time, the fixed spline basis is \(B(t)=(1,0.5,0.25)^\mathsf{T}\), with \(\gamma=(-2,1.2,-0.8)^\mathsf{T}\). The random-effects basis is \(Z(t)=(1,0.5)^\mathsf{T}\), and this subject has \(b_i=(0.3,-0.4)^\mathsf{T}\). Find the conditional probability of a positive biomarker.

First calculate the fixed spline contribution:

$$ B(t)^\mathsf{T}\gamma =1(-2)+0.5(1.2)+0.25(-0.8) =-2+0.6-0.2=-1.6. $$

The random contribution is \(Z(t)^\mathsf{T}b_i=1(0.3)+0.5(-0.4)=0.1\). Including the covariate contribution gives the linear predictor \(\eta_i(t)=0.4-1.6+0.1=-1.1\). Thus

$$ p_i(t\mid b_i)=\frac{1}{1+\exp(1.1)}\approx 0.2497. $$

For this subject’s specified random effects and covariate, the model assigns about a 25.0% probability of a positive result at this time. It is a conditional probability, not the population-average probability obtained by integrating over the distribution of \(b_i\).

Subject Likelihood and the Shared-Effects Link

Let \(T_i\) be the observed event or censoring time, and let \(\delta_i=1\) indicate an observed event and \(\delta_i=0\) indicate right censoring. Conditional on \(b_i\), the event-time contribution is the hazard at the observed time when an event occurs, multiplied by the probability of surviving event-free through the observed time. Define \(J_i\) as the set of observed biomarker visits. Under the stated conditional-independence assumptions, the subject’s marginal likelihood contribution is

$$ L_i=\int \left\{\prod_{j\in J_i}p_{ij}(b)^{Y_{ij}} [1-p_{ij}(b)]^{1-Y_{ij}}\right\} h_i(T_i\mid b)^{\delta_i} \exp\left\{-\int_0^{T_i}h_i(u\mid b)\,du\right\} \phi_q(b;0,D)\,db. $$

Here \(p_{ij}(b)\) and \(h_i(t\mid b)\) are the longitudinal probability and hazard evaluated at the same candidate random-effects value \(b\), and \(\phi_q(b;0,D)\) is the multivariate normal density. For a censored subject, \(\delta_i=0\), so the event contribution is survival through \(T_i\), with no hazard multiplier. The population likelihood is the product of these subject contributions, or equivalently its log is the sum of their logarithms.

Key result: The marker and event contributions must be combined at the same value of \(b_i\) before integrating over its distribution. In general, integrating each contribution separately and multiplying the two marginal likelihoods is not equivalent: that would discard the dependence induced by the shared random effects.

This construction also explains why numerical integration is needed. The binary outcomes contribute Bernoulli probabilities, while the event term depends nonlinearly on \(b_i\) through the hazard and cumulative hazard. The integral is generally not available in closed form. Numerical integration approximates it; the accuracy of that approximation must be adequate for the number and dimension of the random effects.

Worked Example: Interpreting the Event Association

Suppose the event model has \(\alpha=(0.5,-0.3)^\mathsf{T}\). Compare two subjects with the same baseline event covariates, whose random effects are \(b_A=(0.4,-0.2)^\mathsf{T}\) and \(b_B=(-0.2,0.3)^\mathsf{T}\). Compute the conditional hazard ratio for A versus B.

Their random-effects difference is \(b_A-b_B=(0.6,-0.5)^\mathsf{T}\). Therefore,

$$ \alpha^\mathsf{T}(b_A-b_B) =0.5(0.6)+(-0.3)(-0.5) =0.30+0.15=0.45, \qquad HR_{A:B}=\exp(0.45)\approx 1.568. $$

At the same time and with the same baseline event covariates, the model’s conditional hazard for subject A is about 1.57 times that for subject B. The comparison is conditional on the stated random effects; it is not a population-average hazard ratio and is not a causal claim.

Worked Example: Combining Marker and Event Contributions

For illustration, consider a subject with two binary results \(Y_{i1}=1\) and \(Y_{i2}=0\). At one fixed random-effects value, suppose the model gives \(p_{i1}=0.25\), \(p_{i2}=0.60\), and a constant event hazard of \(0.08\) per year. The subject has an observed event at \(T_i=2.5\) years. Calculate the conditional likelihood contribution at this random-effects value.

The marker contribution is \(0.25^1(1-0.60)^1=0.25(0.40)=0.10\). With a constant hazard, the event contribution is \(0.08\exp\{-0.08(2.5)\}=0.08\exp(-0.2)\approx 0.06550\) per year. Multiplication gives

$$ L_i(b_i)=0.10(0.06550)\approx 0.006550\text{ per year}. $$

This is a conditional contribution, not the marginal likelihood contribution: it has not yet been averaged over \(b_i\). For example, a deliberately simplified two-point approximation with equal weights and conditional contributions \(0.006550\) and \(0.01235\) per year gives \(0.5(0.006550)+0.5(0.01235)=0.009450\) per year. Actual fitting integrates according to the specified random-effects distribution and uses a numerical approximation suitable for that distribution.

Derivation, Interpretation, and Practical Checks

The likelihood follows by conditioning first. Given \(b_i\), the Bernoulli observations have product likelihood \(\prod_{j\in J_i}p_{ij}^{Y_{ij}}(1-p_{ij})^{1-Y_{ij}}\). The event-time density contribution is \(h_i(T_i\mid b_i)^{\delta_i}S_i(T_i\mid b_i)\), where

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

Conditional independence makes the two contributions multiply. Since \(b_i\) is unobserved, average their product over its density. This gives the integral in the likelihood above. If instead one multiplied the separately averaged marker and event contributions, one would use the product of two integrals rather than the integral of the product. Those are generally different because both conditional contributions vary with \(b_i\).

The longitudinal fixed effects and spline coefficients describe the population pattern in log odds, subject to the chosen covariates and basis. The random effects describe deviations around that pattern. The event association parameter \(\alpha\) quantifies how those deviations relate to the hazard. For instance, if a component of \(b_i\) represents a higher subject-specific log-odds level and its corresponding association is positive, higher values of that component are associated with a higher conditional hazard, holding the other modeled terms fixed. Because the random effects can be correlated, interpretation of one component should acknowledge the model’s joint distribution.

Useful checks include comparing observed positive-result proportions over time with fitted probabilities, examining whether the fitted spline behaves plausibly over the observed assessment range, and checking that event-time residual diagnostics do not reveal substantial disagreement with the hazard model. Inspect convergence warnings, estimated random-effects variances and correlations, and sensitivity to reasonable integration accuracy settings. A near-zero estimated variance may indicate that a random component is unsupported; a boundary estimate or unstable covariance estimate can also make the association parameters difficult to estimate.

The spline is flexible but does not guarantee a good trajectory. Sparse measurements in parts of follow-up, very few positive or negative results, or near-separation can make spline coefficients unstable. Predictions beyond the observed time range deserve particular caution. If numerical integration changes materially when its accuracy is increased, the fitted likelihood and resulting inferences may not be reliable.

Alternatives and Limitations

A linear-time logistic mixed model is simpler and may be adequate when the log-odds trajectory is close to linear, but it cannot represent meaningful curvature without additional terms. A spline-based logistic model without an event submodel can describe the repeated binary outcomes but does not use the shared-effects structure to connect them with event risk. Conversely, fitting separate longitudinal and survival models does not account for dependence through latent subject characteristics. These alternatives answer different questions and rely on different assumptions.

Sharing random effects is also a modeling choice, not a universal description of dependence. The particular components placed in \(b_i\), and the form \(\alpha^\mathsf{T}b_i\), determine how the processes are linked. This model does not automatically make the hazard depend on the current fitted biomarker probability; that would be a different association structure. Nor does shared dependence alone correct bias from informative visit timing, misspecified censoring assumptions, or an inadequate baseline hazard. Model interpretation should therefore stay tied to the specified conditional structure.

Common pitfall: It is incorrect to read a spline coefficient as a change in biomarker probability, or to interpret \(\exp(\alpha_k)\) as a hazard ratio for a one-unit increase in the biomarker itself. Spline coefficients act on the log-odds scale through their basis functions, while \(\alpha\) acts on the specified random-effects scale. To interpret a probability, calculate the linear predictor and apply the logistic function; to interpret a conditional hazard ratio, compare the full random-effects vectors in the hazard model.

Check Your Understanding

Answer each question, then compare with the solutions below.

  1. In the longitudinal submodel, what does \(p_{ij}\) represent, and on what scale do the spline coefficients act?
  2. For a censored subject with \(\delta_i=0\), which event-time contribution remains in the likelihood?
  3. Suppose two otherwise identical subjects differ by \(b_A-b_B=(1,0)^\mathsf{T}\), and \(\alpha=(0.2,-0.4)^\mathsf{T}\). What is the conditional hazard ratio for A versus B?
  4. Why can the marginal marker likelihood and marginal event likelihood not generally be multiplied to obtain the joint contribution?

Solutions. (1) \(p_{ij}=P(Y_{ij}=1\mid b_i)\), the conditional probability of a positive result; the spline coefficients act on the log-odds scale. (2) The survival contribution \(\exp\{-\int_0^{T_i}h_i(u\mid b_i)\,du\}\) remains; there is no hazard multiplier when \(\delta_i=0\). (3) The log hazard ratio is \(\alpha^\mathsf{T}(b_A-b_B)=0.2\), so the ratio is \(\exp(0.2)\approx1.221\). (4) Both processes depend on the same unobserved \(b_i\). Their conditional contributions must be multiplied at a common \(b_i\), then integrated; multiplying separate integrals generally loses the dependence induced by \(b_i\).

Clinical Biostats