top of page
Search

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

  • Amanda Duim Ferreira
  • Jun 28
  • 9 min read

Correlation is not causation, and one reason for spurious correlations is confounding variables. In this post, we are walking you through what a confounding variable is, giving examples of them in agricultural and environmental studies. We are also going to discuss how to use statistical methods to detect them, but keep in mind that no statistical method can fully solve confounding variables. Carefully studying and understanding your research topic in deep remain essential.


Defining confounding variables

A confounding variable is a third factor that is associated with both the supposed cause (your independent variable) and the supposed effect (your outcome) and that can create a false or distorted impression of a relationship between them.

A variable must meet three conditions to be a confounder:

  • Associated with the exposure,

  • An independent risk factor for the outcome, and

  • Not 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. In an analysis of the impact of seeding rate on yield, a weather variable such as cumulative precipitation may be a confounding variable. In this example, let’s check 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 is not a controlled variable (e.g., randomized block design), differences in cumulative precipitation can mask the effect of seeding rate.


Is cumulative precipitation independent for the outcome (yield)?

Yes. Water availability drives crop growth through a mechanism that has nothing to do with seeding rate. Meaning that precipitation affects yield even at a fixed plant density.


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

No. If the cumulative precipitation is a mediator between yield and seedling 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, and the seeding rate obviously doesn't change how much rain falls.



In this diagram, precipitation points into both seeding rate and yield, and there's no arrow from seeding rate to precipitation. So, 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?

"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. Seeding rate doesn't change how much rain falls. The fact that precipitation causes germination doesn't put 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:




Mediators, colliders, and confounders

Attention to this, because germination can be a mediator or a collider in the relationship between seeding rate and yield:


A mediator is found in a chain: A high seeding rate led to high germination, and that caused 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



We have the same variable (germination) in two different roles. That happens because the role is path-specific. This is why you can't classify a variable as "a confounder" or "a collider" in a general sense; it can be classified only with respect to a particular path between two particular variables.


Two things can independently produce good germination: a high seeding rate or favorable rainfall. In the field as a whole, these two are not telling you anything about each other. A farmer's choice of seeding rate doesn't change how much rain falls. They're separate causes that happen to share one common effect: germination. 


Berkson's paradox

The bias appears the moment you restrict your view to plots that share the same germination outcome, which 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 reach good germination by two different routes: heavy seeding or plenty of rain. Either one can do the job on their own.

Imagine that you divided your results by germination rates, getting the following four groups:


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


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


Germination has two routes: heavy seeding or good rain. Plots A, B, and C each have at least one of those, so they germinate well. Plot D is the only one with neither: low seeding nor low rain. This is when the error can occur: when you evaluate only “good germination plots”, you are adding a filtering step: adjusting for germination, or analyzing only well-established plots, or simply having a dataset where failed plots were abandoned and never measured. Either way, D disappears.

So within the surviving plots, low seeding always travels with high rain, and low rain always travels with high seeding. Seeding rate and rainfall now look inversely related: push one down and the other is up. A correlation has appeared out of nowhere. That inverse relationship isn't a fact about seeding and rain. It exists only because the one box where both were low (D plot) is precisely the box that got filtered out.

That means that the pattern is an artifact of removing D, not a real feature of the field. That is the collider bias: germination is the collider (caused by both seeding and rain), and conditioning on it deletes what kept the two causes independent, manufacturing a correlation between two things that had nothing to do with each other.

When you observe only a filtered sample, you may perceive associations that do not actually exist. That's the counterintuitive part that earns it the name "paradox": the numbers in your filtered data look real and even compelling, but they're an artifact of how the sample was selected, not of how the world works. 

So whether the filtering happens by your model (adjusting for germination), by stratification (analyzing well-germinated plots separately), or by your data (only surviving plots got measured), the result is the same induced, non-causal link between seeding rate and rainfall, and that contaminates the seeding-rate effect you actually care about.



How to identify and avoid cofounders?

Confounder identification is a causal, not purely statistical, problem. You can draw causal diagrams (directed acyclic graphs, or DAGs) to clarify which variables are true confounders, mediators, or colliders. Before starting data collection and experimentation, try to identify possible confounders and plan accordingly. Here are some strategies:


Spatial heterogeneity within a field: The most commonly known confounder in agriculture is soil/field heterogeneity (fertility, moisture, slope, drainage varying across a plot). The randomized complete block design groups plots into blocks positioned so 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 you have two nuisance gradients running 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 can't be randomized at a small scale: For instance, irrigation, tillage, prescribed burning, or flooding can only be applied to large contiguous areas, so applying them in a fully randomized small-plot layout is impractical, and if you cluster them informally, they turn into 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, 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, soaking up variation that blocking alone might miss.


Site-to-site variation plus natural temporal change: In environmental science, the dominant confounders are (a) sites differ inherently and (b) everything changes over time anyway, so a simple before/after at one impacted site can't 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/hierarchical design with random effects for the clustering levels (plot, farm, region, year) absorbs cluster-level confounding, so the treatment is 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 required 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:


Crude vs Adjusted Estimates: This is a basic diagnostic to compare 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; 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 compare rates between groups after adjusting for confounders like N soil 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/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, as a common cause of both the treatment and the outcome. Statistical significance can't tell you that; only reasoning about how the system actually works can.

No statistical method fully solves unmeasured confounding; the confounders you didn't record can't 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 we covered exist precisely because analysis alone can't rescue a study from confounders it never measured.

Finally, credibility rests on transparency. Stating why each variable was controlled and why others, like mediators or colliders, were deliberately left out, grounded in explicit causal reasoning, is what separates a defensible causal claim from a coincidental one.

Environmental and agricultural sciences are rich ground for confounding because of their classic culprits: soil properties, climate, management intensity, and human pressure. They tend to co-vary with both the focal "treatment" and the outcome of interest. They rarely arrive one at a time, and they rarely sort themselves out. Separating a true effect from this tangle of intertwined factors takes the same two ingredients throughout: careful causal reasoning to decide what to adjust for, and well-chosen experimental or statistical designs to do the adjusting. Get those right, and your conclusions will rest on the mechanism you set out to study.




Recommended literature

Gomez, K. A., & Gomez, A. A. (1984). Statistical procedures for agricultural research. John Wiley & Sons. https://www.wiley.com/en-us/shop/general-introductory-agriculture/statistical-procedures-for-agricultural-research-2nd-edition-p-9780471870920

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). https://doi.org/10.1038/s41467-020-19478-2 

VanderWeele, T.J. Principles of confounder selection. Eur J Epidemiol 34, 211–219 (2019). https://doi.org/10.1007/s10654-019-00494-6 

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. https://doi.org/10.22037/ghfbb.v5i2.246





 
 
 

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