Suppose a subscriber leaves after a recommendation system fails to show a possible substitute for a favorite show. Would the subscriber have stayed if the substitute had appeared prominently? Counterfactual reasoning compares the observed outcome with an outcome under a condition that did not occur. That comparison can support attribution: whether the missing recommendation contributed to the departure. section 1.0
A counterfactual is more specific than a general intervention forecast. “What would purchases be if engagement were high?” asks about an intervention. “Given that this player had low engagement and low purchases, what would their purchases have been if engagement were high?” also conditions on what happened to that player. On the causal hierarchy, the first is a level 2 query; the second is a level 3 counterfactual query. section 10.1.1
To turn that question into an inference workflow:
- Represent the observed events in an actual world and the changed condition in a hypothetical world. Parallel-world graphs can also express questions involving more than two worlds. section 8.4.4 section 8.5
- Use the observations to infer what is uncertain about the case, impose the hypothetical action, and predict its outcome. For a discrete graphical model, an intervention can be implemented with `do`, followed by inference conditional on actual-world evidence. section 9.2.4
- Check the model’s assumptions before treating the answer as established. Two structural causal models can agree on observational and interventional distributions yet disagree on counterfactual outcomes. section 10.6.1
A lost game under a different strategy
In the Monty Hall problem, consider a player who stayed with their first door and lost. Condition on that actual loss, then ask whether they would have won by switching. The modeled probability is 100%: losing by staying means the first door lacked the car, while the remaining unopened door had it. If all that is known is that the player lost, the modeled probability of winning by switching is instead 2/3. The evidence available about the actual case changes the counterfactual answer. section 9.2.4
Listing 9.10 Infer the counterfactual distributions
cf_model = do(twin_world_graph, {'Strategy Hyp': 'switch'}) #1
infer = VariableElimination(cf_model) #2
cf_dist1 = infer.query( #3
['Win or Lose Hyp'], #3
evidence={'Strategy': 'stay', 'Win or Lose': 'lose'} #3
)
print(cf_dist1)
cf_dist2 = infer.query( #4
['Win or Lose Hyp'], #4
evidence={'Win or Lose': 'lose'} #4
)
print(cf_dist2)
The listing shows the discrete-model workflow: apply a hypothetical switch with `do`, then query the hypothetical outcome while supplying actual-world evidence through `VariableElimination`. section 9.2.4
Counterfactual analysis can instead target a predictive model: which changed loan-application features would flip a rejection to approval? A minimal feature change helps explain a classification, but it may be unrealistic; algorithmic recourse adds an actionability constraint. This differs from reasoning about the causal process that generated the application and its outcome. In decision systems, simulated outcomes under alternative policies can also inform credit assignment and regret. Neither a compelling explanation nor a good fit to observed data alone guarantees that a particular counterfactual is correct. section 8.1.3 section 8.1.5 section 10.6.1
