Suppose an experiment sets players’ side-quest engagement to high to test whether it changes in-game purchases. In ordinary play, guild membership helps determine engagement. Once the experiment sets engagement, that incoming causal influence no longer describes how engagement was produced. Graph surgery changes the causal DAG to match the intervention. section 7.2.3
For an ideal intervention do(X=x), remove every edge entering X. Leave its outgoing edges in place: X can still affect its consequences. This differs from merely observing X=x, which can retain associations between X and its former causes. section 7.2.3 section 8.2.3
Cut the path through a common cause
Guild membership causes both side-quest engagement and in-game purchases, while engagement also causes purchases. Before intervention, engagement and purchases are connected both directly and through guild membership. Cutting the guild-membership → engagement edge removes the latter path; the engagement → purchases path remains. The transformed graph therefore isolates the dependence carried by engagement’s causal influence. section 7.2.4
Cutting edges is not the whole operation for a causal graphical model. Replace the target’s causal Markov kernel with a distribution assigning probability 1 to the chosen value. In the gaming example, setting engagement to high replaces a table conditioned on guild membership with one that assigns all probability to high, regardless of membership. section 7.2.3 section 7.2.5
Listing 7.11 Graph surgery on a DAG in pgmpy
from pgmpy.base import DAG
G = DAG([ #1
('Guild Membership', 'Side-quest Engagement'), #1
('Side-quest Engagement', 'In-game Purchases'), #1
('Guild Membership', 'In-game Purchases') #1
]) #1
G_int = G.do('Side-quest Engagement') #2
The pgmpy listing constructs the gaming DAG and calls G.do('Side-quest Engagement') to produce the edge-cut graph; assigning a fixed engagement value is a separate requirement for a full ideal intervention. section 7.2.3 section 7.2.5
Check what a library’s do operation actually changes. The described pgmpy BayesianNetwork.do performs graph surgery and replaces the target’s factor, but its replacement does not put all probability on one specified outcome. A fixed-value ideal intervention therefore needs an additional change to the target’s TabularCPD. PyMC’s do operation instead implements the intervention by effectively replacing the target’s model expression with a constant. section 7.2.5 section 11.6.1
Edge removal depends on the assignment mechanism. Random assignment removes incoming influence on the target even from unknown common causes. Assignment based on login time instead introduces a login-time → engagement mechanism, leaving a path that can bias the comparison with purchases. Both are stochastic interventions, but only the random assignment removes that source of bias. section 7.5.1
Graph surgery also supplies the action step of counterfactual inference: after using factual observations to update exogenous variables, cut incoming edges to the target in the hypothetical world and set its hypothetical value. Then predict outcomes in that modified world. This keeps a hypothetical condition distinct from simply conditioning on an observed value. section 9.1.2 section 9.5
