Independent, Dependent, Confounding and Mediating Variables: What They Actually Do in a Study
An independent variable is commonly the exposure, predictor or comparison of interest, while the dependent variable is the outcome being explained or estimated. A confounder is part of a causal structure that can distort the exposure-outcome comparison if not addressed. A mediator lies on a hypothesized pathway through which the exposure affects the outcome. These roles depend on the research question; they are not permanent properties of variables.
“Age is a confounding variable.”
Always?
For every outcome?
For every exposure?
No.
A variable does not walk into your dataset wearing a permanent badge that says:
CONFUNDER
Its role depends on the causal question.
That is the distinction many introductory variable definitions miss.
Independent and dependent variables: useful labels, but start with exposure and outcome
Suppose your question is:
Is distance to an adolescent-friendly clinic associated with use of the service?
You might call:
Independent variable: clinic distance.
Dependent variable: service use.
In epidemiology and much of health research, it is often clearer to say:
Exposure: clinic distance.
Outcome: service use.
Why?
Because “independent” can be misleading. The exposure may be statistically and causally related to many other variables.
It is not necessarily independent of anything.
The labels are useful for introductory thinking.
The causal structure matters more.
one example for the whole article
Use this study:
What is the effect of distance to an adolescent-friendly clinic on use of the service?
For illustration, suppose the causal story is:
Residential setting → clinic distance → perceived accessibility → service use
and:
Residential setting → service use
We now have several possible roles.
Exposure
Clinic distance.
Outcome
Service use.
Potential mediator
Perceived accessibility.
Potential confounding structure
Residential setting is a common cause of clinic distance and service use.
Now let us unpack each one.
What is a confounding variable?
In causal inference, confounding is not adequately defined as:
“a variable associated with both the independent and dependent variable.”
That shortcut can mislead.
A more useful causal question is whether there are non-causal pathways creating differences between exposed and unexposed groups that prevent a valid comparison of the causal effect of interest.
In the example:
Residential setting → distance
and:
Residential setting → service use
Residential setting can create a backdoor path between distance and service use.
If it is appropriately measured and the causal assumptions are correct, adjustment may help block that pathway.
But the label depends on the question.
If your exposure changed, the relevant confounding structure could also change.
Confounding belongs to an exposure-outcome question, not permanently to a variable.
What is a mediator?
A mediator lies on a hypothesized causal pathway from exposure to outcome.
For example:
Distance → perceived accessibility → service use
Here, actual distance may affect whether services feel accessible, which may then influence use.
Perceived accessibility is therefore a plausible mediator.
Now ask what you want to estimate.
Total effect question
What is the total effect of clinic distance on service use?
If you adjust for perceived accessibility, you may block part of the pathway through which distance operates.
You have changed the estimand.
Direct effect question
What is the effect of clinic distance on service use not operating through perceived accessibility?
Now mediation analysis becomes relevant, but estimating direct effects requires stronger assumptions and an analysis designed for that purpose.
Simply adding the mediator to a regression and comparing coefficients is not automatically a complete mediation analysis.
Confounder versus mediator: why timing matters
Consider:
Household income → clinic distance → service use
If household income influences residential location and transport options before clinic distance is experienced, it may be part of a confounding structure.
Now consider:
Clinic distance → transport burden → service use
Transport burden may be partly caused by distance.
That makes it a potential mediator.
The difference is causal position.
Not whether one variable has p < 0.05.
Bench Check: “adjusted for all potential confounders”
You wrote:
The model adjusted for age, education, income, knowledge, attitudes, distance, perceived access, service satisfaction and provider trust as potential confounders.
How did you decide that every item was a confounder?
Some may be:
- causes of the exposure and outcome;
- consequences of the exposure;
- mediators;
- consequences of the outcome;
- colliders;
- purely descriptive variables.
Calling everything a confounder does not make the model conservative.
It can change the question and, in some causal structures, introduce bias.
What is a collider, and why should I care?
This article is not titled “colliders,” but you need to know they exist.
A collider is a variable caused by two other variables along a path.
For example:
Exposure → Clinic attendance ← Health-seeking tendency
If you condition on clinic attendance, for example, by studying only clinic attendees, you can induce an association between the exposure and health-seeking tendency even if none existed before conditioning.
Causal diagrams are useful partly because they make this problem visible.
The lesson is not:
“Never adjust for anything.”
It is:
Adjustment decisions are causal decisions.
What is an effect modifier?
An effect modifier is different again.
Suppose the association between clinic distance and service use is much stronger among younger adolescents than older adolescents.
Age may modify the effect.
That means the effect differs across levels of age.
This is a substantive finding about heterogeneity.
Effect modification is not something to “control away.”
It may be something to report.
For example:
The estimated effect of distance on service use differed by age group, with a larger reduction in use among younger adolescents.
Whether effect modification is plausible should ideally be considered before endless subgroup testing begins.
Can the same variable be a confounder in one study and a mediator in another?
Yes.
Suppose income is the variable.
Question A:
What is the effect of education on healthcare use?
Income may partly mediate the effect of education on healthcare use:
Education → income → healthcare use
Question B:
What is the effect of insurance type on healthcare use?
Income may influence both insurance type and healthcare use.
Now it may be part of the confounding structure.
Same variable.
Different exposure-outcome question.
Different role.
This is why a textbook list of:
“Examples of confounding variables: age, sex, income...”
can only take you so far.
What about a “control variable”?
“Control variable” is often used loosely for anything placed in an adjusted model.
That phrase hides the reason for inclusion.
Methods Bench prefers naming the role where possible:
- confounder;
- design variable;
- precision variable;
- mediator;
- effect modifier;
- predictor;
- descriptive covariate.
Clear labels make the analysis easier to defend.
How do DAGs help?
A directed acyclic graph, or DAG, represents assumed causal relationships using arrows.
A DAG does not discover causality from the data.
It makes your assumptions visible.
That is useful because it forces you to ask:
- What causes the exposure?
- What causes the outcome?
- What happens after exposure?
- Which pathways should be blocked?
- Which pathways should remain open?
- Could adjustment open a non-causal path?
Two researchers can disagree about a DAG.
Excellent.
Now they are disagreeing about explicit causal assumptions rather than hiding them inside a regression model.
What do I actually write in my methods section?
Avoid vague wording:
All possible confounders were controlled for.
Prefer:
Potential confounders were identified a priori using previous evidence and an assumed causal structure. The primary model adjusted for residential setting and household socioeconomic position because these variables were considered common causes of clinic distance and service use. Perceived accessibility was treated as a potential mediator and was not included in the model estimating the total effect.
Only use this if it reflects the analysis you actually performed.
For effect modification:
We prespecified age group as a potential effect modifier and estimated stratum-specific effects/interactions as appropriate.
Again, the exact analysis should determine the wording.
Choose your primary exposure and outcome.
Write them at opposite ends of a page.
Then add:
- causes of the exposure;
- causes of the outcome;
- variables caused by the exposure;
- variables that may alter the effect.
Draw arrows.
Now look at the variables you planned to “control for.”
Do they all still belong in the same model?
Frequently asked questions
- What is the difference between independent and dependent variables?
The independent variable is commonly the exposure, predictor or comparison; the dependent variable is the outcome. In causal analysis, “exposure” and “outcome” are often clearer terms.
- What is a confounder?
A confounder is part of a causal structure that can create a non-causal association or bias the exposure-outcome comparison if not appropriately addressed.
- What is a mediator?
A mediator lies on a hypothesized causal pathway from exposure to outcome.
- Should I adjust for mediators?
Not automatically. If you want the total effect of the exposure, adjusting for a mediator may remove part of that effect. Direct and indirect effects require a different estimand and stronger assumptions.
- Is age always a confounder?
No. Its role depends on the exposure, outcome and causal structure.
- What is an effect modifier?
A variable across which the effect of the exposure differs. It represents heterogeneity of effect rather than a nuisance that must always be controlled.
Take the Methods Bench Conceptual Framework Worksheet and redraw your framework as a causal question:
Exposure → Outcome
Then position every other variable according to what you think causes what.
This should later feed into the Methods Bench Variable & Adjustment Planner.
References and further reading
- 1.Greenland S, Pearl J, Robins JM. Causal diagrams for epidemiologic research. Epidemiology. 1999;10(1):37-48.
- 2.Schisterman EF, Cole SR, Platt RW. Overadjustment bias and unnecessary adjustment in epidemiologic studies. Epidemiology. 2009;20(4):488-495. PMCID: PMC2744485.
- 3.Hernán MA, Robins JM. Causal Inference: What If.
- 4.Methods Bench. How to Choose Variables for a Quantitative Study Before You Open SPSS.
Take it further
Better research, once a week.
Practical methods guidance, research tools and funding opportunities from Methods Bench.
Get practical research notes and new opportunities
Short, useful emails for researchers in Uganda and East Africa. No spam.