Tutorials › Generalized Linear Mixed Models (GLMM) › Time-Varying Predictors In GLMMs And GEE

GLMM Versus GEE · Tutorial 127 of 698

Time-Varying Predictors In GLMMs And GEE

You will learn to separate a time-varying predictor’s within-person and between-person associations, and interpret those associations in GLMMs and GEE.

Intermediate 11 min read

What You'll Learn

  • Decompose a time-varying predictor into a person-specific mean and a deviation from that mean.
  • Interpret within-person and between-person coefficients in conditional GLMMs.
  • Interpret the corresponding coefficients in population-averaged GEE mean models.
  • Calculate conditional and marginal odds ratios from hypothetical fitted models.
  • Recognize why using a time-varying predictor without this decomposition can obscure interpretation.
  • Identify practical limitations, including incomplete measurement and time-related confounding.

Why Separate Within-Person Change From Between-Person Differences?

A time-varying predictor is measured repeatedly on the same person: pain at each visit, weekly activity, or a patient’s current medication dose. Its values can differ both within a person over time and between people. Those are distinct comparisons. A person whose activity is usually high may differ from a person whose activity is usually low; separately, a person may have a different outcome at occasions when their activity is above their own usual level.

A model with only one coefficient for the raw predictor can blur these comparisons. A useful approach is to express each observation as a deviation from that person’s average and the person’s average itself. The resulting terms let the model estimate within-person and between-person associations separately. This distinction applies to both conditional GLMM mean models and population-averaged GEE mean models, though their coefficients refer to different estimands.

Definition: Let \(x_{it}\) be a time-varying predictor for person \(i\) at occasion \(t\), measured on \(n_i\) occasions. Define that person’s observed mean as \(\bar{x}_i = \frac{1}{n_i}\sum_{t=1}^{n_i}x_{it}\), and the within-person deviation as \(x_{it}^{W}=x_{it}-\bar{x}_i\). Then \(x_{it}=x_{it}^{W}+\bar{x}_i\). The deviation describes how far the current measurement is from that person’s observed mean; the mean describes their average level across observed occasions.

Two Terms, Two Comparisons

A common way to include a time-varying predictor is to put both components into the linear predictor. For example, a random-intercept GLMM can have conditional mean model

$$ g\!\left\{E(Y_{it}\mid b_i,\mathbf{x}_i)\right\} =\beta_0+\beta_W(x_{it}-\bar{x}_i)+\beta_B\bar{x}_i+b_i. $$

Here \(Y_{it}\) is the outcome, \(g\) is its link function, \(b_i\) is the person-specific random intercept, and \(\mathbf{x}_i\) denotes that person’s predictor history. The model also requires a specified response distribution and random-effects distribution. Its conditional mean interpretation assumes the chosen mean structure and link are appropriate; standard random-effects modeling also requires assumptions about the distribution of \(b_i\) and how it relates to the covariates. In this parameterization, \(\beta_W\) describes the association with being one unit above a person’s observed mean, conditional on the random effect and other included terms. \(\beta_B\) describes the association with a one-unit difference in the person-specific mean, comparing people at the same within-person deviation and other covariates.

In a GEE, the same decomposition can be used in a marginal mean model:

$$ g\!\left\{E(Y_{it}\mid \mathbf{x}_i)\right\} =\beta_0+\beta_W(x_{it}-\bar{x}_i)+\beta_B\bar{x}_i. $$

The predictor decomposition is the same, but the mean is population-averaged rather than conditional on a person-specific random effect. Thus, in a logistic model, \(\beta_W\) in a GLMM gives a conditional log-odds association, whereas \(\beta_W\) in a logistic GEE gives a population-averaged log-odds association. These coefficients need not be equal. The distinction between conditional and marginal estimands is essential when comparing the models.

The “within-person” label refers to the contrast represented by the deviation term, not a guarantee that the observed data isolate a causal effect. A causal interpretation would require additional design and identification assumptions. Time trends, treatment changes, measurement error, and time-varying confounders can all affect the association.

Worked Example: Decomposing Activity Measurements

Suppose three hypothetical people have activity scores measured on three occasions. Person A has scores 2, 4, and 6; Person B has 5, 5, and 8; and Person C has 8, 10, and 9. Find each person’s mean and deviations.

For Person A, \(\bar{x}_A=(2+4+6)/3=4\), so the deviations are \(2-4=-2\), \(4-4=0\), and \(6-4=2\). For Person B, \(\bar{x}_B=(5+5+8)/3=6\), giving deviations \(-1\), \(-1\), and \(2\). For Person C, \(\bar{x}_C=(8+10+9)/3=9\), giving deviations \(-1\), \(1\), and \(0\). Within each person, the deviations sum to zero, as they must when calculated from that person’s observed mean.

At Person A’s third occasion, the score is 6, the person-specific mean is 4, and the within-person deviation is 2: \(6=2+4\). This observation therefore contributes both a deviation of 2 and a between-person component of 4 to the model. The deviation and mean are not interchangeable measurements; they represent different comparisons.

How the Decomposition Changes Interpretation

To see why the two terms matter, consider a model with an identity link and a correctly specified additive mean:

$$ E(Y_{it}\mid x_{it},\bar{x}_i)=\beta_0+\beta_W(x_{it}-\bar{x}_i)+\beta_B\bar{x}_i. $$

At a fixed person-specific mean, a one-unit increase in the deviation changes the linear predictor by \(\beta_W\). At a fixed deviation, a one-unit increase in the person mean changes it by \(\beta_B\). For an identity link these changes are in outcome units. For a logit link, the changes are in log-odds units and exponentiating a coefficient gives the corresponding odds ratio. For a log link, exponentiating gives a rate ratio or mean ratio, as appropriate to the response model.

A model containing only \(x_{it}\) imposes a single slope on both dimensions of variation. In general, that restriction may be scientifically implausible. In a balanced dataset, the issue can be shown directly for an identity-link mean model. Write \(w_{it}=x_{it}-\bar{x}_i\), so \(x_{it}=w_{it}+\bar{x}_i\), and suppose the true mean is \(\beta_0+\beta_Ww_{it}+\beta_B\bar{x}_i\). If we regress the outcome on raw \(x_{it}\) alone, its population slope is

$$ \frac{\operatorname{Cov}(x,Y)}{\operatorname{Var}(x)} = \frac{\beta_W\operatorname{Var}(w)+\beta_B\operatorname{Var}(\bar{x})} {\operatorname{Var}(w)+\operatorname{Var}(\bar{x})}. $$

For this expression, assume equal numbers of observations per person, a mean-zero outcome error uncorrelated with the predictors, and use the pooled observation distribution. The within-person deviations sum to zero for every person, so they have zero pooled covariance with the person means: \(\operatorname{Cov}(w,\bar{x})=0\). Substituting \(x=w+\bar{x}\) and the stated mean into \(\operatorname{Cov}(x,Y)\) gives \(\beta_W\operatorname{Var}(w)+\beta_B\operatorname{Var}(\bar{x})\); the same decomposition gives \(\operatorname{Var}(x)=\operatorname{Var}(w)+\operatorname{Var}(\bar{x})\). The raw-predictor slope is therefore a variance-weighted combination of the two slopes, not necessarily either one. With unequal observation counts or a nonlinear link, that simple formula does not generally apply; the central point remains that a single raw-predictor coefficient does not separately identify the two associations.

Worked Example: Interpreting a Within-Person GLMM Coefficient

Suppose a hypothetical binary outcome is modeled with a random-intercept logistic GLMM:

$$ \operatorname{logit}\{P(Y_{it}=1\mid b_i,\mathbf{x}_i)\} =-1.00-0.35(x_{it}-\bar{x}_i)+0.20\bar{x}_i+b_i. $$

For a person whose mean activity score is 5, consider the conditional comparison between a deviation of 0 and a deviation of 1, holding \(b_i\) fixed. The change in conditional log odds is \(-0.35\), so the conditional odds ratio is \(\exp(-0.35)=0.705\). Thus, at an occasion when activity is one score unit above that person’s observed mean, the model estimates 0.705 times the conditional odds of the outcome compared with an occasion at that person’s mean, for the same random intercept and other covariates. This is an association, not by itself a causal effect.

For illustration, set \(b_i=0\). At deviation 0 and mean 5, the linear predictor is \(-1.00+0+0.20(5)=0\), giving probability \(1/(1+\exp(0))=0.500\). At deviation 1, the predictor is \(-0.35\), giving probability \(1/(1+\exp(0.35))\approx0.413\). The probability difference is about \(-0.087\), or 8.7 percentage points, for this specified conditional comparison. It is not a universal probability change: logistic probability differences depend on the starting predictor and random effect.

The between-person coefficient is different. A one-unit increase in mean activity, at a fixed within-person deviation, has conditional odds ratio \(\exp(0.20)=1.22\). This compares people with different average activity levels, not occasions when the same person’s activity changes.

For this interpretation to be meaningful, the hypothetical fitted model must use the stated link and adequately specified conditional mean; the random intercept and its distribution must also be appropriate for the intended conditional interpretation. The arithmetic illustrates the fitted model and does not establish that these assumptions hold in an actual dataset.

Worked Example: Interpreting a Population-Averaged GEE Coefficient

Suppose a hypothetical logistic GEE for the same type of binary outcome has fitted marginal mean

$$ \operatorname{logit}\{E(Y_{it}\mid\mathbf{x}_i)\} =-1.20+0.12(x_{it}-\bar{x}_i)+0.30\bar{x}_i. $$

The within-person marginal odds ratio is \(\exp(0.12)=1.128\). For occasions one activity-score unit above rather than at the person’s observed mean, the model estimates 1.128 times the population-averaged odds, at the same person mean and other covariates. This is an interpretation of the marginal mean model, not a subject-specific comparison conditional on \(b_i\).

For a person mean of 4 and deviation 0, the linear predictor is \(-1.20+0+0.30(4)=0\), so the fitted marginal probability is 0.500. At deviation 1 it is \(0.12\), giving probability \(1/(1+\exp(-0.12))\approx0.530\). The model’s predicted difference is about 0.030, or 3.0 percentage points, for this covariate profile. The between-person marginal odds ratio for a one-unit increase in mean activity is \(\exp(0.30)=1.35\). It describes a between-person contrast in the marginal mean model.

The GEE must have a suitable marginal mean specification for these interpretations. Its coefficient is not interchangeable with the GLMM coefficient in the preceding example: the GLMM conditions on a random effect, while the GEE models the population-averaged mean. The two examples are separate hypothetical fits, not estimates that should be expected to match.

Choosing an Approach and Checking the Analysis

The decomposition is a choice of predictor representation; it does not by itself choose between a GLMM and a GEE. A GLMM specifies a conditional response model with random effects and is useful when subject-specific conditional means are of interest and its random-effects assumptions are defensible. A GEE specifies a marginal mean model and is useful when the population-averaged mean is the target. Within either framework, including both the deviation and person mean answers a different question from using only the raw time-varying predictor.

Model term or approachPrimary comparisonInterpretation to keep in view
Within-person deviation \(x_{it}-\bar{x}_i\)Occasions above versus below a person’s observed meanConditional association in a GLMM; marginal association in a GEE
Person mean \(\bar{x}_i\)People with different observed average predictor levelsBetween-person association, conditional or marginal according to the model
Raw predictor \(x_{it}\) aloneCombines within-person and between-person variationA single slope does not generally reveal either component separately

Several checks help assess whether the representation is useful and credible:

  • Confirm that the predictor varies within people. If it is constant for every person, all deviations are zero and a within-person association cannot be estimated from that predictor.
  • Inspect the number and timing of measurements per person. A mean calculated from very few or unevenly timed observations may be a poor summary of a person’s usual level.
  • Check whether occasion or calendar-time effects are needed. If both the predictor and outcome trend over time, omitting time can make their association misleading.
  • Examine missingness and measurement quality. A mean based only on observed occasions may differ systematically from the intended long-term mean, especially if measurement or follow-up depends on a person’s condition.
  • Consider whether the predictor may respond to earlier outcomes or treatment. In that case, the fitted association does not automatically have a causal interpretation.

Centering around each person’s observed mean also has limitations. It can be sensitive to how many occasions are observed and to the observation schedule; it does not remove time-varying confounding or measurement error. A model with both components can estimate two associations, but it cannot guarantee that either is unbiased for a causal effect. The appropriate alternative depends on the scientific target: a raw predictor may be adequate if a common association is a justified modeling restriction, while a within-between decomposition is preferable when the two comparisons are substantively distinct.

A Common Interpretation Pitfall

A frequent mistake is to say, “The coefficient for activity shows what happens when a person becomes more active,” when the fitted model contains only raw activity. That coefficient can reflect both changes in activity within a person and persistent differences between people with different usual activity levels. The correction is to identify which terms the model includes and state the comparison each term represents. With both terms included, describe the deviation coefficient as the within-person association and the person-mean coefficient as the between-person association, while specifying whether the model is conditional or marginal.

Key takeaway: A time-varying predictor contains two kinds of information: how a person differs from their own observed mean, and how that mean differs across people. Include and interpret the two components separately when those comparisons matter; then distinguish conditional GLMM associations from population-averaged GEE associations.

Check Your Understanding

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

  1. A person’s predictor values are 3, 7, and 8. Find the observed mean and the three within-person deviations.
  2. A logistic GLMM has within-person coefficient \(-0.20\). What is the conditional odds ratio for a one-unit increase in the deviation, and what comparison does it represent?
  3. A fitted model includes only the raw time-varying predictor. Can its coefficient automatically be interpreted as a within-person association? Why or why not?
  4. In a logistic GEE, the within-person coefficient is \(0.10\). What is the population-averaged odds ratio for a one-unit increase in the deviation?

Solutions. (1) The mean is \((3+7+8)/3=6\), and the deviations are \(3-6=-3\), \(7-6=1\), and \(8-6=2\); they sum to zero. (2) The conditional odds ratio is \(\exp(-0.20)=0.819\). It compares occasions one unit apart in deviation, holding the random effect and other model terms fixed. (3) No. The raw predictor contains both within-person variation and between-person variation, so one coefficient does not generally separate their associations. (4) The population-averaged odds ratio is \(\exp(0.10)=1.105\), or about 1.11, for a one-unit increase in the deviation under the fitted marginal mean model.

Clinical Biostats