Tutorials › Generalized Linear Mixed Models (GLMM) › Individual-Weighted And Cluster-Weighted Marginal Means

Marginal Effects and Population-Averaged Estimates · Tutorial 427 of 698

Individual-Weighted And Cluster-Weighted Marginal Means

Learn to define, calculate, and compare marginal means that give equal weight to each cluster or each individual, and to choose the weighting scheme that matches the target population.

Advanced 12 min read

What You'll Learn

  • Define cluster-weighted and individual-weighted marginal means for a specified set of clusters.
  • Derive the difference between the two means using cluster sizes and cluster-specific means.
  • Calculate each estimand from hypothetical cluster-level predictions.
  • Compare treatment contrasts under equal-cluster and individual weighting.
  • Diagnose when the weighting choice changes interpretation and when it does not.
  • Distinguish a target-population choice from a modeling or computational error.

Why the Unit Being Averaged Matters

A marginal mean summarizes expected outcomes across a target population. But a population can be sampled or described at more than one level. In clustered data, one might choose a cluster—such as a clinic or school—uniformly, or choose an individual uniformly from all individuals in the clusters. These choices generally do not select the same population when cluster sizes differ.

The difference is about the target of the average, not automatically about whether a model is correct. Giving each clinic equal weight answers a question about the average clinic. Giving each person equal weight answers a question about the average person in the pooled population. If large and small clusters have different expected outcomes, these averages can differ.

Definition: Suppose the target contains \(J\) clusters. Let \(n_j\) be the number of eligible individuals in cluster \(j\), \(N=\sum_{j=1}^{J}n_j\) the total number of eligible individuals, and \(\mu_j\) the cluster-specific marginal mean on the response scale. The cluster-weighted marginal mean is \(\mu_C=J^{-1}\sum_{j=1}^{J}\mu_j\). The individual-weighted marginal mean is \(\mu_I=N^{-1}\sum_{j=1}^{J}n_j\mu_j\). The former gives each cluster equal weight; the latter gives each individual equal weight, so cluster \(j\) receives weight \(n_j/N\).

Here, \(\mu_j\) must refer to the same outcome and scenario for every cluster. For example, it might be the cluster-specific predicted probability of an outcome under a specified treatment condition, after applying a chosen covariate standardization. The earlier material on standardizing marginal effects establishes that the covariate distribution is part of an estimand. The weights across clusters are a separate choice. Define the cluster means using a consistent prediction target first; then specify whether the target averages clusters or individuals.

The counts \(n_j\) must also match the population the question names. For a person-level outcome, they might count eligible people, not visits or repeated records. If the target is an average visit, a different set of weights may be appropriate. Unequal counts alone do not make either estimand wrong: the right choice depends on the intended population and sampling unit.

Deriving the Difference

Let \(\bar n=N/J\) be the average cluster size and \(\bar\mu=J^{-1}\sum_{j=1}^{J}\mu_j=\mu_C\) the cluster-weighted mean. Subtracting the two estimands gives

$$ \mu_I-\mu_C =\frac{1}{N}\sum_{j=1}^{J}n_j\mu_j-\frac{1}{J}\sum_{j=1}^{J}\mu_j =\frac{1}{N}\sum_{j=1}^{J}(n_j-\bar n)(\mu_j-\bar\mu). $$

To verify the last equality, note that \(N=J\bar n\), so the difference before the last equality is \(N^{-1}\sum_j(n_j-\bar n)\mu_j\). Since \(\sum_j(n_j-\bar n)=0\), subtracting \(\bar\mu\) from each \(\mu_j\) does not change that sum. This identity shows why the two means differ: their difference is the size–mean association across clusters, scaled by the total number of individuals.

If larger clusters tend to have larger means, the right-hand sum tends to be positive and individual weighting tends to give a larger mean. If larger clusters tend to have smaller means, it tends to be negative. The exact condition for equality is that the centered size–mean products sum to zero. Equal cluster sizes guarantee equality, as do equal cluster means, but neither is required: positive and negative products can also cancel.

Worked Example: Three Clinics With Unequal Sizes

Suppose three hypothetical clinics have, respectively, 2, 10, and 4 eligible patients. Their predicted outcome probabilities under one common scenario are 0.20, 0.50, and 0.80. Assume these probabilities are defined for the same outcome and covariate target in all three clinics. Find both averages.

Cluster-weighted mean. Each clinic receives weight \(1/3\):

$$ \mu_C=\frac{0.20+0.50+0.80}{3}=0.50. $$

Individual-weighted mean. There are \(N=2+10+4=16\) patients, so the clinic weights are \(2/16\), \(10/16\), and \(4/16\):

$$ \mu_I=\frac{2(0.20)+10(0.50)+4(0.80)}{16} =\frac{0.40+5.00+3.20}{16} =\frac{8.60}{16}=0.5375. $$

Thus, the average clinic has predicted probability 0.500, while the average patient in the pooled set of clinics has predicted probability 0.5375. The individual-weighted result is higher because the largest clinic has the middle mean, but the four-patient clinic has the highest mean; the two-patient clinic has the lowest. In this particular example, the size–mean balance yields a positive difference.

Check the result using the derived identity. Here, \(\bar n=16/3\) and \(\bar\mu=0.50\), so the centered numerator is

$$ (2-16/3)(0.20-0.50) +(10-16/3)(0.50-0.50) +(4-16/3)(0.80-0.50) =1.00+0-0.40=0.60. $$

Dividing by \(N=16\) gives \(0.60/16=0.0375\), exactly the difference \(0.5375-0.500=0.0375\). The calculation uses the sizes paired with their own clinic means; pairing a size with the wrong mean can change both the magnitude and the sign.

What Each Average Represents

The cluster-weighted mean corresponds to selecting a cluster uniformly from the \(J\) target clusters and then using that cluster’s defined mean. It is useful when the scientific question concerns the average cluster, or when clusters are the units to which equal representation should be given. For example, it might be appropriate to describe the typical clinic when the goal is to compare clinics as organizations, regardless of patient volume.

The individual-weighted mean corresponds to selecting one individual uniformly from all eligible individuals in the target. A cluster containing 100 eligible individuals then contributes ten times as much as a cluster containing 10. This is often the natural target for a question about the expected outcome of a randomly selected patient from the pooled patient population.

These interpretations require a clearly defined target set. If the observed cluster sizes are merely a sample and the intended target is a broader population of clusters, plugging observed sizes directly into the formula may not represent the intended population average. Likewise, if a cluster’s size is related to who is observed or to the outcome process, the size-weighted average remains a well-defined descriptive target, but additional assumptions may be needed to interpret it as a broader population quantity.

Worked Example: How a Large Cluster Changes the Average

Consider three hypothetical schools with eligible student counts 5, 5, and 20. Their predicted probabilities of meeting a specified benchmark are 0.10, 0.30, and 0.60. Assume the predictions use the same benchmark definition and covariate target.

The cluster-weighted mean is

$$ \mu_C=\frac{0.10+0.30+0.60}{3} =\frac{1.00}{3}=0.3333. $$

For the individual-weighted mean, \(N=5+5+20=30\):

$$ \mu_I=\frac{5(0.10)+5(0.30)+20(0.60)}{30} =\frac{0.50+1.50+12.00}{30} =\frac{14.00}{30}=0.4667. $$

The difference is \(0.4667-0.3333=0.1334\), or about 13.33 percentage points before rounding. The large school has the highest predicted probability and contains two-thirds of the students, so it has a much greater influence on the individual-weighted average than on the average across schools. Neither number is a corrected version of the other: they answer different questions.

Weighting Marginal Contrasts

The weighting choice also applies to contrasts, such as a difference in predicted probabilities between two treatment conditions. To target an average contrast across clusters, calculate each cluster’s contrast and average those contrasts equally. To target an average contrast across individuals, weight the cluster-specific contrasts by the same eligible individual counts. When comparing two conditions for the same target population, keep the target clusters, sizes, covariate definition, and weights consistent across conditions.

Worked Example: A Risk Difference Under Two Weighting Schemes

Suppose two hypothetical clusters contain 4 and 16 eligible individuals. Their standardized predicted probabilities under condition 0 are 0.10 and 0.50, and under condition 1 are 0.20 and 0.70. Treat these as predictions for the same two clusters and the same covariate target under both conditions.

The cluster-specific risk differences are \(0.20-0.10=0.10\) and \(0.70-0.50=0.20\). Giving clusters equal weight yields

$$ \Delta_C=\frac{0.10+0.20}{2}=0.15. $$

For the individual-weighted contrast, use the same weights \(4/20\) and \(16/20\):

$$ \Delta_I=\frac{4(0.10)+16(0.20)}{20} =\frac{0.40+3.20}{20}=0.18. $$

As a check, the individual-weighted condition means are \(\mu_I(0)=[4(0.10)+16(0.50)]/20=0.42\) and \(\mu_I(1)=[4(0.20)+16(0.70)]/20=0.60\). Their difference is \(0.60-0.42=0.18\), consistent with the weighted cluster-specific contrasts. The individual-weighted risk difference is 0.03, or 3 percentage points, larger than the equal-cluster contrast because the larger cluster has the larger cluster-specific difference.

Assumptions, Diagnostics, and Alternatives

The arithmetic definitions themselves require only a specified set of clusters, positive eligible counts, and one comparable cluster-specific mean per cluster. Interpreting the results as model-based population means also requires that the cluster means be defined and estimated for the stated outcome, scenario, and covariate target. If predictions are intended to describe a wider population, the model and sampling assumptions supporting that interpretation must be appropriate; the formulas do not establish those assumptions.

Before reporting either average, check the following:

  • Confirm the unit counted. Make sure \(n_j\) counts eligible members of the intended target, rather than visits, measurements, or duplicated records.
  • Inspect the cluster sizes and means together. A table or plot of \(n_j\) against \(\mu_j\) can reveal whether a few large clusters dominate the individual-weighted result or whether size and mean tend to move together.
  • Verify common definitions. The cluster means must refer to the same outcome scale, condition, and standardization target. Otherwise, the weighted average mixes unlike quantities.
  • Check the weights sum to one. Cluster weights are \(1/J\); individual weights are \(n_j/N\). In either case their sum must equal 1.
  • Separate point estimation from uncertainty. Individuals within a cluster are not automatically independent observations. Uncertainty calculations must reflect the clustered design and the way the means were estimated; the weighted point estimate alone does not supply a valid standard error.

A common alternative is to report both estimands, with their target populations stated explicitly. Another is to use design or survey weights when the target population’s sampling design requires them. Such weights are not interchangeable with \(n_j/N\): they answer a different population-representation problem and must be justified by the design. The choice is not “weighted is better” versus “unweighted is safer.” It is a choice between well-defined targets.

Common pitfall: “Each cluster contributes one mean, so the unweighted average is the overall mean.” This is correct only for an average cluster, or in special cases where cluster weighting and individual weighting coincide. For an average individual, each cluster mean must be weighted according to the number of eligible individuals it represents. Conversely, automatically weighting by size is also a mistake when the target is the average cluster.

A discrepancy between the two averages is therefore informative, not necessarily evidence of a defective GLMM. It can indicate that cluster size and expected outcome are associated, or simply that the estimands represent different sampling schemes. Reporting the weighting rule and the target unit makes the result interpretable and helps readers see why another analysis might produce a different marginal mean.

Check Your Understanding

For each question, identify the relevant weighting and compare it with the stated target.

  1. Four clinics have equal predicted means of 0.40 but different patient counts. Must the individual-weighted and cluster-weighted means differ?
  2. Two schools have sizes 10 and 30 and predicted means 0.20 and 0.60. Calculate both means.
  3. A report gives an equal-weight average of clinic means and calls it the predicted probability for a randomly selected patient. What should be checked?
  4. In a two-condition comparison, why should the same cluster weights generally be used in both conditions when estimating a contrast for one target population?

Solutions. (1) No. Both averages equal 0.40 because all cluster means are equal, regardless of sizes. (2) The cluster-weighted mean is \((0.20+0.60)/2=0.40\). The individual-weighted mean is \([10(0.20)+30(0.60)]/40=(2+18)/40=0.50\). (3) Check whether the intended target is the average patient or the average clinic. For a randomly selected patient, weight clinic means by eligible patient counts, assuming those counts describe the target population. (4) Keeping weights fixed ensures both condition means refer to the same population composition. Changing weights between conditions would combine the outcome contrast with a change in which clusters represent the target.

Clinical Biostats