Part 1: Understanding Average Treatment Effects
Artificial Intelligence has become increasingly effective at predicting clinical outcomes, but prediction alone cannot determine whether a treatment actually caused an observed benefit. This distinction between prediction and causation lies at the heart of modern Clinical Decision Support (CDS). This article introduces the fundamental concepts of causal inference using a synthetic clinical dataset developed for educational purposes. Through practical examples, it explains counterfactuals, treatment-selection bias, confounding, propensity scores, and Inverse Probability Weighting (IPW), illustrating how these methods improve estimation of the Average Treatment Effect (ATE). Rather than emphasizing programming or mathematical detail, the focus is on developing an intuitive understanding of why causal inference matters and how it forms the foundation for personalized, AI-assisted clinical decision making. This article is the first in a two-part series that progresses from causal inference to individualized treatment recommendations and practical Clinical Decision Support systems.

The Physician’s Question
Imagine a physician treating a patient recently diagnosed with cancer.
Several treatment options may be available. One treatment may improve the patient’s chance of surviving the next year, while another may offer little benefit or expose the patient to unnecessary side effects. Naturally, the physician wants to answer a simple but important question:
Will this treatment actually benefit this patient?
At first glance, the answer appears straightforward. We could compare the one-year survival of patients who received the treatment with those who did not. If the treated patients had better survival, we might conclude that the treatment works.
Unfortunately, real-world medicine is rarely that simple.
Patients who receive a treatment are often fundamentally different from those who do not. They may differ in age, disease stage, performance status, genetic biomarkers, smoking history, or many other clinical characteristics. Physicians make treatment decisions based on these factors every day, and rightly so. Consequently, the treated and untreated groups are rarely directly comparable.
This raises an important question:
Did the treatment improve survival, or were the treated patients simply different to begin with?
That question is much more difficult than it first appears. It requires us to separate the effect of the treatment itself from the differences that already existed between the two groups of patients. This is the central challenge of causal inference.
In this article, I introduce the fundamental ideas behind causal inference using a synthetic clinical dataset developed for educational purposes. We will see why simple comparisons can be misleading, how propensity scores and inverse probability weighting (IPW) help create more comparable treatment groups, and how these methods provide a more credible estimate of the Average Treatment Effect (ATE).
In the second article of this series, we will build upon these ideas to estimate treatment benefits for individual patients using a T-learner, illustrating how modern AI techniques can support personalized Clinical Decision Support (CDS).
Prediction Is Not Causation
Imagine Modern machine learning has become remarkably good at making predictions. Given sufficient historical data, a model can estimate the probability that a patient will survive, develop a complication, or respond to a particular therapy. These predictions can be valuable, but they do not necessarily tell us whether a treatment caused the observed outcome.
To appreciate the difference, consider two related but fundamentally different questions.
- Prediction: What is likely to happen?
- Causation: What would happen if we changed the treatment decision?
The first question looks only at the future outcome. The second asks how the outcome would change under an alternative course of action.
This distinction is subtle but important.
Suppose historical data show that patients receiving a particular treatment have higher one-year survival than patients who do not receive it. It may be tempting to conclude that the treatment improved survival. However, the treated patients may have been younger, diagnosed earlier, or possessed favorable genetic biomarkers. Their better outcomes may have been due, at least in part, to these underlying characteristics rather than the treatment itself.
In other words, correlation does not necessarily imply causation.
This challenge is not unique to medicine. Engineers, economists, and business analysts face the same problem whenever they attempt to estimate the effect of an intervention using observational data. The central question becomes:
How can we isolate the effect of the treatment itself from all the other factors that influence the outcome?
Answering that question is the goal of causal inference.
In the following sections, we will build a simple synthetic clinical dataset that allows us to explore these ideas in a controlled environment. Because the underlying truth is known, we can objectively evaluate how well different causal inference techniques recover the actual treatment effect.
The Counterfactual: The Outcome We Never Observe
At the heart of causal inference lies a deceptively simple idea known as the counterfactual.
Suppose a physician decides to treat a patient. One year later, the patient survives. An obvious question follows:
Did the treatment cause the patient to survive?
Unfortunately, we can never answer that question with certainty for that individual patient.
Why?
Because we only observe one version of reality.
If the patient received the treatment, we observe the outcome with treatment. We never observe what would have happened without treatment. Conversely, if the patient did not receive the treatment, we observe the outcome without treatment, but we never know what the outcome would have been had the treatment been given.
These two potential outcomes are often represented as:
- Y(1) : Outcome if the patient receives treatment.
- Y(0) : Outcome if the patient does not receive treatment.
For any individual patient, only one of these outcomes can ever be observed. The other remains hypothetical, it is the counterfactual (Figure 1).
This is known as the Fundamental Problem of Causal Inference. Since one of the two potential outcomes is always missing, the true treatment effect for an individual patient can never be observed directly.
Fortunately, although the true treatment effect for an individual patient is unknowable, it is still possible to estimate treatment effects across a population using carefully designed statistical methods. These methods attempt to compare patients who are as similar as possible, differing primarily in whether they received the treatment.
This is precisely where causal inference differs from conventional predictive machine learning. Rather than simply predicting an outcome, it attempts to estimate what might have happened under an alternative treatment decision.

Figure 1: The counterfactual problem. For each patient, we can observe only one of the two potential outcomes (with treatment Y(1) or without treatment Y(0)). The other outcome remains unobserved, which is the counterfactual.
In the next section, we will construct a synthetic clinical dataset that allows us to simulate both potential outcomes. Because we control how the data are generated, we know the underlying treatment effects exactly. This provides an ideal environment for understanding how causal inference methods work before applying them to real-world clinical data.
Why Use Synthetic Data?
One of the greatest challenges in developing and evaluating causal inference methods is that the true treatment effect for an individual patient is fundamentally unknowable. We observe only one of the two possible outcomes, the one corresponding to the treatment that was actually received. The counterfactual outcome remains forever unobserved.
This creates an important practical problem. If the true treatment effect is never known, how can we determine whether a causal inference method is producing accurate estimates?
One solution is to construct a synthetic dataset in which the underlying relationships are deliberately engineered by the investigator. Unlike real clinical data, where the truth is hidden, synthetic data allow us to define the treatment assignment mechanism, the survival probabilities, and the true treatment effect for every individual patient.
For this article, I developed a synthetic clinical dataset representing 5,000 fictional patients diagnosed with a hypothetical disease that I refer to as Cancer-X. The disease itself is fictional and serves only as an educational example. The objective is not to model a specific cancer, but to create a realistic environment for demonstrating the fundamental concepts of causal inference and Clinical Decision Support.
Each patient is characterized by several baseline clinical features, including age, smoking history, disease stage, performance status, and biomarker status. These variables influence both the probability of receiving treatment and the patient’s expected survival. By carefully controlling these relationships, we can introduce realistic treatment-selection bias, evaluate causal inference methods, and compare their estimates with the known ground truth.
This ability to compare an estimated treatment effect with the true underlying treatment effect is one of the greatest advantages of synthetic data. It transforms an otherwise impossible validation problem into a controlled scientific experiment.
Engineering a Realistic Dataset
The synthetic dataset was designed to resemble a realistic clinical decision-making environment rather than to model any specific disease. The objective was to create a patient population in which physicians would reasonably make different treatment decisions based on each patient’s clinical characteristics.
Five baseline variables were selected to describe each patient:
- Age (years)
- Smoking history (pack-years)
- Disease stage (1–4)
- Performance status (0–3)
- Biomarker status (positive or negative)
These variables are commonly referred to as baseline covariates because they are measured before the treatment decision is made. In real clinical practice, physicians routinely consider these and many other factors when deciding whether a patient should receive a particular therapy. The baseline covariates are also known as features (X) in machine learning.
The values assigned to these variables were generated to resemble realistic patient populations while remaining entirely synthetic. The precise probability distributions are not important for understanding the concepts presented in this article. What is important is that the variables exhibit sufficient diversity to create meaningful differences among patients.
The next step was to model how treatment decisions are made.
As a result, the synthetic dataset intentionally contains treatment-selection bias. The treated and untreated groups differ systematically before treatment is even evaluated. For example, patients with more advanced disease or favorable biomarkers were more likely to receive treatment, while patients with poorer performance status were somewhat less likely to be treated. This phenomenon is known as confounding and is one of the principal reasons why simple comparisons between the two groups can produce biased estimates of the Average Treatment Effect (ATE).
This intentional treatment-selection bias is known as confounding. It creates systematic differences between the treated and untreated groups, making a simple comparison of their outcomes potentially misleading.
Finally, the synthetic dataset was engineered so that treatment genuinely improves survival for some patients more than others. Consequently, each patient possesses an underlying true individual treatment effect, although this quantity is known only because the data are simulated. In real clinical datasets, the true treatment effect for an individual patient can never be observed directly.
By controlling both the treatment assignment process and the underlying treatment effects, the synthetic dataset becomes a valuable laboratory for studying causal inference methods under conditions that resemble real-world clinical practice.
A Naive Comparison of the Two Groups
Suppose we momentarily ignore the treatment-selection bias built into our synthetic dataset and simply compare the one-year survival of the treated and untreated patients. This approach is known as the naive estimate of the Average Treatment Effect (ATE). It assumes that the only meaningful difference between the two groups is whether they received the treatment.
The naive ATE is calculated simply as:
Naive ATE = (Average survival of treated patients − Average survival of untreated patients)
Applying this calculation to the synthetic dataset produced the following result (Table 1):
Table 1. ATE Values from Dataset Simulation.
| Estimate | Value |
| Naive ATE | 3.40% |
| True ATE | 4.40% |
At first glance, the treatment appears to improve one-year survival by 3.4 percentage points. However, because we engineered the synthetic dataset, we know that the true Average Treatment Effect is actually 4.4 percentage points. The discrepancy is not caused by an error in the calculation. The arithmetic is perfectly correct.
Rather, the naive comparison is biased because the treated and untreated groups were systematically different before treatment was ever administered. Patients with different disease stages, biomarker status, and performance status were not equally likely to receive treatment. Consequently, part of the observed difference in survival reflects differences in the patient populations rather than the effect of the treatment itself (Figure 2).

Figure 2: A naive comparison of one-year survival between the treated and untreated patient groups. The observed difference in mean survival (31.2% vs. 27.8%) suggests an Average Treatment Effect (ATE) of 3.4%. However, because the two groups differ systematically in their baseline characteristics, this naïve estimate is biased and does not represent the true causal effect of the treatment.
The important lesson is that a simple comparison between treated and untreated patients does not necessarily estimate the causal effect of the treatment. It estimates the combined influence of the treatment and the differences that already existed between the two groups.
This is precisely the problem that causal inference seeks to solve.
Propensity Scores: Making the Groups Comparable
The naive comparison presented in the previous section is biased because the treated and untreated patients are fundamentally different before treatment is even administered. To estimate the causal effect of the treatment, we first need to account for these differences.
One elegant solution is the propensity score (Figure 3).

Figure 3: The propensity score is the estimated probability that a patient receives treatment based on baseline covariates. It predicts treatment assignment rather than clinical outcome and serves as the basis for Inverse Probability Weighting (IPW).
The propensity score is defined as the probability that a patient receives treatment based solely on the patient’s baseline characteristics (covariates). In our synthetic dataset, these covariates include age, smoking history, disease stage, performance status, and biomarker status.
Conceptually, the propensity score answers the following question:
Given this patient’s characteristics, how likely is the physician to recommend treatment?
Notice that the propensity score does not estimate whether the patient will survive. Nor does it estimate whether the treatment is effective. It estimates only the probability of receiving treatment.
Patients with similar propensity scores have similar baseline characteristics, even if one patient received treatment and the other did not. This provides a common basis for comparing patients who are otherwise clinically alike.
To estimate the propensity score, I trained a logistic regression model using only the baseline covariates. The model predicts the probability of treatment assignment for every patient in the synthetic dataset.

Figure 4: Distribution of the estimated propensity scores for treated and untreated patients in the synthetic dataset. Each patient’s propensity score represents the estimated probability of receiving treatment based on the baseline covariates. Although the two distributions overlap substantially, they are not identical, reflecting the treatment-selection bias intentionally introduced into the dataset. These propensity scores form the basis for Inverse Probability Weighting (IPW).
The overlap between the two distributions is particularly important. It indicates that patients with similar baseline characteristics exist in both the treated and untreated groups, making meaningful causal comparisons possible after appropriate statistical adjustment.
The resulting propensity scores range between 0 and 1. Patients with values close to 1 were highly likely to receive treatment based on their clinical characteristics, whereas patients with values close to 0 were unlikely to be treated.
The propensity score itself does not remove bias. Rather, it provides a quantitative measure of how likely each patient was to receive treatment. In the next section, we will use these propensity scores to rebalance the treated and untreated groups through Inverse Probability Weighting (IPW).
Inverse Probability Weighting (IPW): Rebalancing the Patient Population
The propensity score tells us how likely each patient was to receive treatment based on their baseline characteristics. However, knowing these probabilities alone does not remove the treatment-selection bias.
The next question is:
How can we use the propensity scores to create a fairer comparison between the treated and untreated groups?
One elegant solution is Inverse Probability Weighting (IPW).
The basic idea is surprisingly intuitive. Patients who received the treatment despite being unlikely to receive it provide particularly valuable information. Likewise, untreated patients who were highly likely to receive treatment are also informative because they represent patients who are relatively uncommon within their respective groups.
IPW assigns a statistical weight to every patient based on the inverse of the patient’s propensity score.
Patients who were very likely to receive the treatment receive relatively small weights because many similar patients already exist in the dataset. In contrast, patients who were unlikely to receive the treatment receive larger weights because they are comparatively rare and therefore have greater influence in the weighted analysis.
Rather than changing the patients themselves, IPW changes how much influence each patient has when estimating the Average Treatment Effect (ATE). In effect, it creates a weighted pseudo-population in which the treated and untreated groups become much more comparable with respect to their baseline characteristics.
The goal is not to eliminate all differences between patients. Rather, it is to reduce the systematic differences that arose from the treatment-selection process. By making the two groups more similar before comparing their outcomes, IPW produces a more credible estimate of the causal effect of the treatment.

Figure 5: Conceptual illustration of Inverse Probability Weighting (IPW). Rather than changing the patients in the dataset, IPW assigns different statistical weights to individual patients based on their propensity scores, creating a weighted pseudo-population in which the treated and untreated groups become more comparable. This reduces bias due to treatment-selection and confounding when estimating the Average Treatment Effect (ATE).
This improvement can be seen by comparing the baseline characteristics of the treated and untreated patient groups before and after applying IPW.
Table 2. Comparison of mean baseline covariates between the treated and untreated patient groups before Inverse Probability Weighting (IPW). The observed differences illustrate the presence of treatment-selection bias and confounding in the synthetic dataset.
| Mean Values | Age | Smoking History | Stage | Performance Status | Biomarker Positive |
| Untreated | 64.76 | 30.06 | 2.65 | 1.26 | 32.4% |
| Treated | 66.27 | 30.85 | 3.11 | 0.89 | 43.3% |
| Difference | 1.51 | 0.80 | 0.45 | -0.37 | 10.90% |
Before weighting, the treated and untreated groups differ noticeably in age, disease stage, performance status, and biomarker status (Table 2). These differences reflect the treatment-selection bias intentionally engineered into the synthetic dataset. Consequently, a direct comparison of outcomes between the two groups is likely to produce a biased estimate of the treatment effect.
Table 3. Comparison of mean baseline covariates between the treated and untreated patient groups after Inverse Probability Weighting (IPW). The substantially reduced differences demonstrate improved covariate balance, creating treatment groups that are more comparable for estimating the Average Treatment Effect (ATE).
| Mean Values | Age | Smoking History | Stage | Performance Status | Biomarker Positive |
| Untreated | 65.03 | 30.21 | 2.74 | 1.19 | 34.3% |
| Treated | 64.94 | 29.99 | 2.71 | 1.15 | 33.1% |
| Difference | -0.09 | -0.22 | -0.03 | -0.03 | -1.2% |
After applying IPW, the differences between the two groups become substantially smaller (Table 3). Although the original patient data remain unchanged, the statistical weighting creates a pseudo-population in which the treated and untreated groups are much better balanced with respect to their measured baseline covariates. This improved covariate balance forms the basis for a more credible causal comparison.
Having created more comparable treatment groups, we can now re-estimate the Average Treatment Effect (Table 4).
Table 4. Average Treatment Effect across Techniques
| Estimate | Value |
| Naive ATE | 3.4% |
| IPW ATE | 4.9% |
| True ATE | 4.4% |
The IPW estimate is noticeably closer to the true Average Treatment Effect than the naive estimate. This illustrates the primary purpose of IPW: not to guarantee the correct answer, but to reduce bias arising from treatment-selection and confounding by creating treatment groups that are more comparable.
Estimating the Average Treatment Effect
The results presented in Table 4 illustrate the impact of adjusting for treatment-selection bias using Inverse Probability Weighting (IPW).
The naive comparison estimated a treatment benefit of 3.4 percentage points, whereas the IPW-adjusted analysis estimated a treatment benefit of 4.9 percentage points. Because the synthetic dataset was engineered with a known true Average Treatment Effect of 4.4 percentage points, we are able to compare both estimates with the underlying ground truth.
The naive estimate underestimates the true treatment effect because the treated and untreated groups were systematically different before treatment was administered. Patients were not assigned treatment at random; treatment decisions depended on their baseline clinical characteristics. Consequently, a simple comparison between the two groups cannot isolate the causal effect of the treatment.
After applying IPW, the estimated treatment effect moves substantially closer to the known true value. This does not imply that IPW always produces the correct answer. Rather, it demonstrates how reducing treatment-selection bias through improved covariate balance can produce a more credible estimate of the causal effect.
One of the greatest advantages of this synthetic experiment is that the true treatment effect is known because the dataset was synthetically generated. This allows us to objectively evaluate the performance of different causal inference methods. In real-world observational studies, the true Average Treatment Effect is generally unknown, making such direct validation impossible.
The goal of causal inference is therefore not to eliminate uncertainty, but to make treatment-effect estimates more reliable by accounting for systematic differences between the groups being compared.
Limitations of This Demonstration
Although the synthetic experiment illustrates the fundamental concepts of causal inference, it is important to recognize its limitations. The objective of this demonstration is educational, to explain the fundamental concepts of causal inference using a controlled synthetic dataset, rather than to develop or validate a clinical decision support system.
First, the dataset is entirely synthetic. The relationships between the patient characteristics, treatment assignment, and clinical outcomes were deliberately engineered to create a controlled learning environment. While the variables and treatment-selection process resemble real clinical decision making, they do not represent any specific disease or patient population.
Second, the synthetic dataset assumes that all important patient characteristics influencing treatment assignment have been measured. In real-world clinical practice, this assumption is rarely satisfied. Important factors such as physician judgment, patient preferences, socioeconomic status, genetic information, or unrecorded clinical observations may also influence treatment decisions. These unmeasured confounders remain one of the greatest challenges in causal inference.
Third, propensity score methods, including Inverse Probability Weighting (IPW), estimate population-level treatment effects. They answer questions such as:
Does the treatment improve outcomes on average across the patient population?
They do not answer a physician’s most important question:
Will this treatment benefit the individual patient sitting in front of me?
Finally, although IPW reduced the bias in this synthetic experiment, it did not perfectly recover the true Average Treatment Effect. Statistical adjustment improves the credibility of the estimate, but it does not eliminate uncertainty. Like all statistical models, causal inference methods depend on the quality of the available data and the validity of their underlying assumptions.
These limitations should not be viewed as weaknesses of causal inference. Rather, they reflect the inherent difficulty of estimating treatment effects from observational data. The goal is not perfect certainty, but better-informed decision making through principled statistical methods.
Looking Ahead: From Population Averages to Personalized Treatment Decisions
Throughout this article, we have focused on estimating the Average Treatment Effect (ATE), the expected benefit of a treatment across an entire patient population. Causal inference methods such as propensity scores and Inverse Probability Weighting (IPW) help reduce treatment-selection bias and produce more credible estimates of these population‑level effects.
These methods answer an important scientific question:
Does the treatment work, on average?
However, physicians rarely treat the “average” patient.
Every patient is unique, with a distinct combination of age, disease stage, performance status, biomarkers, medical history, and many other clinical characteristics. The question facing the physician is therefore much more personal:
Will this treatment benefit the individual patient sitting in front of me?
Answering that question requires estimating an Individual Treatment Effect (ITE) rather than a single average treatment effect across the population. Unlike the ATE, which summarizes the average benefit, the ITE attempts to estimate how much a particular patient is expected to benefit from the treatment compared with the alternative of not receiving it.
Modern machine learning provides powerful tools for estimating these individualized treatment effects. One such approach is the T-learner, which builds separate predictive models for treated and untreated patients and estimates the treatment benefit for each individual by comparing the predicted outcomes under the two treatment scenarios.
In the next article, we will build upon the causal inference concepts introduced here to develop a simple AI-assisted Clinical Decision Support (CDS) system based on the T-learner. Although the demonstration will again use synthetic data, it will illustrate how causal inference and machine learning can be combined to estimate personalized treatment benefits and support more informed clinical decision making.
Ultimately, Clinical Decision Support is not about replacing physicians. It is about providing them with better quantitative evidence to complement their clinical expertise. The physician remains the final decision maker, but AI can assist by analyzing complex relationships and estimating treatment effects that are impossible to calculate mentally during routine clinical practice.
Related Resources
This article is part of an educational series on causal machine learning and Clinical Decision Support.
- Companion Article (Part 1):
Why Prediction Is Not Enough: A Practical Introduction to Causal Inference for Clinical Decision Support - Companion Article (Part 2):
Why Personalized Treatment Effects Matter: Building AI-Assisted Clinical Decision Support with a T-Learner - Live Clinical Decision Support Demonstration:
https://models.mlpowersai.com/cds-estimate.html
Call to Action
Explore the live Clinical Decision Support demonstration and discover custom Healthcare AI solutions.
The Clinical Decision Support application described in this article is now available as an interactive demonstration.
MLPowersAI develops custom machine learning and causal AI solutions for healthcare, life sciences, and process industries. We build deployment-ready applications that transform data into practical decision-support tools while maintaining scientific transparency and interpretability.
Our expertise spans predictive machine learning, causal inference, clinical decision support, digital twins, and AI agents for scientific and industrial applications.
🔗 Visit us at MLPowersAI.com
🔗 Connect via LinkedIn for discussions or collaboration inquiries.
Acknowledgement
The opening illustration and Figures 1, 2, 3, and 5 were created using OpenAI’s ChatGPT image generation capabilities. Figure 4 was generated programmatically from the author’s Python code within a Jupyter Notebook. The concepts, figure design, interpretation, and accompanying captions were developed, reviewed, and validated by the author.








