Why Separate Within-Cluster and Between-Cluster Associations?
A time-varying covariate can differ both across observations in the same cluster and between clusters. For example, a patient’s activity level may vary across visits, while some patients are generally more active than others. The association between a patient being more active than usual and an outcome need not match the association between patients who are generally more active and those who are less active. Treating these as one association can obscure meaningful differences.
The distinction is about the covariate and its comparison, not by itself about causation. A within-cluster association compares observations from the same cluster at different covariate values. A between-cluster association compares clusters with different average covariate values. Both may reflect confounding or other features of the data; neither is automatically a causal effect.
Here, \(i\) might index a patient and \(j\) a visit, or \(i\) a school and \(j\) a student. The cluster mean should be calculated over the observations defined for the analysis. If clusters have unequal numbers of observations, the observation-weighted grand mean and the equally weighted mean of cluster means generally differ. Centering the cluster means changes the intercept, but not the meaning of a one-unit within-cluster contrast or the slope for the between-cluster component.
Worked Example: Decomposing a Covariate
Consider hypothetical measurements of weekly activity (in hours) at three visits for each of two patients. Patient A has \(X_{Aj}=2,4,6\); Patient B has \(X_{Bj}=5,5,8\). Compute the cluster means and within-cluster deviations.
For Patient A, \(\bar X_A=(2+4+6)/3=4\), giving deviations \(-2,0,2\) hours. For Patient B, \(\bar X_B=(5+5+8)/3=6\), giving deviations \(-1,-1,2\) hours. Each observed value is the sum of its deviation and its patient’s mean; for example, Patient B’s value of 8 is \(2+6\).
The overall observation-weighted mean is \(\bar X=(2+4+6+5+5+8)/6=5\) hours. The centered between-cluster components are therefore \(\bar X_A-\bar X=-1\) and \(\bar X_B-\bar X=1\) hour. Patient B has a higher average activity level, while the deviations describe whether a particular visit was above or below that patient’s own average.
Modeling the Two Components
A general within-between mean model includes both components as separate predictors. For a GLMM with a random intercept \(b_i\), one possible specification is
Here \(g\) is the response’s link function, \(\beta_W\) is the within-cluster coefficient, and \(\beta_B\) is the between-cluster coefficient. Under the usual random-intercept formulation, the model specifies a distribution for \(b_i\), commonly with mean zero, and assumes that clusters are independent conditional on the model. For the standard interpretation of the conditional model, the random effects are taken to be independent of the covariates. The response distribution and link must be suitable for the outcome, and the conditional mean model must be adequately specified.
The corresponding GEE mean model can use the same decomposition:
The GEE coefficients describe the specified population-averaged mean, rather than a mean conditional on a random effect. The mean structure must be appropriate for the response and covariates, and clusters must be independent for standard large-sample GEE inference. The working correlation concerns dependence among observations within clusters; it does not replace the choice to include separate within- and between-cluster covariates. In general, GLMM and GEE coefficients need not be numerically equal, particularly with nonlinear links.
Why a Single Slope Can Be Misleading
A single-slope model that uses \(X_{ij}\) alone imposes a particular restriction: the within- and between-cluster components have the same coefficient on the linear predictor. To see this, start with separate coefficients and use \(X_{ij}=(X_{ij}-\bar X_i)+\bar X_i\). If the cluster mean is uncentered, the linear predictor terms are
Thus, a model containing only \(\beta X_{ij}\) requires \(\beta_W=\beta_B=\beta\). If the two associations differ, that restriction can hide the difference and make the single coefficient hard to interpret. With an identity link and a fitted linear model, the coefficient from a model using only \(X_{ij}\) can reflect both sources of variation. For nonlinear links and correlated observations, its exact relationship to the separate-component coefficients depends on the model and estimation procedure; it should not be treated as a simple average.
The difference \(\beta_B-\beta_W\) is sometimes called a contextual contrast. On the linear-predictor scale, it compares the between-cluster coefficient with the within-cluster coefficient. Its interpretation depends on the comparison being made and the model specification; it is not automatically a causal “contextual effect.”
Worked Example: Interpreting Separate Coefficients in a Linear Mean Model
Suppose a hypothetical identity-link model for a score (points) is
The covariate is activity in hours per week. The within-cluster coefficient is 1.5 points per additional hour relative to the same person’s average activity, at a fixed between-cluster component. The between-cluster coefficient is 0.8 points per hour for a one-hour difference in average activity between clusters, at a fixed within-cluster deviation.
For Patient B in the previous example, at the visit with \(X_{Bj}=8\), the deviation is \(8-6=2\) hours and the centered cluster mean is \(6-5=1\) hour. Substitution gives
For a one-hour increase in the cluster mean while holding the within-cluster deviation fixed, the model changes by 0.8 points. The within coefficient is different: a one-hour increase in deviation while holding the cluster mean fixed changes the modeled mean by 1.5 points. The contextual contrast is \(0.8-1.5=-0.7\) points per hour on this model’s linear scale. These are modeled associations, not evidence that changing activity will cause the score to change.
Worked Example: Conditional GLMM Coefficients and Probabilities
Suppose a hypothetical random-intercept logistic GLMM for a binary outcome has fixed coefficients \(\beta_0=-1.2\), \(\beta_W=0.8\), and \(\beta_B=0.5\), with the cluster mean centered at 5 hours per week. For illustration, take a cluster with \(b_i=0\), a visit at the cluster mean, and a centered cluster mean of zero. Its linear predictor is \(-1.2\), so its conditional probability is
This is a probability conditional on the stated random effect and covariates. If the within-cluster deviation increases by one hour, holding the other terms fixed, the log odds increase by 0.8 and the conditional odds are multiplied by \(\exp(0.8)\approx2.226\). The new linear predictor is \(-1.2+0.8=-0.4\), giving a conditional probability of \(\exp(-0.4)/[1+\exp(-0.4)]\approx0.4013\).
If instead the cluster mean increases by one hour while the deviation remains zero, the linear predictor is \(-1.2+0.5=-0.7\), giving a conditional probability of approximately \(0.3318\). The between-cluster conditional odds ratio is \(\exp(0.5)\approx1.649\). The within-between contrast on the log-odds scale is \(0.5-0.8=-0.3\). These predictions hold at \(b_i=0\); they are not population-averaged probabilities obtained by integrating over the random-effect distribution.
Worked Example: The Same Decomposition in a GEE Mean Model
Suppose a hypothetical logistic GEE for a binary outcome has estimated population-averaged coefficients \(\gamma_0=-1.0\), \(\gamma_W=0.6\), and \(\gamma_B=0.3\), with the cluster mean centered at 5 hours per week. At a visit at the cluster mean in a cluster whose centered mean is zero, the modeled population-averaged probability is
A one-hour increase in the within-cluster deviation, holding the cluster mean fixed, changes the linear predictor to \(-1.0+0.6=-0.4\). The modeled population-averaged probability is then approximately \(0.4013\), and the population-averaged odds ratio is \(\exp(0.6)\approx1.822\). A one-hour increase in the cluster mean at deviation zero changes the predictor to \(-1.0+0.3=-0.7\), giving a modeled probability of approximately \(0.3318\) and an odds ratio of \(\exp(0.3)\approx1.350\).
These are population-averaged mean-model calculations under the stated GEE specification. They are not random-effect-conditional predictions. The numbers are illustrative coefficients, not results from an analysis of real data.
Assumptions, Diagnostics, and Alternatives
The decomposition is an algebraic construction, but interpreting fitted coefficients requires more. Check that the cluster definition and observation window make the cluster mean meaningful, that the covariate is measured consistently, and that clusters have enough variation for the within-cluster association to be estimated. If a cluster’s covariate never changes, its within-cluster deviations are all zero, so that cluster supplies no direct information about the within-cluster slope. If cluster means barely vary, the between-cluster coefficient may be imprecise.
Diagnostics should be relevant to the chosen model. Examine the distributions and ranges of the within and between components, identify influential clusters, and check whether the assumed response mean and link are plausible. For a GLMM, assess the adequacy of the conditional mean and random-effects assumptions. For a GEE, assess the mean specification and use inference appropriate to the number of independent clusters. A fitted coefficient cannot repair a poorly defined cluster mean, severe lack of covariate overlap, or an inappropriate mean model.
Alternative specifications answer different questions. A model with \(X_{ij}\) alone assumes equal within- and between-cluster slopes. A model with only \(X_{ij}-\bar X_i\) targets within-cluster variation but leaves the between-cluster component out of the mean model. A model with only \(\bar X_i\) describes between-cluster variation without estimating the within-cluster association. Cluster fixed effects can control for all stable cluster-level characteristics in many settings, but do not estimate effects of covariates that are constant within cluster and do not, by themselves, provide the same decomposition for the between-cluster association. Choice among these models should follow the scientific comparison of interest, not a search for the most favorable coefficient.
Check Your Understanding
Answer each question, then compare your reasoning with the solutions.
- A cluster has covariate values 3, 6, and 6. What is its mean, and what are the three within-cluster deviations?
- In a model with separate within and between coefficients, what comparison does the within coefficient describe?
- A logistic GLMM has \(\beta_W=0.4\). What is the conditional odds ratio for a one-unit increase in the within-cluster deviation, holding other terms fixed?
- Why does a model with one coefficient multiplying \(X_{ij}\) impose a restriction when within and between components are considered separately?
- What information does a cluster with no variation in \(X_{ij}\) contribute to estimating the within-cluster slope?
Solutions. (1) The mean is \((3+6+6)/3=5\); the deviations are \(-2,1,1\). (2) It describes the modeled association for a one-unit increase relative to the cluster’s own mean, holding the between-cluster component fixed. (3) The odds ratio is \(\exp(0.4)\approx1.492\), conditional on the random effects and other covariates in the GLMM. (4) Since \(X_{ij}=(X_{ij}-\bar X_i)+\bar X_i\), using one coefficient on \(X_{ij}\) gives the same coefficient to both components. (5) Its within-cluster deviations are all zero, so it supplies no direct variation for estimating the within-cluster slope.