Tutorials › Generalized Linear Models › Time Trends in Repeated-Measure Means

Marginal Mean Models · Tutorial 824 of 981

Time Trends in Repeated-Measure Means

Learn to choose and interpret time effects that respect the measurement schedule and distinguish changes on the link scale from changes in the response mean.

Advanced 11 min read

What You'll Learn

  • Distinguish actual elapsed time from visit number when measurements are unequally spaced
  • Specify linear, categorical, and nonlinear time effects in a marginal mean model
  • Interpret fitted means and time contrasts on the link and response scales
  • Calculate average changes over intervals of different lengths
  • Recognize when a single time slope is an inappropriate summary

Why the Time Scale Matters

Repeated measurements are often taken at different intervals: a baseline assessment, a follow-up after two months, and another a year later. A model that uses visit numbers \(1,2,3\) treats each step as the same change in time, even though the elapsed intervals differ. That may be appropriate if the scientific question concerns differences between scheduled visits, but it is not automatically appropriate for a question about change per month or year.

A time effect is part of the marginal linear predictor: it describes how the modeled population-average mean changes with time, for specified values of other covariates. The key decisions are whether time should be represented by actual elapsed time, by visit categories, or by a flexible function of elapsed time, and whether the interpretation is on the link scale or the response scale.

Definition: Let \(Y_{ij}\) be the response for subject \(i\) at measurement \(j\), observed at elapsed time \(t_{ij}\), and let \(\mu_{ij}=E[Y_{ij}\mid X_{ij}]\) denote its covariate-conditional population-average mean. A time effect specifies how the linear predictor \(\eta_{ij}=g(\mu_{ij})\) depends on \(t_{ij}\), or on a categorical label for the measurement occasion. The time origin and unit must be stated: for example, months since enrollment, with enrollment coded \(t=0\).

The measurements within a subject may be correlated; the time-effect specification describes the mean pattern, not that dependence. For interpretation, hold any other covariates fixed at stated values. If the time pattern itself differs across covariate values, the model needs a corresponding interaction; here the focus is the basic time pattern.

Three Ways to Represent Time

With continuous linear time, the predictor contains an elapsed-time term such as \(\beta_1t_{ij}\). This assumes a constant change per unit time on the link scale. With categorical time, each scheduled occasion has its own mean, without requiring equal intervals or a straight-line trend. With a nonlinear time function, elapsed time enters through a curve, such as a polynomial or a chosen set of basis functions.

These are different assumptions, not merely different coding conventions. A linear effect uses the distances between measurement times; categorical time distinguishes occasions but does not use their elapsed-time distances to constrain the means. A nonlinear function uses elapsed time while allowing a specified degree of curvature or flexibility.

Worked Example: Categorical Means at Unequally Spaced Visits

Suppose a continuous outcome is measured at \(t=0\), \(t=2\), and \(t=5\) years. A categorical-time model with an identity link can be written

$$ \mu(t)=\alpha+\delta_2 I(t=2)+\delta_5 I(t=5). $$

Suppose the fitted coefficients are \(\hat\alpha=20\), \(\hat\delta_2=3\), and \(\hat\delta_5=1\). At baseline, both indicators are zero, so the fitted mean is \(20\). At year 2 it is \(20+3=23\), and at year 5 it is \(20+1=21\).

The change from baseline to year 2 is \(23-20=3\) outcome units over 2 years, an average change of \(3/2=1.5\) units per year over that interval. From year 2 to year 5, the change is \(21-23=-2\) units over 3 years, an average of \(-2/3\approx-0.667\) units per year. The categorical model does not require these interval rates to match: it estimates occasion-specific means rather than one common slope.

The model makes no prediction about the mean at year 1 unless an additional rule is supplied. Its fitted values apply to the modeled occasions; treating the time labels as categories does not define an interpolating curve.

Theorem: For \(K\) measurement occasions, a categorical-time model with an identity link and one reference occasion can represent any \(K\) fitted occasion means. In particular, if occasion 1 is the reference, set \(\mu_k=\alpha+\delta_k\) for \(k=2,\ldots,K\); then choosing \(\alpha=\mu_1\) and \(\delta_k=\mu_k-\mu_1\) reproduces all \(K\) means.

Proof. At the reference occasion all nonreference indicators equal zero, so the model mean is \(\alpha\). Setting \(\alpha=\mu_1\) gives the desired reference mean. At occasion \(k\), its indicator equals one and all other occasion indicators equal zero, so its model mean is \(\alpha+\delta_k\). Setting \(\delta_k=\mu_k-\mu_1\) yields \(\alpha+\delta_k=\mu_1+(\mu_k-\mu_1)=\mu_k\). Thus every specified vector of occasion means is represented. Conversely, the model has one coefficient for the reference mean and one difference for each other occasion, so it does not impose an equality or linear-trend constraint among those means. \(\square\)

Linear Time and the Meaning of a Slope

For a continuous linear time effect, write \(\eta(t)=a+bt\), holding other covariates fixed. The parameter \(b\) is the change in the linear predictor for a one-unit increase in elapsed time. The unit matters: if time is measured in years, \(b\) is a per-year link-scale change. For an identity link, the response mean itself changes linearly by \(b\) per unit time. For a nonlinear inverse link, the response-scale change generally depends on the starting time and the interval length.

Result: If \(\eta(t)=a+bt\), then for any two times \(t_1\) and \(t_2\), \(\eta(t_2)-\eta(t_1)=b(t_2-t_1)\). If \(\mu(t)=h(\eta(t))\), where \(h=g^{-1}\) is differentiable, the response-scale change is \(h(a+bt_2)-h(a+bt_1)\); when \(t_2\ne t_1\), its average rate per time unit is this difference divided by \(t_2-t_1\).

Derivation. Subtract the two linear predictors:

$$ \eta(t_2)-\eta(t_1)=(a+bt_2)-(a+bt_1)=b(t_2-t_1). $$

Applying \(h\) gives the two response means, whose difference is \(h(a+bt_2)-h(a+bt_1)\). Dividing by the elapsed interval gives the average response-scale rate. If \(h\) is differentiable, the instantaneous response-scale rate follows from the chain rule:

$$ \frac{d\mu(t)}{dt}=b\,h'(a+bt). $$

This derivative generally varies with \(t\), even though the link-scale slope \(b\) is constant. Thus, a linear time effect on the link scale should not be described as a constant response-scale change unless the link is the identity.

Worked Example: Linear Time with an Identity Link

Suppose the fitted marginal mean, in a continuous-outcome model with an identity link, is \(\hat\mu(t)=10+0.4t\), where \(t\) is years since baseline. Measurements occur at \(t=0\), \(t=2\), and \(t=5\).

The fitted means are \(\hat\mu(0)=10\), \(\hat\mu(2)=10+0.4(2)=10.8\), and \(\hat\mu(5)=10+0.4(5)=12\). The change from year 0 to year 2 is \(10.8-10=0.8\), or \(0.8/2=0.4\) units per year. From year 2 to year 5 it is \(12-10.8=1.2\), or \(1.2/3=0.4\) units per year.

The unequal intervals do not alter the fitted rate because the identity-link model specifies a constant response-scale slope. If the same times had instead been coded only as visit numbers, a one-unit visit effect would refer to moving from one occasion to the next, not to a fixed number of years.

Nonlinear Time Effects

A nonlinear time effect allows the rate of change to vary with elapsed time. One transparent option is a quadratic predictor, \(\eta(t)=\beta_0+\beta_1t+\beta_2t^2\). A nonzero \(\beta_2\) represents curvature on the link scale. More flexible specifications can use prespecified basis functions, for example \(\eta(t)=\beta_0+\sum_{r=1}^{R}\gamma_r B_r(t)\), where each \(B_r(t)\) is a known function of elapsed time. The coefficients describe the combined curve; in general, an individual basis coefficient is not itself a simple per-year mean change.

Worked Example: A Quadratic Trend over Irregular Intervals

Suppose an identity-link model has fitted mean \(\hat\mu(t)=12+0.5t-0.08t^2\), with time in years. For observations at \(t=0,1,3,5\), the fitted means are:

$$ \begin{aligned} \hat\mu(0)&=12,\\ \hat\mu(1)&=12+0.5-0.08=12.42,\\ \hat\mu(3)&=12+1.5-0.72=12.78,\\ \hat\mu(5)&=12+2.5-2=12.50. \end{aligned} $$

The average changes are \((12.42-12)/1=0.42\) units per year from year 0 to year 1; \((12.78-12.42)/2=0.18\) per year from year 1 to year 3; and \((12.50-12.78)/2=-0.14\) per year from year 3 to year 5. The fitted mean first rises and then falls. This is consistent with the instantaneous slope \(d\hat\mu(t)/dt=0.5-0.16t\), which is positive at \(t=1\) and negative at \(t=5\).

The curve is defined at times between the observed occasions, unlike a categorical-time specification, but its shape is constrained by the quadratic form. Extrapolation far beyond the observed time range also follows that same polynomial and may be scientifically implausible.

Worked Example: A Linear Logit Trend Is Not a Linear Probability Trend

For a binary outcome, suppose the fitted logit mean is \(\hat\eta(t)=-0.76+0.18t\), with \(t\) measured in years. The response-scale fitted mean is \(\hat\mu(t)=\operatorname{expit}(\hat\eta(t))=1/(1+\exp[-\hat\eta(t)])\). At year 1, \(\hat\eta(1)=-0.58\), and at year 3, \(\hat\eta(3)=-0.22\).

The fitted probabilities are \(\operatorname{expit}(-0.58)\approx0.3589\) and \(\operatorname{expit}(-0.22)\approx0.4452\). Thus, the response-scale change over the two-year interval is, using the unrounded values, \(\{\operatorname{expit}(-0.22)-\operatorname{expit}(-0.58)\}/2\approx0.04314\), or approximately \(0.0431\) per year. The logit-scale change per year is exactly \(0.18\), but that is not a probability change of \(0.18\) per year.

Rounding the two probabilities first and then subtracting can slightly change the final digits. The reported rate above is calculated from the unrounded fitted values, then rounded once.

Common Mistakes and Practical Choices

Choose a time representation to match the scientific question and measurement design. A categorical effect is useful when each scheduled visit is substantively distinct or when no simple time curve is justified. Continuous linear time is compact and directly interpretable when a constant link-scale rate is reasonable. A nonlinear function can capture curvature while retaining the information in elapsed-time distances.

  • Using visit number as elapsed time. Coding visits as 1, 2, and 3 imposes equal predictor steps. If the actual times are 0, 2, and 5 years, use those elapsed times for a rate-per-year interpretation.
  • Calling a link-scale coefficient a response-scale rate. With a nonlinear link, the response mean is transformed. Report fitted response means or an interval-specific response-scale change when that is the quantity of interest.
  • Reporting a change without its interval. A difference of 2 units over one year is not the same rate as 2 units over four years. State the time endpoints and divide by their actual separation if giving an average rate.
  • Assuming categorical time interpolates. Visit-specific fitted means do not specify a curve between visits. Do not infer an intermediate-time mean without an explicit model for it.
  • Ignoring the time origin and unit. A slope per month differs numerically from a slope per year. State the origin and units so coefficients and predictions are reproducible.
Key takeaway: Unequal spacing makes the distinction between elapsed time and visit category essential. State the time coding, interpret coefficients on their modeled scale, and calculate response-scale changes over the actual time interval.

Check Your Understanding

Use the time units and link scale explicitly in each answer.

  1. Measurements occur at 0, 1, and 4 years. What does a categorical-time model leave unconstrained that a linear elapsed-time model constrains?
  2. A fitted identity-link mean is \(8+0.3t\), with \(t\) in months. Find the fitted means at months 2 and 10 and the average change per month between them.
  3. A model has a linear time effect on the logit scale. Is its probability-scale change per year necessarily constant? Explain.
  4. For a categorical-time model, fitted means are 15 at year 1 and 18 at year 4. Calculate the average change per year over that interval.
  5. Why should a quadratic time curve be interpreted cautiously when predicting far beyond the observed time range?
Clinical Biostats