top of page
Search

Confounding variables: What are they and how to detect them?

  • Amanda Duim Ferreira
  • Jun 28
  • 9 min read

Updated: Aug 6

"Correlation is Not Causation: Understanding Confounding Variables in Research"


Correlation is not causation. One reason for spurious correlations is confounding variables. In this post, I will walk you through what a confounding variable is, providing examples from agricultural and environmental studies. Additionally, I will discuss how to use statistical methods to detect them. However, it is essential to keep in mind that no statistical method can fully solve confounding variables. Careful study and understanding of your research topic remain essential.


Understanding Confounding Variables


A confounding variable is a third factor associated with both the supposed cause (your independent variable) and the supposed effect (your outcome). This association can create a false or distorted impression of a relationship between them. A variable must meet three conditions to qualify as a confounder:


  • It must be associated with the exposure.

  • It must be an independent risk factor for the outcome.

  • It must not be on the causal pathway between exposure and outcome.


Examples of Confounders


Yield as an Outcome of Seeding Rate


When studying how a management choice affects yield (e.g., seeding rate, fertilizer use), climate variables often confound the relationship. For instance, in an analysis of the impact of seeding rate on yield, a weather variable such as cumulative precipitation may serve as a confounding variable. Let us examine how and in which cases cumulative precipitation can be a confounder.


Is cumulative precipitation associated with yield?

Yes, it can affect water availability for plant growth. If this variable is not controlled (e.g., randomized block design), differences in cumulative precipitation can mask the effect of seeding rate.


Is cumulative precipitation independent of the outcome (yield)?

Yes. Water availability drives crop growth through a mechanism unrelated to seeding rate. This means that precipitation affects yield even at a fixed plant density.


Is cumulative precipitation in the causal pathway between seeding rate and yield?

No. If cumulative precipitation is a mediator between yield and seeding rate, it disqualifies this weather variable as a confounder. For precipitation to be a mediator, the seeding rate would have to cause precipitation, which then causes yield. The seeding rate obviously does not change how much rain falls.


Cumulative Precipitation Diagram

In this diagram, precipitation points into both seeding rate and yield, and there is no arrow from seeding rate to precipitation. Thus, cumulative precipitation is not a mediator because seeding rate does not cause precipitation.


If precipitation can affect germination, does that mean it lies on the causal pathway between seeding rate and yield? The phrase "on the pathway" has a precise meaning: the variable must be a descendant of the exposure — i.e., seeding rate → precipitation → yield. For that to be true, the seeding rate would have to cause precipitation. Since the seeding rate does not change how much rain falls, the fact that precipitation causes germination does not place precipitation on the pathway. Precipitation still sits upstream, feeding into the chain from the side rather than sitting inside it. If you want to add germination to it, the pathway would be:


Germination Pathway Diagram

Mediators, Colliders, and Confounders


It is essential to pay attention to the roles of germination in the relationship between seeding rate and yield. Germination can act as a mediator or a collider:


  • A mediator is found in a chain: A high seeding rate leads to high germination, which causes high yields (seeding rate → germination → yield).

  • If two variables point to a third one in a causal pathway, the variable in the middle is a collider:

High seeding rate → High germination

High cumulative precipitation → High germination


In this case, germination is a collider:

seeding rate → germination ← cumulative precipitation


The same variable (germination) can serve different roles. This occurs because the role is path-specific. Consequently, one cannot classify a variable as "a confounder" or "a collider" in a general sense; it can only be classified concerning a particular path between two specific variables.


Two factors can independently produce good germination: a high seeding rate or favorable rainfall. In the field as a whole, these two factors do not inform one another. A farmer's choice of seeding rate does not influence how much rain falls. They are separate causes that happen to share one common effect: germination.


Berkson's Paradox


Bias appears when one restricts the view to plots that share the same germination outcome. This is what "adjusting for germination" or "looking only at well-established plots" does. Conditioning an analysis on a collider, whether through stratification or regression, can introduce a spurious association between its causes.


How does this happen? Start from a simple fact: a plot can achieve good germination through two different routes: heavy seeding or ample rain. Either one can suffice on its own. Imagine dividing your results by germination rates, resulting in the following four groups:


Germination Rate Groups

When examining all groups, there is no relation between germination rate and seeding rate (compare A and C) or between germination rate and rainfall (compare A and B). Every combination appears exactly once. High seeding occurs with high rain (A) and low rain (B); low seeding occurs with high rain (C) and low rain (D). This leads to the following conclusion:


Knowing a plot's seeding rate tells you nothing about how much rainfall the plot receives.


Germination has two routes: heavy seeding or good rain. Plots A, B, and C each possess at least one of those factors, resulting in good germination. Plot D is the only one lacking both: low seeding and low rain. This is when the error can occur: when evaluating only “good germination plots,” one introduces a filtering step. Adjusting for germination, analyzing only well-germinated plots, or simply having a dataset where failed plots were abandoned and never measured leads to the same outcome. In any case, D disappears.


Thus, within the remaining plots, low seeding consistently accompanies high rain, while low rain consistently accompanies high seeding. Seeding rate and rainfall now appear inversely related: when one decreases, the other increases. A correlation has emerged seemingly out of nowhere. This inverse relationship is not a fact about seeding and rain; it exists solely because the one box where both were low (D plot) is precisely the box that got filtered out.


Consequently, the pattern is an artifact of removing D, not a genuine feature of the field. This phenomenon is known as collider bias: germination acts as the collider (caused by both seeding and rain), and conditioning on it eliminates what kept the two causes independent, creating a correlation between two factors that had no relationship.


When observing only a filtered sample, one may perceive associations that do not exist. This counterintuitive aspect earns it the name "paradox": the numbers in the filtered data appear real and compelling, but they are artifacts of how the sample was selected, not reflections of actual relationships. Whether the filtering occurs through your model (adjusting for germination), through stratification (analyzing well-germinated plots separately), or through your data (only surviving plots being measured), the result is the same: an induced, non-causal link between seeding rate and rainfall contaminates the seeding-rate effect that is genuinely of interest.


How to Identify and Avoid Confounders


Identifying confounders is a causal, not purely statistical, challenge. Drawing causal diagrams (directed acyclic graphs, or DAGs) can clarify which variables are true confounders, mediators, or colliders. Before beginning data collection and experimentation, I recommend identifying possible confounders and planning accordingly. Here are some strategies:


Spatial Heterogeneity within a Field


The most commonly known confounder in agriculture is soil or field heterogeneity (fertility, moisture, slope, drainage varying across a plot). The randomized complete block design groups plots into blocks positioned to ensure conditions are as homogeneous within each block as possible (e.g., a block running across the slope contour, not down it). Every treatment appears exactly once per block, and the block effect is removed in the ANOVA.


Two Orthogonal Gradients at Once


When two nuisance gradients run in different directions, a Latin square blocks both simultaneously through rows and columns. Each treatment appears once in every row and once in every column.


Factors That Cannot Be Randomized at a Small Scale


For instance, irrigation, tillage, prescribed burning, or flooding can only be applied to large contiguous areas. Thus, applying them in a fully randomized small-plot layout is impractical. If you cluster them informally, they become confounders.


Measurable Baseline Difference


If the confounder is continuous and measurable before treatment, measure it and adjust statistically rather than (or in addition to) designing around it. Pre-treatment soil nitrogen, initial plant size, baseline pest density, or starting soil organic carbon are classic covariates. For example, in a fertilizer trial, if plots differ in starting soil N, measure soil N at the outset and include it as a covariate. ANCOVA estimates the treatment effect at a common baseline N, absorbing variation that blocking alone might miss.


Site-to-Site Variation Plus Natural Temporal Change


In environmental science, the dominant confounders are (a) inherent site differences and (b) changes over time. A simple before/after analysis at one impacted site cannot separate the impact from a background trend. Before-After-Control-Impact (BACI) designs measure both an impact site and one or more control sites, both before and after the perturbation. The impact effect is the difference in the before-to-after change between impact and control sites, which removes both the fixed site difference and the shared temporal trend.


Clustering and Pseudo Replication


When measurements are grouped (several cores per plot, several plots per farm, farms within regions, repeated samples per quadrat), treating subsamples as independent inflates your sample size falsely (pseudo replication). A nested or hierarchical design with random effects for the clustering levels (plot, farm, region, year) absorbs cluster-level confounding, allowing the treatment to be tested against the correct error term.


What If the Data Is Observational or If the Confounding Controls Failed?


When randomization, restriction, or matching is infeasible or imperfect, statistical adjustment is necessary to reduce confounding. In observational data, confounding is almost always present, particularly with nonrandom treatment allocation or self-selected exposures. Classical methods for detecting and assessing confounding include:


  • Crude vs Adjusted Estimates: This basic diagnostic compares the crude association to association estimates after adjustment. If the exposure–outcome effect changes meaningfully after adjusting for a covariate (e.g., ≥10–20% relative change), that covariate is considered an important confounder. However, change-in-estimate alone does not guarantee that a variable is conceptually a confounder; it must fit the causal definition.


  • Stratification and Mantel–Haenszel Methods: Data are split into levels of a potential confounder, and the exposure–outcome association is estimated within each stratum. If crude and stratum-specific associations differ, and stratum-specific estimates are similar across strata, the variable likely acts as a confounder rather than an effect modifier. The Mantel–Haenszel estimator combines stratum-specific odds ratios or risk ratios into a single adjusted measure and is widely used to detect and control confounding in 2×2 tables. However, this method becomes unwieldy with multiple confounders or continuous covariates.


  • Standardization: Direct and indirect standardization compares rates between groups after adjusting for confounders like soil nitrogen status or clay content. Differences between crude and standardized rates indicate confounding by the standardization variable(s).


  • Multivariable Regression: Linear, logistic, or Cox regression models include exposure and suspected confounders as predictors. The adjusted coefficient for exposure estimates its association with the outcome at fixed levels of confounders. Confounding is suggested when the exposure coefficient changes substantially upon adding a covariate that is causally plausible as a confounder. This method has advantages, such as handling numerous, continuous, and categorical confounders and allowing modeling interactions to distinguish effect modification from confounding. However, data-driven variable selection (p-value screening, stepwise procedures, AIC-only choice) can be misleading. A true confounder need not be statistically significant, and automated selection may omit key confounders or include mediators or colliders.


Key Takeaways for Practice


Throughout this post, one theme has run underneath every example:


Deciding what counts as a confounder is a question about causal structure, not about statistics.


A variable earns the label by occupying a particular position in the causal story, serving as a common cause of both the treatment and the outcome. Statistical significance cannot determine this; only reasoning about how the system operates can.


No statistical method can fully address unmeasured confounding; the confounders you did not record cannot be adjusted away, only designed around or reasoned about. This is where sensitivity analysis and, above all, sound study design carry the weight: randomization, blocking, BACI structures, and the other tools discussed exist precisely because analysis alone cannot rescue a study from unmeasured confounders.


Finally, credibility rests on transparency. Stating why each variable was controlled and why others, such as mediators or colliders, were deliberately excluded, grounded in explicit causal reasoning, distinguishes a defensible causal claim from a coincidental one. Environmental and agricultural sciences present rich ground for confounding due to classic culprits: soil properties, climate, management intensity, and human pressure. These factors tend to co-vary with both the focal "treatment" and the outcome of interest. They rarely arrive one at a time, and they seldom sort themselves out. Separating a true effect from this tangle of intertwined factors requires two consistent ingredients: careful causal reasoning to determine what to adjust for and well-chosen experimental or statistical designs to execute the adjustments. Get those elements right, and your conclusions will rest on the mechanisms you set out to study.


Recommended Literature


  • Gomez, K. A., & Gomez, A. A. (1984). Statistical procedures for agricultural research. John Wiley & Sons. Statistical Procedures for Agricultural Research

  • Byrnes JEK, Dee LE. Causal Inference With Observational Data and Unobserved Confounding Variables. Ecol Lett. 2025 Jan;28(1):e70023. doi: 10.1111/ele.70023. PMID: 39836442; PMCID: PMC11750058.

  • Griffith, G.J., Morris, T.T., Tudball, M.J. et al. Collider bias undermines our understanding of COVID-19 disease risk and severity. Nat Commun 11, 5749 (2020). Collider Bias in COVID-19

  • VanderWeele, T.J. Principles of confounder selection. Eur J Epidemiol 34, 211–219 (2019). Principles of Confounder Selection

  • Pourhoseingholi, M., Baghestani, A., & Vahedi, M. (2012). How to control confounding effects by statistical analysis. Gastroenterology and Hepatology From Bed to Bench, 5, 79 - 83. Controlling Confounding Effects

  • Split-Plot Designs

 
 
 

Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating

OUTTADESK COMUNICACAO E GERENCIAMENTO DE DADOS LTDA.

CNPJ: 66.889.737/0001-15

SÃO PAULO, BRASIL

outtadesk@gmail.com

+55(19)99798-3663

  • Instagram
  • LinkedIn

© 2025 by OuttaDesk. 

bottom of page