Resource

Clustered and Correlated Data: Why Ordinary Regression Can Give Misleading Results

A regression dataset can contain many rows without containing the same number of independent pieces of information. This Resource explains how to recognize clustered or correlated observations and how the research question, outcome distribution, clustering structure, and target interpretation guide the choice among GEE, linear mixed models, generalized linear mixed models, and other correlated-data methods.

A regression dataset may contain 2,000 rows without containing 2,000 independent pieces of information.

Patients treated in the same hospital can share clinical practices and organizational conditions. Measurements repeated within the same person are connected by that person's biology and history. Observations from members of the same household, clinic, school, or other group may likewise be more similar than observations from different groups.

These structures create clustered or correlated data. The problem is not merely descriptive. Independence across study units is a central assumption underlying ordinary regression methods, whereas longitudinal and cluster-correlated settings require methods that recognize dependence (Lash et al., 2021).

Ignoring that structure can produce misleading uncertainty and inference. But there is no single universal “clustered data model.” The appropriate analysis depends on the research question, outcome distribution, clustering structure, target interpretation, and assumptions about how dependence arises.

This resource provides a practical framework for recognizing clustering and choosing among marginal models/GEE, linear mixed models, generalized linear mixed models, and specialized methods for correlated categorical outcomes.

Core principle: Rows are not necessarily independent observational units simply because they occupy separate rows in the dataset.

What makes observations clustered or correlated?

Observations are clustered when multiple observations belong to a common higher-level unit or otherwise have a dependence structure that makes treating every row as statistically independent inappropriate.

Common structures include:

  • repeated measurements within the same person;
  • patients nested within hospitals, clinics, physicians, or care teams;
  • students nested within schools;
  • members within households or families;
  • multiple observations arising from the same matched set;
  • repeated binary, ordinal, or count outcomes;
  • other multilevel or grouped epidemiologic data.

In longitudinal research, repeated observations from the same individual are typically correlated. Within-person dependence can reflect stable differences among individuals, temporal processes, and other sources of shared variation. An exploratory analysis can therefore examine not only the mean trajectory but also residual variances and correlations among measurements within individuals (Fitzmaurice et al., 2011; Lash et al., 2021).

Why the independence assumption matters

Ordinary regression is usually formulated as though observations are independent conditional on the predictors in the model. Lash et al. (2021) describe independence across study units as a central assumption for model-fitting methods and explicitly distinguish settings in which that independence does not hold.

Suppose several observations come from one person. If those observations are positively correlated, they contain partly overlapping information. Treating them as independent acts as though their joint information were greater than it actually is.

The consequences can affect the estimated covariance matrix of the regression coefficients and therefore:

  • standard errors;
  • confidence intervals;
  • test statistics;
  • p-values;
  • inferential conclusions.

The central danger is therefore not that every regression coefficient must become dramatically different once clustering is modeled. A coefficient can look quite similar while its estimated uncertainty changes materially.

Important distinction: In clustered data analysis, the mean model and the uncertainty calculation are related but separate statistical issues.

Why ordinary standard errors can be misleading

When within-cluster correlation exists, the usual independence-based variance calculation does not represent the observed dependence structure.

Marginal approaches such as generalized estimating equations address this directly. Agresti (2013) explains that under an independence working structure, GEE coefficient estimates coincide with estimates obtained by treating observations within and between clusters as independent. However, the ordinary model-based standard errors need not remain appropriate. GEE can instead use empirical dependence to obtain robust standard errors that reflect the clustered data (Agresti, 2013).

Practical rule: Do not judge whether clustering matters solely by comparing regression coefficients. Compare the assumptions and the resulting uncertainty as well.

Correlation can also affect efficiency. A working correlation structure that reasonably approximates the actual dependence can improve estimation efficiency, while an independence structure may perform less efficiently in some settings, particularly when within-cluster correlations are substantial (Agresti, 2013).

Start with the data structure, not the software menu

Before choosing a model, identify the actual independent units and the source of repeated or grouped observations.

Ask: What creates multiple rows from the same underlying unit?

For longitudinal data, the answer may be the person. For hospital data, patients may be clustered within hospitals. More complicated studies can contain several levels or forms of dependence.

Then separate two questions:

  1. What mean or association do you want to estimate?
  2. How should the dependence among observations be represented?

Those questions help distinguish marginal and mixed-effects approaches.

Marginal models and GEE

A marginal model directly models the mean response in the population while accounting for correlation among observations within clusters.

For longitudinal outcomes, Fitzmaurice et al. (2011) describe marginal models as extensions of generalized linear models that incorporate within-subject association. A defining feature is that the mean model and the covariance or association model are specified separately. Regression coefficients therefore describe covariate relationships with the population mean rather than being conditional on latent individual random effects (Fitzmaurice et al., 2011).

What GEE does

Generalized estimating equations provide a major estimation framework for marginal models.

The analyst specifies:

  • a model for the marginal mean;
  • an appropriate link and variance function;
  • a working covariance or correlation structure.

Possible working correlation structures include independence, exchangeable correlation, autoregressive patterns for repeated observations over time, and unstructured correlation (Agresti, 2013).

The word working is important. Under appropriate conditions, GEE estimation of mean-model parameters can remain consistent despite misspecification of the working covariance structure when the mean model is correctly specified. Empirical or sandwich standard errors can then use the observed dependence to provide inference less reliant on the chosen working correlation (Agresti, 2013).

That robustness does not make GEE assumption-free. The mean model still needs to be defensible, and the inferential properties of robust variance estimation depend on its large-sample setting.

What a GEE coefficient means

GEE is especially natural when the scientific target is a population-average relationship.

The question is conceptually:

How does the mean response in the population differ as the exposure or predictor changes?

This interpretation becomes especially important for binary, count, ordinal, and other outcomes fitted with nonlinear links.

Linear mixed models

A linear mixed model provides another framework for correlated continuous outcomes.

Mixed models combine fixed effects describing systematic mean relationships with random effects representing variation among clusters or individuals. Random effects can also generate dependence because observations belonging to the same cluster share the same random components (Fitzmaurice et al., 2011; Lash et al., 2021).

Conceptually, a longitudinal linear mixed model can be represented as:

Yi = Xiβ + Zibi + εi

where Xiβ describes the fixed-effects component, Zibi represents cluster- or subject-specific random effects, and εi represents remaining within-unit variability.

McCulloch and Searle (2001) develop linear mixed models as an extension of ordinary linear modeling designed to accommodate correlated observations and variance-component structures.

Random intercepts

A random intercept allows clusters or individuals to differ in their underlying outcome level.

For repeated measurements, observations from the same individual share that person's random intercept. This shared component induces within-person correlation.

For multilevel data, the same principle can represent differences among hospitals, schools, clinics, or other grouping units.

Random slopes

A random slope permits the relationship with a predictor—often time—to vary among clusters or individuals.

For example, individuals can have both different baseline levels and different trajectories. Lash et al. (2021) describe models in which cluster-specific random intercepts quantify departures from a common intercept and random slopes quantify departures from a common slope. Random intercepts and slopes may themselves be correlated.

A random-effects structure is more than a technical correction to standard errors. It expresses assumptions about heterogeneity between clusters and the dependence induced within clusters.

Generalized linear mixed models

Continuous outcomes are only one part of clustered data analysis.

For binary, count, ordinal, or other non-Gaussian outcomes, generalized linear mixed models (GLMMs) extend the random-effects framework using an appropriate outcome distribution and link function.

Fitzmaurice et al. (2011) describe GLMMs as extensions of generalized linear models in which some regression coefficients can vary randomly across individuals. Conditional on those random effects, repeated observations are modeled using distributions appropriate to the response, such as Bernoulli for binary data, Poisson for counts, or multinomial distributions for categorical outcomes.

GLMMs are therefore useful when the scientific model explicitly involves cluster or subject heterogeneity and the outcome is not adequately represented by an ordinary Gaussian linear model.

But fitting a GLMM is not interchangeable with fitting GEE.

Population-average versus cluster- or subject-specific effects

This is one of the most important distinctions in correlated-data analysis.

Marginal interpretation

Marginal models describe effects on the population mean response. The regression model is conditional on measured covariates but not on unobserved subject-specific random effects.

Fitzmaurice et al. (2011) emphasize that marginal regression coefficients describe covariate effects on population mean responses.

Conditional or subject-specific interpretation

Generalized linear mixed models condition on random effects. With nonlinear links, their fixed-effect regression parameters therefore generally have subject-specific or cluster-specific interpretations, rather than the same population-average interpretation produced by a marginal model (Fitzmaurice et al., 2011).

This difference is particularly important with logistic and other nonlinear models.

A marginal logistic model and a logistic random-effects model need not produce the same coefficient because they need not estimate the same statistical quantity. Fitzmaurice et al. note that averaging a logistic mixed-effects model over its random effects does not generally yield a marginal logistic regression model of the same form.

Lash et al. (2021) similarly note that, outside linear mixed models, marginal and conditional parameter values generally differ numerically.

Interpretation warning: Do not compare a GEE coefficient with a GLMM coefficient as though one must be wrong because they differ. First determine whether they target the same estimand.

GEE versus mixed effects: a practical comparison

Practical comparison of marginal/GEE and mixed-effects approaches
Decision Marginal model / GEE Mixed-effects model
Primary target Population-average mean relationship Heterogeneity and conditional relationships involving cluster/subject random effects
Dependence Represented through a working covariance/correlation structure Generated partly or wholly through shared random effects
Random effects Not required Central model component
Continuous outcomes Marginal approaches are available Linear mixed models are a major framework
Binary/count/categorical outcomes Marginal generalized models can be fitted using GEE GLMMs extend mixed models to non-Gaussian outcomes
Individual/cluster heterogeneity Need not be explicitly modeled as latent random effects Can be represented using random intercepts, slopes, and other random coefficients
Nonlinear-link interpretation Population-average Generally conditional/subject-specific
Correlation model Working covariance/correlation Implied by random effects and any additional covariance specification

(Fitzmaurice et al., 2011; McCulloch & Searle, 2001; Lash et al., 2021).

Neither column is universally preferable. They represent different ways of formulating correlated-data problems.

Repeated measures are one form of clustered data

Repeated measures are a particularly common source of dependence.

Measurements from the same participant should not automatically be treated as independent observations. Longitudinal analysis requires attention both to the trajectory of the mean response and to the association among repeated measurements (Fitzmaurice et al., 2011).

Possible structures differ scientifically.

  • Exchangeable: treats pairwise within-cluster correlations as similar.
  • Autoregressive: can represent weaker correlation between observations farther apart in time.
  • Unstructured: allows pair-specific correlations but requires more parameters.

These structures are discussed by Agresti (2013).

Mixed models provide another route: shared random intercepts or slopes generate correlation through cluster-level heterogeneity.

Do not reduce this decision to “repeated data = random intercept.” A random intercept itself imposes a particular dependence structure. Lash et al. show that, in a linear model with normally distributed random intercepts and residuals, the induced response dependence is exchangeable; other random-effects structures imply different forms of dependence.

Epidemiologic cluster-correlated data

Clustered observations arise naturally in epidemiology.

Repeated measurements within people are one example, but cluster-correlated data can also result from organizational, geographic, familial, provider, or other grouping structures. The statistical question is whether outcomes remain independent across the study units after conditioning on the variables represented in the model.

Modern Epidemiology treats independence as central to conventional model fitting and separately develops methods for settings in which study-unit independence fails (Lash et al., 2021).

For epidemiologic analyses, recognizing dependence should occur before model fitting. Clustering is part of the design and data-generating structure, not merely something to investigate after an ordinary regression produces an unexpected p-value.

The appropriate response can include marginal modeling, mixed-effects modeling, or another method designed for the particular correlated-data structure. The existence of clustering alone does not determine which one is scientifically appropriate.

Matched and correlated categorical outcomes

Categorical outcomes require additional care because correlation is not limited to continuous repeated measurements.

Agresti (2013) treats matched pairs and clustered categorical data as distinct correlated-data problems. Methods include analyses for dependent proportions and matched pairs, marginal models for square contingency tables, GEE for clustered categorical data, transitional models, and random-effects models for clustered categorical responses.

For clustered categorical outcomes, GEE can specify a working correlation pattern without requiring a complete multivariate distribution. Empirical standard errors can then account for observed within-cluster dependence (Agresti, 2013).

Random-effects categorical models provide a different formulation by representing cluster heterogeneity explicitly. Agresti's treatment therefore reinforces the broader principle:

Matched, repeated, and clustered categorical data should not automatically be analyzed as independent binary or multinomial observations.

Nor should every categorical clustered design automatically be forced into the same GEE or GLMM specification.

How to choose a clustered-data method

Begin with the research question rather than the model name.

1. Identify the target quantity

Ask whether the intended conclusion concerns an average response or association in the population, a cluster- or subject-specific relationship, heterogeneity among clusters, individual trajectories, a matched comparison, or another design-specific estimand.

For nonlinear outcomes, the population-average versus subject-specific distinction should be made explicitly before fitting the model (Fitzmaurice et al., 2011).

2. Identify the outcome distribution

A continuous approximately Gaussian outcome may support linear marginal or mixed models.

Binary, count, ordinal, or nominal outcomes require methods appropriate to those distributions, such as marginal generalized models/GEE, GLMMs, or specialized categorical-data methods (Agresti, 2013; Fitzmaurice et al., 2011).

3. Map the clustering structure

Specify which observations belong together. Consider whether there is one measurement per person with people nested within hospitals, repeated observations within people, both people and organizational clusters, matched pairs or sets, or longitudinal categorical observations.

Decision: The statistical model should correspond to the actual design rather than merely to the shape of the spreadsheet.

4. Decide whether cluster heterogeneity is scientifically important

If differences among subjects or clusters are themselves central—for example, different baseline levels or trajectories—random effects provide a natural framework.

If the scientific target is primarily a population-average mean relationship and cluster correlation is principally a nuisance dependence, a marginal formulation may align more directly with the target.

5. Specify the dependence model thoughtfully

For GEE, consider the working correlation. For mixed models, consider which random effects are scientifically plausible and what covariance structure they imply.

Do not assume that an exchangeable GEE, random intercept, or maximally complicated covariance structure is automatically correct.

6. Check the assumptions that belong to the chosen model

For marginal GEE, assess the mean-model specification and whether the working correlation is plausible enough for efficient estimation. Robust standard errors do not remove every modeling assumption.

For mixed models, assess the fixed-effects specification, random-effects structure, covariance assumptions, distributional assumptions, and model stability.

For GLMMs, random-effects distribution assumptions form part of the probability model, adding complexity relative to marginal models (Fitzmaurice et al., 2011).

7. Interpret coefficients according to the fitted estimand

Especially for nonlinear models, do not translate a conditional coefficient into population-average language—or vice versa—without justification.

Decision: The model name is not enough. The interpretation must match the mathematical target.

Checklist: recognize clustering before analysis

Use this checklist before fitting an ordinary regression.

  • Does any participant contribute more than one observation?
  • Are observations nested within hospitals, clinics, physicians, schools, households, families, centers, or other groups?
  • Are there repeated measurements across time or conditions?
  • Are any observations explicitly matched or paired?
  • Can two rows share the same subject, household, provider, institution, or cluster identifier?
  • Could observations within the same group share environmental, organizational, clinical, biological, or measurement influences?
  • Does a predictor vary at the cluster level rather than independently for every row?
  • Have I identified the unit that is plausibly independent across observations?
  • Have I separated the mean-model question from the dependence/covariance question?
  • Is my target population-average, cluster-specific, subject-specific, or matched-set specific?
  • Does the outcome require a continuous, binary, count, ordinal, nominal, or other response model?
  • If using GEE, have I considered a defensible working correlation structure?
  • If using a mixed effects model, have I justified the random intercepts, random slopes, or other random effects?
  • For a nonlinear GLMM, am I interpreting fixed effects conditionally rather than automatically calling them population-average effects?
  • Have I checked whether the number and structure of independent clusters support the planned inference?
  • Have I avoided assuming that “robust standard errors” eliminate the need to understand the clustering structure?
  • Have I avoided assuming that every clustered dataset requires the same model?

If several early items are checked, ordinary independent-observation regression deserves explicit justification rather than being the default.

Common mistakes in clustered data analysis

Mistake 1: “Every row is an independent observation”

Rows are a storage format, not a statistical independence assumption. Repeated or grouped observations can remain correlated after measured predictors are included.

Mistake 2: “If the coefficient barely changes, clustering did not matter”

Dependence can primarily affect estimated uncertainty. Standard errors, confidence intervals, and tests can change even when the point estimate changes little.

Mistake 3: “GEE is just ordinary regression with corrected standard errors”

Too narrow. GEE is an estimation framework for marginal models with an explicit mean model and working covariance structure. The target interpretation is part of the model.

Mistake 4: “A random intercept fixes all clustering”

A random intercept represents one particular form of cluster heterogeneity and induces a particular dependence structure. Random slopes or other structures may be needed when heterogeneity is more complex (Lash et al., 2021).

Mistake 5: “GEE and a mixed effects model estimate the same thing”

Not necessarily. For generalized models with nonlinear links, marginal and conditional regression parameters generally have different interpretations (Fitzmaurice et al., 2011).

Mistake 6: “Binary clustered outcomes automatically require logistic mixed regression”

Repeated or clustered binary data can also be modeled marginally, including with GEE. The estimand and dependence formulation should drive the choice rather than outcome type alone (Agresti, 2013; Fitzmaurice et al., 2011).

Mistake 7: “All correlated designs are basically the same”

They are not. Longitudinal measurements, patients within hospitals, multilevel structures, matched pairs, and clustered categorical outcomes can require different formulations. The clustering mechanism, scientific target, and outcome type all matter.

Practical reporting guidance

A clustered-data analysis should make the dependence structure visible to the reader.

Report:

  • what constitutes a cluster;
  • how many independent clusters or subjects contribute data;
  • whether observations are repeated, nested, matched, or otherwise correlated;
  • the outcome distribution and link where applicable;
  • whether the model is marginal or mixed;
  • the working correlation for GEE;
  • the random-effects structure for a mixed model;
  • the covariance or variance estimator used for inference;
  • whether the reported effect is population-average or conditional/subject-specific;
  • relevant diagnostics and sensitivity analyses.

Avoid describing the analysis merely as “regression adjusted for clustering.” That wording can conceal important differences in estimand and model assumptions.

Bottom line

The first step in clustered data analysis is not choosing between GEE and a mixed effects model. It is recognizing that the observations are correlated in the first place.

Once clustering is identified, define the research question and target estimand, map the clustering structure, identify the outcome distribution, and decide whether the analysis should model a population-average relationship, cluster/subject heterogeneity, or another design-specific target.

Marginal models and GEE handle dependence while directly targeting population-average mean relationships. Linear mixed models use random effects to represent heterogeneity and dependence for continuous outcomes. Generalized linear mixed models extend that framework to non-Gaussian outcomes and, with nonlinear links, generally yield conditional or subject-specific regression interpretations. Matched and other correlated categorical designs may require their own marginal, conditional, or random-effects formulations (Agresti, 2013; Fitzmaurice et al., 2011; Lash et al., 2021; McCulloch & Searle, 2001).

Practical rule: Do not let the number of rows determine the amount of independent information you think you have. Let the study design and dependence structure determine the analysis.

FAQs

What is clustered data analysis?

Clustered data analysis refers to methods that account for dependence among observations belonging to the same person, hospital, school, household, matched set, or other grouping unit. Appropriate methods depend on the outcome, clustering structure, and target interpretation.

Why is ordinary regression a problem with clustered observations?

Ordinary regression typically relies on independence across study units for its conventional variance and inference calculations. When observations within clusters are correlated, independence-based standard errors may not represent the actual uncertainty, which can affect confidence intervals, tests, and p-values (Lash et al., 2021; Agresti, 2013).

Does clustering always bias regression coefficients?

Not necessarily. Ignoring dependence can have important consequences for uncertainty even when a coefficient estimate remains similar. Whether point estimates are also affected depends on the model, design, covariate structure, and assumptions.

What is the difference between GEE and a mixed effects model?

GEE fits marginal models targeting population-average mean relationships while representing within-cluster dependence through a working covariance structure. Mixed models introduce random effects that explicitly represent cluster or subject heterogeneity and induce correlation among observations sharing those effects. With nonlinear links, mixed-model coefficients generally have conditional rather than marginal interpretations (Fitzmaurice et al., 2011).

What are random effects?

Random effects represent deviations among clusters or subjects from the common fixed-effects structure. A random intercept allows different underlying levels, while a random slope permits relationships such as change over time to vary across clusters or individuals (Lash et al., 2021).

When should I use a linear mixed model?

A linear mixed model is a major option for continuous correlated outcomes when the analysis should explicitly represent cluster or subject heterogeneity, random intercepts or slopes, and the resulting covariance structure (Fitzmaurice et al., 2011; McCulloch & Searle, 2001).

Can GEE be used for repeated binary outcomes?

Yes. GEE can fit marginal models for clustered categorical responses. Agresti describes GEE specifically in the context of clustered categorical data, including working correlation structures and empirical robust standard errors (Agresti, 2013).

Can generalized linear mixed models handle binary or count outcomes?

Yes. GLMMs extend mixed-effects models to non-Gaussian outcomes through appropriate distributions and links. Conditional on random effects, responses can be modeled using distributions such as Bernoulli for binary outcomes or Poisson for counts (Fitzmaurice et al., 2011).

Are population-average and subject-specific effects interchangeable?

No. With nonlinear links, marginal and mixed-model regression parameters generally represent different quantities. A population-average effect describes the marginal population response, whereas a GLMM coefficient is generally conditional on the modeled random effects (Fitzmaurice et al., 2011).

Do matched categorical data count as correlated data?

Yes. Matched pairs and matched sets produce dependent categorical observations. Agresti treats methods for dependent proportions, conditional logistic regression, marginal models, GEE, and random-effects models as distinct approaches for matched or clustered categorical data (Agresti, 2013).

References

Agresti, A. (2013). Categorical data analysis (3rd ed.). Wiley.

Fitzmaurice, G. M., Laird, N. M., & Ware, J. H. (2011). Applied longitudinal analysis (2nd ed.). Wiley.

Lash, T. L., VanderWeele, T. J., Haneuse, S., & Rothman, K. J. (2021). Modern epidemiology (4th ed.). Wolters Kluwer.

McCulloch, C. E., & Searle, S. R. (2001). Generalized, linear, and mixed models. Wiley.

Need help with a similar research question?

Share a short, non-confidential summary of your study and the decision you need to make.

Send an enquiry