Total and Direct Effect Curves
Context: Prediction vs. Causation
Total Effect
Assume we know the nature of an association between two variables and . We can use that regularity or pattern to infer values of given new observations (or hypothetical values) of . In other words, we can infer (or predict) given that we see . In practice, this dependency of and is typically encoded in a mathematical model or, in our case, a Bayesian network.
We can express this formally as . The operator emphasizes that we are strictly observers in the domain of and . 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 causes according to some mechanism we understand. We can use that knowledge to infer how would respond if we set to a particular value. In this context, we are no longer merely observing taking on some value. Instead, we intervene in this domain and actively set to a value of our choice.
We can express the distribution of under one such intervention as . The operator emphasizes that we assign the value , 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.
Level 1 · Association
predicts · signals · is associated with
Level 2 · Intervention
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.
In this graph, a student’s influences whether they choose to take . 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 and influence . In turn, influences .
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.
For this first example, we recode as for zero hours and for any tutoring. The admission rate is the proportion of applicants for whom .
Research Questions
Given the domain, this question might be on top of the list: What is the effect of on ? 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 and operators:
-
What admission rate would we predict for students who took the tutorial?
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. -
How will the admission rate change as a result of participating in the tutoring sessions?
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 Effects | Direct 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 | |
| None | Specify Confounders and Non-Confounders using an Identification Criterion. Assert that there are no unobserved Confounders. |
| Influence Paths to Target | |
Loading SVG... | Loading SVG... |
Total & Direct Effects Curves
So far, we treated 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 or . Rather, we can evaluate the effect of the duration of .
Total Effects Analysis
We use Total Effects Analysis to predict the probability of admission from the number of tutoring hours an applicant received.
- Open the network in Validation Mode with no observations.
- Set as the Target Node.
- Select alone.
- Choose Analysis > Visual > Target > Target's Posterior > Curves > Total Effects.
- Choose Mean for both Target and Variables. Leave Use Hard Evidence cleared and click Show Sensitivity Chart.

The horizontal axis shows mean tutoring hours. BayesiaLab infers the mean of from the network. Because is coded 0 and 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 at its default. We designate as a Non-Confounder so that tutoring can influence admission through the final score.
- Right-click , choose Properties > Classes > Add Predefined Class, and select .
- Select alone and choose Direct Effects from the same Curves submenu.
- Keep both Mean settings and leave Use Hard Evidence cleared. Click Show Sensitivity Chart.
- BayesiaLab automatically adjusts for all Confounders by Likelihood Matching and produces the Direct Effects Curve.
The horizontal axis shows mean tutoring hours. BayesiaLab infers the mean of from the network. Because is coded 0 and is coded 1, the vertical axis gives the probability of admission.
Compare Total Effects and Direct Effects
The overlay shows the probability of for both Total Effects and Direct Effects.
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 fixed.