Tutorials › Joint Modeling of Longitudinal and Time-to-Event Data › Polynomial Time Effects

Mixed Models Review · Tutorial 84 of 697

Polynomial Time Effects

Learn to specify and interpret a quadratic time effect in a mixed model, calculate fitted biomarker values at selected times, and evaluate changes using both time coefficients.

Intermediate 11 min read

What You'll Learn

  • Specify a quadratic fixed time effect alongside subject-specific random intercepts and slopes.
  • Interpret the linear coefficient as the slope at the chosen time origin and the quadratic coefficient as curvature.
  • Calculate fitted values and changes between follow-up times.
  • Account for covariance between coefficient estimates when estimating uncertainty in a change.
  • Distinguish tests of curvature from joint tests of all time effects.
  • Recognize when a quadratic trajectory is poorly supported or used beyond its observed time range.

Why Model a Curved Time Trend?

A biomarker may rise quickly after baseline and then level off, or decline gradually and then more sharply. A straight-line time effect cannot represent that changing rate of change. A quadratic time term adds curvature with one additional fixed-effect coefficient, making it a simple extension of the linear mixed models used for repeated measurements.

The quadratic model does not imply that every participant follows the same curve. It describes the population-average mean trajectory through its fixed effects, while random effects can allow participants to have different starting values and rates of change. The subject-specific interpretation and predictions follow the earlier material on random slopes and population-average versus subject-specific predictions.

Definition: Let \(Y_{ij}\) be the biomarker measurement for subject \(i\) at follow-up time \(t_{ij}\), measured from a chosen time origin. A quadratic-time linear mixed model with random intercepts and slopes is
$$ Y_{ij}=\beta_0+\beta_1t_{ij}+\beta_2t_{ij}^2+b_{0i}+b_{1i}t_{ij}+\varepsilon_{ij}. $$
Here \(\beta_0,\beta_1,\beta_2\) are fixed effects; \(b_{0i}\) and \(b_{1i}\) are subject-specific random effects; and \(\varepsilon_{ij}\) is the residual. The population-average mean at time \(t\) is \(m(t)=\beta_0+\beta_1t+\beta_2t^2\), because the random effects have mean zero.

The conventional assumptions are that subjects are independent; the random-effects vectors have mean zero and a common covariance matrix \(D\); and, conditional on those random effects, the residuals have mean zero and a specified within-subject covariance matrix \(R_i\). Random effects and residuals are independent. Gaussian random effects and residuals are often assumed for likelihood-based estimation and inference, though the mean interpretation itself follows from their zero means. The selected mean curve must also be a reasonable description over the time range being interpreted. The covariance of repeated measurements is a separate modeling choice.

The fixed quadratic term does not require a random quadratic effect. In the model above, subjects may differ in their intercepts and linear slopes, while the population curvature is represented by \(\beta_2\). Adding subject-specific curvature is a more complex model and requires enough repeated information to estimate that extra variation reliably.

What the Coefficients Mean Together

The linear coefficient is not generally the rate of change at every time. Differentiating the population mean gives the instantaneous slope \(\frac{d m(t)}{dt}=\beta_1+2\beta_2t\). Thus \(\beta_1\) is the slope at the time origin \(t=0\), and \(2\beta_2\) is the change in slope per unit of time. The second derivative is \(2\beta_2\): a negative \(\beta_2\) gives downward curvature, and a positive \(\beta_2\) gives upward curvature.

To describe change over an interval, use both time coefficients. For times \(t_a\) and \(t_b\), the population-average mean change is \(\Delta=m(t_b)-m(t_a)=\beta_1(t_b-t_a)+\beta_2(t_b^2-t_a^2)\). This is often more directly useful than interpreting either coefficient alone. If the model includes baseline covariates or treatment interactions, the relevant change can also depend on those terms; the formula must then be derived from the mean curve for the group or covariate values of interest.

Worked Example: Fitted Values and Changing Slope

Hypothetical data and model. Suppose a fitted population-average model for a biomarker, in mg/L, uses time in months since baseline and has estimates \(\hat\beta_0=12.0\) mg/L, \(\hat\beta_1=1.8\) mg/L per month, and \(\hat\beta_2=-0.15\) mg/L per month squared. Assume the quadratic mean is an appropriate description over the 0-to-4-month period considered here.

The fitted mean at time \(t\) is \(\hat m(t)=12.0+1.8t-0.15t^2\). At baseline it is \(\hat m(0)=12.0+1.8(0)-0.15(0^2)=12.0\) mg/L. At 2 months, \(\hat m(2)=12.0+1.8(2)-0.15(2^2)=12.0+3.6-0.6=15.0\) mg/L. At 4 months, \(\hat m(4)=12.0+1.8(4)-0.15(4^2)=12.0+7.2-2.4=16.8\) mg/L.

The model-estimated change from baseline to 4 months is \(16.8-12.0=4.8\) mg/L. The instantaneous slope at baseline is \(1.8\) mg/L per month, while at 4 months it is \(1.8+2(-0.15)(4)=0.6\) mg/L per month. The fitted trajectory is still increasing at 4 months, but its rate of increase has slowed. These are population-average fitted values; a subject-specific prediction would also include estimated subject effects.

Changes and Their Uncertainty

When estimating a change, the uncertainty in both time coefficients matters, including their covariance. Write the change as a linear combination \(L=c_1\beta_1+c_2\beta_2\), where \(c_1=t_b-t_a\) and \(c_2=t_b^2-t_a^2\). If the estimated covariance matrix of \((\hat\beta_1,\hat\beta_2)\) is \(V\), then \(SE(\hat L)=\sqrt{c^\mathsf{T}Vc}\), where \(c=(c_1,c_2)^\mathsf{T}\). Omitting the covariance term can materially misstate the standard error.

Worked Example: A Change From Month 1 to Month 5

Hypothetical estimates. Suppose time is measured in months, \(\hat\beta_1=0.90\) mg/L per month and \(\hat\beta_2=-0.10\) mg/L per month squared. Suppose the estimated variances are \(\operatorname{Var}(\hat\beta_1)=0.0400\), \(\operatorname{Var}(\hat\beta_2)=0.000400\), and the covariance is \(\operatorname{Cov}(\hat\beta_1,\hat\beta_2)=-0.00200\), in the corresponding units. Assume the model is adequate for months 1 through 5 and use a normal-approximation 95% confidence interval.

The estimated change from month 1 to month 5 is \(\hat L=(5-1)\hat\beta_1+(5^2-1^2)\hat\beta_2=4(0.90)+24(-0.10)=3.60-2.40=1.20\) mg/L.

Here \(c_1=4\) and \(c_2=24\). Therefore, \(\operatorname{Var}(\hat L)=4^2(0.0400)+24^2(0.000400)+2(4)(24)(-0.00200)=0.6400+0.2304-0.3840=0.4864\). Thus \(SE(\hat L)=\sqrt{0.4864}\approx0.6974\) mg/L. The approximate interval is \(1.20\pm1.96(0.6974)=1.20\pm1.367\), or \((-0.1669,\ 2.567)\) mg/L.

Under the stated model and normal approximation, this 95% confidence interval describes the uncertainty of the estimated population-average change from month 1 to month 5. Since it includes zero, these data do not establish a nonzero change at the corresponding two-sided 5% level. This conclusion is about the interval for this particular change, not a claim that the probability the fixed, unknown change lies in this computed interval is 95%.

Derivation, Tests, and Choice of Time Origin

The change formula follows directly by subtracting the two fitted means. At \(t_b\), \(m(t_b)=\beta_0+\beta_1t_b+\beta_2t_b^2\); at \(t_a\), \(m(t_a)=\beta_0+\beta_1t_a+\beta_2t_a^2\). Subtraction cancels the intercept and leaves \(\Delta=\beta_1(t_b-t_a)+\beta_2(t_b^2-t_a^2)\). For any linear combination of estimated coefficients, its variance is obtained by multiplying the coefficient vector on both sides of the covariance matrix: \(\operatorname{Var}(c^\mathsf{T}\hat\beta)=c^\mathsf{T}Vc\). With two terms this expands to \(c_1^2\operatorname{Var}(\hat\beta_1)+c_2^2\operatorname{Var}(\hat\beta_2)+2c_1c_2\operatorname{Cov}(\hat\beta_1,\hat\beta_2)\), as used above.

A test of \(H_0:\beta_2=0\) addresses whether the quadratic component improves on a linear time mean, conditional on the other included fixed effects and the chosen covariance model. It is different from the joint test \(H_0:\beta_1=\beta_2=0\), which asks whether there is any linear or quadratic time association. Keeping the linear term when the quadratic term is included preserves the usual hierarchical polynomial specification and makes the curvature term interpretable independently of the slope at the origin.

Worked Example: Testing the Time Terms Jointly

Hypothetical estimates. Suppose \(\hat\beta_1=1.20\) mg/L per month and \(\hat\beta_2=-0.0800\) mg/L per month squared. For illustration, suppose their estimated covariance matrix is \(\hat V=\begin{pmatrix}0.0900&-0.00600\\-0.00600&0.000900\end{pmatrix}\), with entries in the corresponding units. Assume a large-sample Wald test is justified.

The joint Wald statistic for \(H_0:\beta_1=\beta_2=0\) is \(W=\hat\beta^\mathsf{T}\hat V^{-1}\hat\beta\), where \(\hat\beta=(1.20,-0.0800)^\mathsf{T}\). The determinant of \(\hat V\) is \(0.0900(0.000900)-(-0.00600)^2=0.0000450\), so \(\hat V^{-1}=\begin{pmatrix}20.0&133.333\\133.333&2000\end{pmatrix}\). Hence \(W=20.0(1.20^2)+2(133.333)(1.20)(-0.0800)+2000(-0.0800)^2=28.8-25.6+12.8=16.0\).

Under the null and the stated large-sample approximation, \(W\) is compared with a chi-squared distribution with 2 degrees of freedom. The upper-tail p-value is \(P(\chi^2_2\ge16.0)=e^{-16.0/2}\approx0.0003355\). This is evidence against the joint null that both time coefficients are zero. It does not by itself establish that the quadratic coefficient is nonzero; that question requires a test or interval for \(\beta_2\).

Changing the time origin changes the intercept and linear coefficient, but not the fitted curve or the quadratic coefficient. If \(s=t-c\), then \(t=s+c\), and substituting gives \(m(t)=(\beta_0+c\beta_1+c^2\beta_2)+(\beta_1+2c\beta_2)s+\beta_2s^2\). Centering time at a clinically relevant visit can therefore make the intercept and linear coefficient more interpretable: the new intercept is the mean at \(t=c\), and the new linear coefficient is the slope there. Coefficient interpretations must always state the time origin and time units.

Diagnostics, Alternatives, and Limitations

A quadratic curve is parsimonious, but its mathematical shape should not be mistaken for evidence that the biology follows a quadratic process. Before interpreting it, check that the time scale and origin are appropriate, that the observed times support the part of the curve being discussed, and that the fixed-effect mean does not show an obvious systematic pattern when compared with the observed trajectories or residual summaries. Large departures at early or late visits, or repeated residual patterns over time, can indicate a poor mean specification or a covariance model that does not adequately represent dependence. Detailed residual diagnostics and choices among within-subject residual correlation structures are separate topics.

A straight-line model is simpler and may be adequate when the rate of change is roughly constant. Treating visit as categorical allows each visit to have a separate mean without imposing a polynomial shape, but uses more parameters and does not provide a smooth trajectory between visits. More flexible smooth curves can represent shapes that a quadratic cannot, but need additional modeling choices and data. The useful comparison is not simply which model has a significant coefficient: assess scientific plausibility, fit over the observed time range, and uncertainty in the contrasts of interest.

Quadratics can turn sharply outside the data range, so a fitted turning point should not be presented as a meaningful future prediction unless that region is supported by data and subject-matter reasoning. If \(\beta_2\ne0\), the stationary time is \(-\beta_1/(2\beta_2)\); whether it is a maximum or minimum depends on the sign of \(\beta_2\). Uncertainty in the coefficients also means that this estimated turning point can be unstable, especially when curvature is weak. A coefficient's p-value alone does not establish that the fitted curvature is practically important.

Common pitfall: It is incorrect to interpret \(\beta_1\) as the biomarker's rate of change throughout follow-up. In a quadratic model, the slope at time \(t\) is \(\beta_1+2\beta_2t\), so \(\beta_1\) is the slope only at \(t=0\). To report a change over an interval, combine both terms as \(\beta_1(t_b-t_a)+\beta_2(t_b^2-t_a^2)\), and account for their covariance when quantifying uncertainty.

Check Your Understanding

Answer each question using the stated model and units. Brief solutions follow.

  1. For \(m(t)=10+2t-0.25t^2\), with time in months and the mean in mg/L, calculate the fitted mean at month 4 and the instantaneous slope at month 4.
  2. If time is recentered as \(s=t-3\), what are the new linear and quadratic coefficients in terms of \(\beta_1\) and \(\beta_2\)?
  3. For \(\hat\beta_1=0.70\) mg/L per month and \(\hat\beta_2=-0.050\) mg/L per month squared, calculate the fitted mean change from month 2 to month 5.
  4. What does a joint test of \(H_0:\beta_1=\beta_2=0\) assess, and why is it not the same as testing \(H_0:\beta_2=0\)?

Solutions. (1) \(m(4)=10+2(4)-0.25(16)=14\) mg/L; the slope is \(2+2(-0.25)(4)=0\) mg/L per month. (2) Substitution gives the new linear coefficient \(\beta_1+6\beta_2\) and quadratic coefficient \(\beta_2\). (3) The change is \(3(0.70)+(25-4)(-0.050)=2.10-1.05=1.05\) mg/L. (4) The joint test asks whether both time terms are zero, meaning no linear or quadratic time association in the specified mean. Testing \(\beta_2=0\) asks specifically whether curvature is needed while allowing a linear time effect.

Clinical Biostats