Why slopes and cumulative exposure require the fitted trajectory
In a joint model, the longitudinal component describes how a subject’s underlying biomarker changes over time. A fitted value at one time describes the trajectory’s level; its derivative describes its instantaneous rate of change; and its integral over an interval summarizes accumulated exposure. These are related summaries, but they answer different questions. A subject can have a high biomarker level and a decreasing slope, for example, while still having a large cumulative exposure.
For a spline trajectory, the calculations are defined by the fitted function, not by connecting the observed measurements with straight lines. This matters because the fitted spline can be smooth between observations and can incorporate subject-specific random effects. Taking differences of noisy measurements can produce a very different estimate of change.
If the biomarker is measured in units \(U\) and time in years, then \(m_i(t)\) has units \(U\), \(m_i'(t)\) has units \(U\) per year, and cumulative exposure has units \(U\)-years. Average exposure has the same units as the biomarker. These unit checks are useful safeguards against calculation errors.
Calculating from a spline representation
Write the subject-specific trajectory as a linear combination of spline basis functions:
where \(\mathbf{s}(t)\) is a vector of basis functions and \(\mathbf{a}_i\) is the corresponding vector of coefficients for subject \(i\). In a random-effects representation, these coefficients combine population coefficients and subject-specific random effects. Once the coefficients are specified, differentiating and integrating the trajectory means differentiating and integrating each basis function.
These expressions assume the fitted coefficients are held fixed for the subject-specific calculation. They also require the spline to be differentiable at the time where a slope is requested. A spline may have different smoothness at its knots depending on its degree and construction. For a piecewise-defined spline, calculate the derivative within each interval and check the behavior at the boundaries. A continuous trajectory need not have a continuous derivative unless the spline construction imposes that condition.
A useful special case is the truncated-power term \((t-\kappa)_+^q\), where \((x)_+=\max(x,0)\), \(\kappa\) is a knot, and \(q\) is a positive integer. Away from the knot, differentiation gives:
For \(q=1\), the derivative is 0 to the left of the knot and 1 to the right, and is not defined at the knot. For \(q>1\), the derivative at the knot exists and is 0. Integration follows directly by integrating the polynomial on the portion of the interval after the knot:
This identity also handles intervals entirely before the knot: both positive-part terms are zero. If an interval crosses a knot, the same expression accounts for the portion after it. With a general piecewise-polynomial basis, an equivalent reliable approach is to split the integral at every knot and integrate the relevant polynomial on each resulting interval.
Worked Example: Slope at and after an Interior Knot
Suppose a hypothetical fitted trajectory, with time measured in years and biomarker values in units \(U\), is \(m_i(t)=8+1.5t-0.4t^2+0.2(t-3)_+^2\). Calculate the subject’s slope at \(t=3\) and at \(t=5\).
Differentiate the polynomial terms and the truncated quadratic term. Since its exponent is 2, the latter has derivative \(0.4(t-3)_+\). Thus \(m_i'(t)=1.5-0.8t+0.4(t-3)_+\). The derivative exists at the knot because the truncated quadratic has derivative 0 there.
At \(t=3\), the positive-part term is \((3-3)_+=0\), so \(m_i'(3)=1.5-0.8(3)+0.4(0)=1.5-2.4=-0.9\) \(U\) per year. At \(t=5\), \((5-3)_+=2\), so \(m_i'(5)=1.5-0.8(5)+0.4(2)=1.5-4+0.8=-1.7\) \(U\) per year.
The fitted trajectory is decreasing at both requested times, with a more negative instantaneous slope at year 5. This conclusion concerns the derivative of the fitted trajectory, not the difference between two observed biomarker measurements.
From the trajectory to cumulative exposure
Cumulative exposure is the area under the fitted trajectory over a specified time interval. It depends on both the biomarker level and the duration of follow-up. Therefore, always state the integration limits, and do not compare cumulative exposures from different follow-up durations without accounting for that difference. Average exposure divides the area by the interval length and can be easier to compare when interval lengths differ.
Worked Example: Exact Exposure Across a Knot
For a hypothetical biomarker trajectory \(m_i(t)=10+2t-0.5(t-2)_+^2\), calculate cumulative and average exposure from year 0 to year 5. Assume the fitted trajectory is used throughout this interval and time is measured in years.
Integrate each term. The constant contributes \(10(5)=50\), and \(2t\) contributes \(2(5^2/2)=25\). The truncated quadratic contributes only after the knot at year 2. Using the truncated-power integral, \(\int_0^5(u-2)_+^2\,du=(5-2)^3/3=27/3=9\). Therefore, \(\int_0^5m_i(u)\,du=50+25-0.5(9)=75-4.5=70.5\) \(U\)-years.
The interval length is \(5-0=5\) years, so average exposure is \(70.5/5=14.1\) \(U\). The cumulative value describes total fitted exposure across the five years; the average is the mean fitted level over those years.
The integral can also be written as a linear function of the spline coefficients. Define the integrated basis vector \(\mathbf{S}_{a,T}=\int_a^T\mathbf{s}(u)\,du\). Then the cumulative exposure is \(\mathbf{S}_{a,T}^{\mathsf T}\mathbf{a}_i\). This makes the calculation convenient in software and clarifies how subject-specific random effects affect the summary: their coefficients contribute through the same integrated basis terms as the fixed coefficients.
Worked Example: Subject-Specific Slopes and Exposures
Consider the hypothetical random-effects trajectory \(m_i(t)=9+(1+b_i)t-0.25(t-2)_+^2\), where \(b_i\) is a subject-specific random slope coefficient. Take \(b_A=0.4\) for subject A and \(b_B=-0.2\) for subject B. Calculate both slopes at year 3 and cumulative exposures from year 0 through year 4.
Differentiation gives \(m_i'(t)=1+b_i-0.5(t-2)_+\). At year 3, \((3-2)_+=1\). Subject A’s slope is \(1+0.4-0.5(1)=0.9\) \(U\) per year; subject B’s is \(1-0.2-0.5(1)=0.3\) \(U\) per year.
For exposure, the intercept contributes \(9(4)=36\). The linear term contributes \((1+b_i)\int_0^4u\,du=(1+b_i)(4^2/2)=8(1+b_i)\). The truncated quadratic contributes \(-0.25\int_0^4(u-2)_+^2\,du=-0.25(4-2)^3/3=-0.25(8/3)=-2/3\). Thus subject A’s exposure is \(36+8(1.4)-2/3=46.533\) \(U\)-years, and subject B’s is \(36+8(0.8)-2/3=41.733\) \(U\)-years.
Their average exposures over four years are \(46.533/4=11.633\) \(U\) for A and \(41.733/4=10.433\) \(U\) for B. The differing values arise from the subject-specific random slope coefficients, while the same knot and quadratic term affect both trajectories.
Why these calculations are valid—and what they assume
The calculations above follow from linearity: a finite linear combination of differentiable basis functions can be differentiated term by term, and a finite linear combination of integrable basis functions can be integrated term by term. For the truncated-power basis, the derivative and integral are ordinary polynomial calculations on either side of the knot. As a result, the slope and exposure are exact for the stated fitted function, apart from rounding.
Use the subject’s estimated coefficient values, including the relevant random effects, and state the time and biomarker units.
Differentiate each basis term, then substitute the requested time. Check whether that time is a knot and whether the derivative exists there.
Integrate each term over the requested interval, splitting at knots if using piecewise polynomials, then add the contributions.
Report slope in biomarker units per time unit and cumulative exposure in biomarker units times time. Divide by interval length only when reporting average exposure.
These summaries inherit the assumptions and limitations of the fitted trajectory. In particular, the spline form and knot locations determine the shape between observations; estimates near boundaries may be especially sensitive to the fitted form. The calculations also treat the estimated coefficients as fixed. In practice, coefficient estimates are uncertain, so reported slopes and exposures should not be presented as if known exactly when inferential uncertainty matters.
For a linear summary \(g_i=\mathbf{c}^{\mathsf T}\mathbf{a}_i\), such as a slope at a fixed time or an integrated exposure, uncertainty can be propagated from the coefficient covariance matrix \(\mathbf{V}_i\) using \(\operatorname{Var}(g_i)=\mathbf{c}^{\mathsf T}\mathbf{V}_i\mathbf{c}\), when that covariance is available and the summary is linear in the coefficients. Here \(\mathbf{c}=\mathbf{s}'(t)\) for a slope and \(\mathbf{c}=\mathbf{S}_{a,T}\) for cumulative exposure. This calculation does not remove uncertainty from model specification or from estimated random effects; it quantifies coefficient uncertainty under the fitted model.
Diagnostics, alternatives, and common pitfalls
A strong check is to compare an analytic derivative or integral with a numerical calculation from the same fitted function. For a derivative at an interior point, a centered finite difference \(\{m_i(t+h)-m_i(t-h)\}/(2h)\) should approach the analytic derivative as \(h\) becomes small, provided the function is smooth around \(t\). For integration, numerical quadrature over the same limits should agree with the exact integral to the chosen numerical tolerance. These checks can reveal coding mistakes, but the finite-difference or quadrature result is an approximation rather than a replacement for an available exact calculation.
If the derivative is requested at a knot, inspect the spline’s continuity there. For example, the first derivative of a truncated linear term has a jump at its knot, so there is no single two-sided derivative at that point. By contrast, a truncated quadratic term has a continuous first derivative there. Do not report a unique slope at a knot unless the model’s basis ensures that the derivative exists.
The principal alternative to differentiating the fitted trajectory is to estimate change from nearby observed values. That approach can be useful descriptively, but it is sensitive to measurement error, visit spacing, and the choice of observations. It does not generally estimate the derivative of the fitted subject-specific trajectory. Similarly, summing observed biomarker values is not an area-under-the-trajectory calculation unless the time spacing and numerical integration rule are explicitly accounted for.
- Wrong: “The cumulative exposure is the fitted value at the final visit multiplied by follow-up time.” Correction: Exposure is the integral over the whole trajectory; the final value alone cannot determine the area.
- Wrong: “The slope is the difference between any two observed measurements divided by their time gap.” Correction: That is a finite difference of observations, not necessarily the derivative of the fitted trajectory.
- Wrong: “A cumulative exposure of 70.5 has the same units as the biomarker.” Correction: If time is in years, the units are \(U\)-years; dividing by duration gives average exposure in \(U\).
- Wrong: “The spline derivative is automatically defined at every knot.” Correction: Check the spline’s smoothness and the particular basis term at that knot.
In joint modeling, slopes and cumulative exposure can serve as scientifically meaningful summaries of a fitted longitudinal process. They can also help describe how an individual’s trajectory changes over a specified interval. Their interpretation depends on the interval, time scale, biomarker scale, and model used; none of these summaries by itself establishes a causal effect on an event outcome.
Check Your Understanding
Work through each question, then compare with the concise solutions below.
- For \(m(t)=4+3t-0.2(t-5)_+^2\), calculate the slope at \(t=5\) and \(t=7\). What are the slope units if \(m(t)\) is measured in \(U\) and time in months?
- For \(m(t)=6+t\), calculate cumulative and average exposure from \(t=0\) to \(t=3\).
- Why can the derivative of a fitted spline at a knot fail to exist, even when the trajectory itself is continuous?
- A numerical integral and an analytic integral differ slightly. Name two checks that help determine whether this is a coding problem or ordinary numerical approximation error.
Solutions. For question 1, \(m'(t)=3-0.4(t-5)_+\). At \(t=5\), the slope is \(3\) \(U\) per month; at \(t=7\), it is \(3-0.4(2)=2.2\) \(U\) per month. For question 2, \(\int_0^3(6+t)\,dt=6(3)+3^2/2=18+4.5=22.5\) \(U\)-time units, and the average exposure is \(22.5/3=7.5\) \(U\). For question 3, continuity of the function does not guarantee matching left- and right-hand derivatives; a truncated linear term, for example, has a derivative jump at its knot. For question 4, verify the same limits and coefficient values are used in both calculations, and refine the quadrature grid or tolerance. Also check that the analytic calculation splits correctly at knots and that the numerical routine evaluates the intended fitted function.