Medical education Key research skills
Volume 206 - Issue 11

Deconfounding confounding part 2: using directed acyclic graphs (DAGs)

Authors:  John R Attia, Christopher Oldmeadow, Elizabeth G Holliday and Michael P Jones

Med J Aust 2017; 206 (11): 480-483. || doi: 10.5694/mja16.01167
Published online: 19 June 2017

In the previous article on confounding in this series,1 we presented the traditional explanation of a confounder. Over the past few decades, it has become clear that this definition has many limitations. For example, confounding can be induced by a network of variables rather than just a single variable, and adjusting for potential confounders can paradoxically increase confounding.

What are directed acyclic graphs?

One of the few true innovations in epidemiological methods has been the emergence of directed acyclic graphs (DAGs) to identify confounding. This development began in the early 1990s with work by Pearl and Robins based on formal logic and machine learning.2-4 DAGs are a formal system of mapping variables and the direction of causal relationships among them. “Directed” refers to arrows indicating the direction of causality between variables, and “acyclic” means that it should not be possible to start from any one variable and follow a series of arrows back to the original variable. Entire books are devoted to this method,2-4 but just a few highlights are sufficient to help clinicians understand confounding.5

In the example of smoking (exposure) and dementia (outcome) that we used in the previous article, we postulated that alcohol might be a confounder.1 These relationships are illustrated using a simple DAG in Box 1. Drinking alcohol may increase the risk of smoking — hence the arrow pointing from alcohol to smoking — and may also increase the risk of developing dementia — hence the arrow pointing from alcohol to dementia — but alcohol is not an intermediate between smoking and dementia. Smoking leads to cardiovascular disease (CVD), which also increases the risk of dementia; in this case, CVD is an intermediate between smoking and dementia. Alcohol is likewise causally related to CVD. If we observe a relationship between smoking and dementia, it is therefore not clear whether this is valid or whether it is spurious because of the effect of the other variables.

How to read a DAG

The steps to take in interpreting a DAG are as follows:

  • Remove all arrows emanating from the exposure of interest.

  • Look for any remaining path, called a “backdoor path”, that links the outcome to the exposure. A path is defined by successive arrows regardless of the direction of the arrowheads.

  • A backdoor path is “closed” if any variable on that path is a “collider”, which is a variable with two arrowheads pointing into it from other variables on the same path.

  • If a backdoor path can be traced and is “open” (ie, it does not include a collider), then adjusting for any variable on that path will close the backdoor path and remove confounding.

  • Adjusting for a collider will reopen the backdoor path and increase confounding.

 

In our example (Box 1), when we remove the arrows pointing from the exposure (smoking), we can no longer trace a path from dementia through CVD to smoking. This means that CVD is not a confounder but a mediator. Adjusting for CVD could therefore remove part of the effect of smoking that we are trying to detect; this is called over-adjustment bias.6 However, we can still trace a path from dementia through alcohol to smoking. This path does not include a collider and is thus open. By adjusting for alcohol, we can close this backdoor path and remove confounding due to alcohol. Note that another backdoor path exists from dementia through CVD to alcohol and then smoking. Adjusting for alcohol has therefore closed two backdoor paths at once.

Using DAGs may seem like a convoluted process, with little benefit, compared with the old definition of confounding we presented in the previous article.1 This is certainly true when models are as simple as this one. But what happens when we want to tackle more complicated models? Let us assume we add the variables of socio-economic status (SES), diet, sex and age to the model, as shown in Box 2. How does the old definition of confounding apply here? Should we just adjust for everything?

The DAG helps us sort out these relationships and decide on covariates to include in regression models. Open backdoor paths in this model include:

  • Dementia – CVD – diet – SES – smoking

  • Dementia – alcohol – SES – smoking

  • Dementia – CVD – age – sex – smoking

 

We should therefore adjust for a variable on these paths to remove confounding (eg, adjusting for SES closes the first two backdoor paths and adjusting for age closes the third backdoor path). Note that CVD remains a mediator.

Another backdoor path that can be traced is:

  • Dementia – CVD – age – sex – alcohol – SES – smoking

 

This is already a closed path because alcohol is a collider on this path (ie, two arrows point into alcohol along this path, from sex and SES). Note that alcohol is a collider on this path but not necessarily on other paths. As this path is already closed, we do not need to adjust for any variables on it; indeed, if we were to adjust for alcohol (the collider), we would reopen a route for confounding!

It takes reading and practice to become familiar with these rules, but they are extremely powerful in teasing out complex causal pathways. The astute reader will realise that trying to reduce confounding by adjusting for one variable along an open backdoor path could increase confounding if that variable is also a collider on another backdoor path. For example, as we saw above, adjusting for alcohol could close the backdoor path of dementia – alcohol – smoking, but it could also reopen the closed path of dementia – CVD – diet – SES – alcohol – sex – smoking, because alcohol is a collider on this pathway (Box 2).

A tool to help readers learn to draw and interpret DAGs is a free software program called DAGitty (http://www.dagitty.net/dags.html).7 This program is reasonably intuitive, flexible and fast to learn. It allows the user to easily draw DAGs and, as a bonus, “reads” the DAG to provide the minimum set of variables for which it is essential to adjust to remove confounding. Other similar programs are also available, such as TETRAD (http://www.phil.cmu.edu/projects/tetrad), DAG (https://epi.dife.de/dag), and dagR, a set of functions for the statistical software R.

The power of DAGs

DAGs are powerful in that they lead us to several observations:

  • Identifying confounders depends on the underlying causal model that is assumed.

  • Confounding can be due to a network of variables, not just a single variable.

  • Assumptions (model) must be drawn before conclusions (analysis) are drawn.

  • The relationship between variables can be specified in many different ways (ie, the direction of the arrows can influence decisions made for analysis).

  • All backdoor paths must ultimately have one variable with an arrowhead leading into the exposure; this means that confounding in complex webs of causation can be analysed by looking for the few variables that have arrows pointing to the exposure.

  • Many routes of confounding can potentially be closed by adjusting for just one or two variables.

 

Adjusting for confounding

It could be argued that one should just adjust for all potential variables — the so-called kitchen sink approach — rather than taking any chances on specifying a potentially incorrect model. Although often appealing because of its simplicity, there are two main reasons why this approach is not recommended. The first is inefficiency: every variable that is added to the model uses degrees of freedom, which are the currency of power. This is particularly a problem for small studies, where problems such as over-fitting due to data sparsity and collinearity may arise.8 Adjusting for variables that are not confounders wastes power and may reduce the ability to detect an association. (There is a separate argument for including variables on the basis that they help explain the outcome and hence increase power; this can be thought of as “mopping up” some of the variance in the outcome so that there is more power to detect the contribution of the exposure, but this consideration is separate from confounding.) The second reason is bias: as we have seen, adjusting for a variable that is a collider reopens a backdoor path and increases the potential for confounding.

Ideally, every study should make explicit the causal model behind the analysis.

Residual confounding

Unfortunately, even accurate specification of the causal model and expert use of DAGs do not completely remove confounding. This situation is called residual confounding, which occurs for three reasons.

First, longitudinal data may not be available. With cross-sectional data, we can never be sure about the direction of causality (ie, the “chicken and egg” problem).

Second, as we are not able to measure most variables perfectly, even adjusting for a variable cannot fully remove its effect. If we think of confounding as a flow of water that travels along the backdoor path, our inability to accurately measure SES, for example, means that we are unable to fully turn off the tap at that point. This is an argument for possibly adjusting for multiple variables along a backdoor path, so that the flow of confounding is reduced at multiple points instead of one point only.

Third, in any observational study, we can never be sure that we have included and measured all the relevant potential confounders. What other variables have we not thought of, and not included on the diagram, that could create a backdoor path between our outcome and our exposure?

As we saw in the previous article,1 the ultimate solution to confounding is a randomised controlled trial. When this is possible, it means that all known and unknown confounders are evenly balanced across the arms of the trial, thus removing their ability to affect the outcome.

Box 1 – Simple causal diagram of smoking and dementia, with effect of alcohol (potential confounder) and cardiovascular disease (mediator)*


People who drink alcohol are also more likely to smoke; alcohol may affect risk of dementia and CVD; and CVD may influence risk of dementia (eg, through subclinical infarcts). Green arrows radiating from the exposure are ignored when reading the pathways for potential confounding. CVD = cardiovascular disease. *Figure originally drawn with DAGitty (http://www.dagitty.net/dags.html).

Box 2 – Causal diagram of smoking and dementia, with effect of alcohol (potential confounder) and cardiovascular disease (mediator), plus sex, age, socio-economic status and diet*


Sex influences alcohol consumption, smoking and age (men are more likely than women to drink alcohol and smoke, and women live longer than men); SES influences alcohol consumption, smoking and diet; diet influences CVD; and age influences risk of CVD and dementia. As in the simple model in , we have to adjust for alcohol to close the dementia – alcohol – smoking path. However, doing this reopens the dementia – CVD – diet – SES – alcohol – sex – smoking path, because alcohol is a collider on this path. So we have to also adjust for sex or SES, or both, to reclose this path. Adjusting for sex, alcohol and SES would therefore be sufficient to remove confounding in this analysis of smoking and dementia. CVD = cardiovascular disease. SES = socio-economic status. *Figure originally drawn with DAGitty (http://www.dagitty.net/dags.html).


Authors


Competing interests


References


Provenance: Commissioned; externally peer reviewed.

More like this