Why Compare Grouped Means?
A marginal mean model describes the expected response for an observation given its covariates, without requiring responses from the same cluster to be independent. A useful diagnostic is therefore to compare the observed responses with the means implied by the model across interpretable groups: for example, visits, treatment groups, or age bands. A persistent gap or pattern in those comparisons can point to a mean structure that does not capture an important feature of the data.
The comparison is a diagnostic, not a test that treats every response as independent. Repeated responses from one person, or patients within one clinic, may be associated. That association affects how much information a collection of observations provides and how uncertain a group average is. It does not, by itself, imply that the model gives the wrong marginal mean.
For a fixed group \(g\), write \(\mathcal I_g\) for the set of observed rows in that group and \(N_g\) for its size. With a fitted parameter \(\hat\beta\), the basic comparison is
The fitted group mean uses the predictions for the actual observations in the group. It is not generally the model prediction at an average covariate value. This distinction matters whenever the link or response-scale mean is nonlinear.
What a Grouped Comparison Can Establish
A model can be checked by tabulating or plotting \(\bar Y_g\), \(\bar\mu_g(\hat\beta)\), and their difference for a series of groups. The groups should be chosen to reveal features the model is intended to describe: time points for a repeated-measures trend, treatment-by-time cells for an interaction, or ranges of a continuous covariate for a nonlinear pattern. Very small groups can produce volatile observed averages; very broad groups can conceal a discrepancy that changes direction within the group.
The following result explains the role of dependence in these summaries. It concerns the true parameter \(\beta_0\) and the correctly specified marginal mean \(E[Y_{ij}\mid X_i]=\mu_{ij}(\beta_0)\). It does not say that a comparison using an estimated parameter has expectation exactly zero: \(\hat\beta\) is data-dependent.
To prove the conditional expectation statement, condition on \(X_i\). The group-membership indicators and the model means are then fixed. Linearity of conditional expectation gives
Now let \(S_g=\sum_{i=1}^m S_{ig}\). Under conditional independence of clusters, the conditional covariance between \(S_{ig}\) and \(S_{kg}\) is zero for \(i\ne k\). Therefore
The final expression includes the individual variances when \(j=k\) and the within-cluster covariances when \(j\ne k\). Thus, under the stated assumptions, dependence changes the variability of a grouped residual sum, but not its conditional mean. A nonzero observed discrepancy in one dataset is possible even when the mean model is correct; a recurring, structured discrepancy across relevant groups is more suggestive of a mean-pattern problem than an isolated gap. This argument is not a formal calibration of a test statistic.
Worked Comparisons
Worked Example: A Time Pattern in Repeated Binary Responses
Suppose eight patients are measured at three visits. A marginal logistic model implies probabilities \(0.25\), \(0.45\), and \(0.65\) at visits 0, 1, and 2, respectively. The observed numbers of successes are 2, 4, and 6, with eight responses at each visit. Compare the grouped observed and model-implied means.
At visit 0, the observed proportion is \(2/8=0.25\), matching the model-implied group mean \(0.25\). At visit 1, it is \(4/8=0.50\), compared with \(0.45\), a difference of \(0.05\). At visit 2, it is \(6/8=0.75\), compared with \(0.65\), a difference of \(0.10\).
The two later groups are above their fitted means, and the gap grows over time. That pattern is worth investigating as a possible inadequacy in the modeled time trend. It is not enough to conclude that the model is wrong: there are only eight patients, and the three responses from a patient may be dependent. Those dependencies affect the uncertainty of the comparisons. The group means alone do not supply a dependence-adjusted significance test.
Worked Example: Unequal Cluster Contributions
Consider a covariate group with observations from three clusters. Cluster 1 contributes two counts, \(0\) and \(2\), cluster 2 contributes one count, \(4\), and cluster 3 contributes three counts, \(0\), \(1\), and \(2\). Suppose the model-implied means for each observation are \(1\), \(1\); \(2\); and \(1\), \(1\), \(1\), respectively. Calculate the observation-weighted comparison and compare it with an equally cluster-weighted summary.
There are six observations and nine observed events in total, so the observation-weighted observed mean is \(9/6=1.5\). The sum of the six model-implied means is \(1+1+2+1+1+1=7\), giving an observation-weighted fitted mean of \(7/6\approx1.17\). The observed-minus-fitted difference is \(1.5-7/6=1/3\).
For an equally cluster-weighted summary, first compute each cluster’s observed mean: cluster 1 has \(2/2=1\), cluster 2 has \(4/1=4\), and cluster 3 has \(3/3=1\). Their equal-weight average is \((1+4+1)/3=2\). The corresponding cluster means of the fitted values are \(1\), \(2\), and \(1\), whose equal-weight average is \((1+2+1)/3=4/3\). The difference is \(2-4/3=2/3\), not \(1/3\).
Neither weighting is automatically correct for every question. The observation-weighted summary describes the average response across rows in the group; the equally cluster-weighted summary gives each represented cluster the same weight, regardless of how many group observations it contributes. State which summary is being used, and do not compare a cluster-weighted observed mean with an observation-weighted fitted mean.
Worked Example: Averaging Predictions Within a Covariate Group
A Poisson marginal model has log mean \(\log\{\mu(x)\}=x\log(2)\). In a broad covariate group, four observations have covariate values \(0,2,0,2\). Their observed counts are \(0,5,2,3\). Find the grouped observed and model-implied means, and identify a tempting but incorrect alternative.
The model means at \(x=0\) and \(x=2\) are \(\exp(0)=1\) and \(\exp\{2\log(2)\}=4\). Averaging the four predictions gives \((1+4+1+4)/4=2.5\). The observed mean is \((0+5+2+3)/4=10/4=2.5\), so the grouped difference is zero.
The average covariate is \((0+2+0+2)/4=1\). Predicting at that average gives \(\mu(1)=\exp\{\log(2)\}=2\), which is not the fitted mean for this group. The correct comparison averages the predictions for the actual covariate values; it does not replace those values with their average before applying a nonlinear mean function.
Reading the Pattern Carefully
A useful summary retains enough structure to reveal where the model succeeds and where it may fail. For repeated measures, report observed and fitted means by visit, and consider treatment-by-visit cells when the model includes that interaction. For continuous covariates, bins can make the comparison readable, but record the range or distribution of covariate values in each bin. A broad bin can average away local errors, while narrow bins may be too sparse to be informative.
When predictors vary within a group, calculate the model-implied group mean as the average of the individual fitted means. For a nonlinear response-scale mean, the prediction at the average covariate generally differs from that average. If an outcome is a count, its observed and fitted means may be nonintegers; that is expected for averages, even though individual counts are integers.
Cluster summaries are especially helpful when many rows come from a small number of clusters. One can inspect cluster-specific group averages or cluster residual sums \(S_{ig}\) to see whether a discrepancy is broadly shared or driven by a few clusters. Such summaries can expose concentration or heterogeneity hidden by a single pooled average. They do not make the clusters interchangeable, nor do they eliminate the need to account for the sampling design when drawing inferential conclusions.
Common Pitfall
Wrong reasoning: “The observations in each group are correlated, so a mismatch between the observed and fitted group means must be caused by the correlation model.” This confuses two different parts of a marginal model. A correctly specified marginal mean can coexist with substantial within-cluster association; association affects the variation of the summary, not the target mean.
Correction: First inspect whether discrepancies follow a systematic covariate or time pattern. Separately recognize that within-cluster dependence changes the uncertainty attached to those discrepancies. A single grouped difference cannot distinguish random variation from mean misspecification, and a pattern is a prompt for scrutiny rather than proof on its own. Conversely, a dependence structure should not be adjusted merely to force observed group averages to match fitted ones.
Check Your Understanding
Answer each question using the distinction between marginal means, grouped summaries, and within-cluster dependence.
- For a group containing responses from repeated visits, what quantities are averaged to obtain its observed mean and its model-implied mean?
- Under a correctly specified conditional marginal mean, why does the expected cluster residual sum for a covariate-defined group equal zero?
- How can within-cluster covariance affect the variance of a grouped residual sum while leaving its conditional expectation unchanged?
- When cluster sizes within a group differ, what is the distinction between an observation-weighted and an equally cluster-weighted mean?
- Why can prediction at the average covariate differ from the average of fitted means in a nonlinear model?