Skip to Content

Total and Direct Effect Curves

Context: Prediction vs. Causation

Total Effect

Assume we know the nature of an association between two variables X\mathit{X} and Y\mathit{Y}. We can use that regularity or pattern to infer values of Y\mathit{Y} given new observations (or hypothetical values) of X\mathit{X}. In other words, we can infer (or predict) Y\mathit{Y} given that we see X\mathit{X}. In practice, this dependency of X\mathit{X} and Y\mathit{Y} is typically encoded in a mathematical model or, in our case, a Bayesian network.

We can express this formally as P(Y∣see⁡(X))P(Y \mid \operatorname{\mathbf{see}}(X)). The see⁡\operatorname{\mathbf{see}} operator emphasizes that we are strictly observers in the domain of X\mathit{X} and Y\mathit{Y}. In Pearl’s Causal Hierarchy (PCH), this type of predictive inference would give us an answer for a question on Level 1. Level 1. Association (Seeing)

In BayesiaLab, predictive inference can be performed using Total Effects.

Direct Effect

Assume we know that X\mathit{X} causes Y\mathit{Y} according to some mechanism we understand. We can use that knowledge to infer how Y\mathit{Y} would respond if we set X\mathit{X} to a particular value. In this context, we are no longer merely observing X\mathit{X} taking on some value. Instead, we intervene in this domain and actively set X\mathit{X} to a value of our choice.

We can express the distribution of Y\mathit{Y} under one such intervention as P(Y∣do⁡(X))P(Y \mid \operatorname{\mathbf{do}}(X)). The do⁡\operatorname{\mathbf{do}} operator emphasizes that we assign X\mathit{X} the value xx, regardless of what would ordinarily determine its value. In Pearl’s Causal Hierarchy (PCH), this type of causal inference answers a question at Level 2. Level 2. Intervention (Doing)

In BayesiaLab, the Direct Effects function is intended to answer this intervention question. However, for Direct Effects to calculate causal inference correctly, we need to provide BayesiaLab with our assumptions regarding the Confounders.

Two Types of Inference
Total Effects · Prediction

Level 1 · Association

P(Y∣see⁡(X))P(Y \mid \operatorname{\mathbf{see}}(X))

predicts · signals · is associated with
Direct Effects · Causation

Level 2 · Intervention

P(Y∣do⁡(X))P(Y \mid \operatorname{\mathbf{do}}(X))

causes · produces · brings about

Caveat

Because BayesiaLab’s Total Effects and Direct Effects are often confused, one caveat is worth stating up front. Despite their similar names, the two functions measure different quantities. An analogy may help clarify the distinction.

Consider first how two metrics can describe the same relationship. Pearson correlation describes the strength and direction of the linear association between two variables, while mutual information captures dependence more broadly, including nonlinear patterns. Reporting both gives complementary views of that relationship.

Total Effects and Direct Effects are more like the width and height of a window. Both dimensions can be measured in centimeters, and for a square window the numbers even match. Yet “How wide is it?” and “How tall is it?” are different questions. When we speak of the effect of one variable on another, we likewise need to be clear about the question we are asking. Are we reasoning from what we see or from what we do?

Introductory Example

Students preparing to apply to a university take an initial math test. After seeing their score, they decide whether to take math tutoring before they have to take their final math test. The university takes their final math score into account when deciding whom to admit. We can represent this admissions process graphically.

Loading SVG...
Click to Zoom

In this graph, a student’s Initial Math Score\mathit{Initial\ Math\ Score} influences whether they choose to take Math Tutoring\mathit{Math\ Tutoring}. Students who score lower on the first test may seek tutoring to prepare for the final test, while those who score higher may feel less need for additional practice.

We assume that both Initial Math Score\mathit{Initial\ Math\ Score} and Math Tutoring\mathit{Math\ Tutoring} influence Final Math Score\mathit{Final\ Math\ Score}. In turn, Final Math Score\mathit{Final\ Math\ Score} influences University Admission\mathit{University\ Admission}.

Note that we have encoded our causal understanding of the domain, not merely associations. The causal directions we have asserted don’t imply anything about the strength of influence between any of the variables. The influence could be positive, negative, or even zero. What we assert is that the arcs assert the only possible directions. Here, we can easily validate it by considering the temporal order of the events in the admissions process.

To make this example more tangible, we have created a synthetic dataset. For each applicant, we recorded the following variables.

Initial Math Score∈[50,100]Math Tutoring∈{0,4,8,12}(hours)Final Math Score∈[50,100]University Admission∈{False,True}\begin{aligned} \mathit{Initial\ Math\ Score} &\in [50, 100] \\ \mathit{Math\ Tutoring} &\in \{0, 4, 8, 12\} \quad \text{(hours)} \\ \mathit{Final\ Math\ Score} &\in [50, 100] \\ \mathit{University\ Admission} &\in \{\mathrm{False}, \mathrm{True}\} \end{aligned}

For this first example, we recode Math Tutoring\mathit{Math\ Tutoring} as False\mathrm{False} for zero hours and True\mathrm{True} for any tutoring. The admission rate is the proportion of applicants for whom University Admission=True\mathit{University\ Admission} = \mathrm{True}.

Research Questions

Given the domain, this question might be on top of the list: What is the effect of Math Tutoring\mathit{Math\ Tutoring} on University Admission\mathit{University\ Admission}? While it sounds straightforward, there is ambiguity in this question, and we could interpret it in two ways. To emphasize the difference between the questions, we have added the see\mathbf{see} and do\mathbf{do} operators:

  1. What admission rate would we predict for students who took the tutorial? Admission Rate=f(see⁡(Math Tutoring=True))\text{Admission Rate} = \mathord{f\bigl(\operatorname{\mathbf{see}}(\mathit{Math\ Tutoring} = \mathrm{True})\bigr)}
    This would be a Level 1 question in Pearl’s Causal Hierarchy. It would also be very easy to answer; a simple crosstab in a spreadsheet would give us this result. Given the ease of calculation, one could be tempted to report it first without much thought.

  2. How will the admission rate change as a result of participating in the tutoring sessions? Admission Rate=f(do⁡(Math Tutoring=True))\text{Admission Rate} = \mathord{f\bigl(\operatorname{\mathbf{do}}(\mathit{Math\ Tutoring} = \mathrm{True})\bigr)}
    This is the question students have in mind when they ask whether tutoring would improve their chances. It is presumably the more interesting question, but it can’t be answered as easily. It would be a Level 2 question in Pearl’s Causal Hierarchy.

Total Effect vs. Direct Effect

To answer both questions, we need to draw on the principles established in Causal Identificationuse BayesiaLab’s Total Effects and Direct Effects functions. They are shown side by side in the following table.

Total EffectsDirect Effects
Question
Level 1 · Association

What would the admission rate be for the students participating in tutoring?

Level 2 · Intervention

What would be the admission rate if tutoring were mandatory for all students?

Requirements
NoneSpecify Confounders and Non-Confounders using an Identification Criterion. Assert that there are no unobserved Confounders.
Influence Paths to Target
Loading SVG...
Click to Zoom
Total Effects estimates the predictive effect without conditioning on any node, using causal and non-causal paths.
Loading SVG...
Click to Zoom
Direct Effects estimates the causal effect exclusively along the causal path. Matching on the Confounder Initial Math Score\mathit{Initial\ Math\ Score} blocks the non-causal path, and declaring Final Math Score\mathit{Final\ Math\ Score} a Non-Confounder, the causal path from Math Tutoring\mathit{Math\ Tutoring} to University Admission\mathit{University\ Admission} remains open.

Total & Direct Effects Curves

So far, we treated Math Tutoring\mathit{Math\ Tutoring} as a binary variable. However, our data set includes the number of hours that students participated in tutoring.

As a result, we are not restricted to performing inference on Math Tutoring=True\mathit{Math\ Tutoring} = \mathrm{True} or Math Tutoring=False\mathit{Math\ Tutoring} = \mathrm{False}. Rather, we can evaluate the effect of the duration of Math Tutoring\mathit{Math\ Tutoring}.

Total Effects Analysis

We use Total Effects Analysis to predict the probability of admission from the number of tutoring hours an applicant received.

Math Tutoring Network
XBL
  1. Open the network in Validation Mode with no observations.
  2. Set University Admission\mathit{University\ Admission} as the Target Node.
  3. Select Math Tutoring\mathit{Math\ Tutoring} alone.
  4. Choose Analysis > Visual > Target > Target's Posterior > Curves > Total Effects.
  5. Choose Mean for both Target and Variables. Leave Use Hard Evidence cleared and click Show Sensitivity Chart.
Target Mean Analysis settings. Mean is selected for Target and Variables, and Use Hard Evidence is unchecked.
Loading SVG...
Total Effects. Applicants who sought more tutoring tended to have lower initial scores, so the predicted probability of admission falls as tutoring hours increase.

The horizontal axis shows mean tutoring hours. BayesiaLab infers the mean of University Admission\mathit{University\ Admission} from the network. Because False\mathrm{False} is coded 0 and True\mathrm{True} is coded 1, the vertical axis gives the probability of admission.

Direct Effects Analysis

We use Direct Effects Analysis to estimate how assigning tutoring hours would change the probability of admission.

By default, BayesiaLab all nodes as Confounders by default, so we can leave Initial Math Score\mathit{Initial\ Math\ Score} at its default. We designate Final Math Score\mathit{Final\ Math\ Score} as a Non-Confounder so that tutoring can influence admission through the final score.

  1. Right-click Final Math Score\mathit{Final\ Math\ Score}, choose Properties > Classes > Add Predefined Class, and select Non_Confounder\mathrm{Non\_Confounder}.
  2. Select Math Tutoring\mathit{Math\ Tutoring} alone and choose Direct Effects from the same Curves submenu.
  3. Keep both Mean settings and leave Use Hard Evidence cleared. Click Show Sensitivity Chart.
  4. BayesiaLab automatically adjusts for all Confounders by Likelihood Matching and produces the Direct Effects Curve.
Loading SVG...
Direct Effects. For the same population of applicants, the estimated probability of admission increases as more tutoring hours are assigned.

The horizontal axis shows mean tutoring hours. BayesiaLab infers the mean of University Admission\mathit{University\ Admission} from the network. Because False\mathrm{False} is coded 0 and True\mathrm{True} is coded 1, the vertical axis gives the probability of admission.

Compare Total Effects and Direct Effects

The overlay shows the probability of University Admission=True\mathit{University\ Admission} = \mathrm{True} for both Total Effects and Direct Effects.

Loading SVG...
Click to Zoom

The Total Effects curve predicts admission for the applicants who chose each number of tutoring hours. The Direct Effects curve estimates admission if the same population received each number of hours, keeping the distribution of Initial Math Score\mathit{Initial\ Math\ Score} fixed.