Probability

Causal Inference Basics: Correlation versus Intervention

Causal inference separates observing X from setting X, so learners can see when raw association is causal, when adjustment is needed, and when a hidden confounder leaves the effect unidentified.

status: reviewimportance: importantdifficulty 4/5math: graduateread: 20mlive demo

Concept Structure

Causal Inference Basics: Correlation versus Intervention

01Intuition

Start with the picture, metaphor, or geometric mechanism.

02Math

Make the objects explicit and connect them with notation.

03Code

Mirror the equations with runnable implementation details.

04Interactive Demo

Manipulate the mechanism and watch the idea respond.

3prerequisites
3next concepts
4related links

Learner Contract

What this page should let you do.

You are here becauseCausal inference separates observing X from setting X, so learners can see when raw association is causal, when adjustment is needed, and when a hidden confounder leaves the effect unidentified.

This Probability concept is the current idea: keep the same invariant visible across Intuition, Math, Code, Interactive Demo.

By the end4/4 sections ready | runnable code expected | live demo

Explain the mechanism, trace the main notation, and test one prediction in the live demo.

Do this firstIntuition

Read the intuition before the notation; the math should name a mechanism you already felt.

Then go nextBackdoor Frontdoor Identification (planned)

Follow this edge after making one prediction here; the next page should reuse the result, not restart the route.

Test the linkManipulate one control and predict the visible change.

Claim/source review status

Substantive review recorded

1/1 claims have bounded review metadata; still check caveats and source scope.Metadata-derived; review may be AI-assisted. Not a human certification.
Claims1/1 reviewed
Sources3 cited
Codeattached
Demolive
Reviewed2026-07-03
Updatedpage 2026-07-03

Learning item flow

4/4 sections readyAsk about thisResearch room
ConceptCausal Inference Basics: Correlation versus InterventionProbability
3 sources attachedLocal snapshot ready
concept:probability/causal-inference-basics
01

01

Intuition

Build the mental picture first so the rest of the page has something to attach to.

Section prompt

A predictive question asks what usually happens when we see X=xX=x.

A causal question asks what would happen if we set X=xX=x.

Those are not the same question. If learners keep only one distinction from this page, keep this one:

P(YX=x)observes a selected group, whileP(Ydo(X=x))changes the data-generating process.P(Y \mid X=x) \quad\text{observes a selected group, while}\quad P(Y \mid \mathrm{do}(X=x)) \quad\text{changes the data-generating process.}

Suppose a study program XX is more common among students who already have stronger preparation CC, and strong preparation also improves the exam outcome YY. Then the treated group can look much better even if part of that gap came from CC, not from the program.

The causal graph is not magic. It does not identify effects by itself. It is a contract about which arrows are allowed to carry causal influence. Once that contract is stated, it tells us what would have to be blocked, randomized, or measured before an association can answer a causal question.

In the small graph

CX,CY,XY,C \to X,\qquad C \to Y,\qquad X \to Y,

the path

XCYX \leftarrow C \to Y

is a back-door path from XX to YY. It makes treated and untreated groups differ before treatment happens. If CC is measured and is the only back-door path, we can compare treated and untreated outcomes inside each value of CC, then average those within-stratum contrasts using the original population mix of CC.

If CC is hidden, the honest answer is not "just control for something nearby." The effect is not identified from the visible (X,Y)(X,Y) table alone.

02

02

Math

Translate the story into symbols, assumptions, and a derivation you can inspect.

Section prompt

Let XX be a treatment or action, YY be an outcome, and CC be a measured pre-treatment common cause. Observational conditioning is

P(Y=1X=x).P(Y=1 \mid X=x).

Intervention uses Pearl's do-operator:

P(Y=1do(X=x)).P(Y=1 \mid \mathrm{do}(X=x)).

Graphically, do(X=x)\mathrm{do}(X=x) cuts incoming arrows into XX and sets XX from outside the system. In the toy graph, the intervention deletes the assignment mechanism

CXC \to X

while keeping the outcome mechanism

CY,XY.C \to Y,\qquad X \to Y.

The average causal effect for a binary treatment can be written as

ACE=P(Y=1do(X=1))P(Y=1do(X=0)).\mathrm{ACE} = P(Y=1 \mid \mathrm{do}(X=1)) - P(Y=1 \mid \mathrm{do}(X=0)).

If CC blocks the back-door path from XX to YY, the adjustment formula is

P(Y=1do(X=x))=cP(Y=1X=x,C=c)P(C=c).P(Y=1 \mid \mathrm{do}(X=x)) = \sum_c P(Y=1 \mid X=x, C=c)P(C=c).

Notice the weighting. We do not use P(C=cX=x)P(C=c \mid X=x), because that is the biased treatment-group mix. We use the population mix P(C=c)P(C=c) after comparing outcomes inside each CC stratum.

For the lab numbers:

P(C=1)=0.4,P(C=1)=0.4,

and the outcome table is

P(Y=1X=0,C=0)=0.10,P(Y=1X=1,C=0)=0.25,P(Y=1X=0,C=1)=0.55,P(Y=1X=1,C=1)=0.70.\begin{aligned} P(Y=1\mid X=0,C=0)&=0.10, & P(Y=1\mid X=1,C=0)&=0.25,\\ P(Y=1\mid X=0,C=1)&=0.55, & P(Y=1\mid X=1,C=1)&=0.70. \end{aligned}

Inside each stratum, treatment adds 0.150.15. Therefore

ACE=(0.250.10)(0.6)+(0.700.55)(0.4)=0.15.\mathrm{ACE} = (0.25-0.10)(0.6) + (0.70-0.55)(0.4) =0.15.

But if prepared learners are more likely to receive treatment, the raw observed contrast is much larger. That contrast is useful for prediction. It is not automatically the causal effect.

03

03

Code

Keep the implementation aligned with the notation so the algorithm is legible.

Section prompt
p_c = {0: 0.6, 1: 0.4}
p_x_given_c = {0: 0.2, 1: 0.8}  # confounded assignment
p_y = {
    (0, 0): 0.10,  # X=0, C=0
    (1, 0): 0.25,
    (0, 1): 0.55,
    (1, 1): 0.70,
}

def obs_y_given_x(x):
    px = sum(p_c[c] * (p_x_given_c[c] if x else 1 - p_x_given_c[c])
             for c in [0, 1])
    return sum(p_c[c] * (p_x_given_c[c] if x else 1 - p_x_given_c[c])
               * p_y[(x, c)] for c in [0, 1]) / px

def do_y(x):
    return sum(p_y[(x, c)] * p_c[c] for c in [0, 1])

raw = obs_y_given_x(1) - obs_y_given_x(0)
adjusted = do_y(1) - do_y(0)

print("raw association:", round(raw, 3))
print("back-door adjusted effect:", round(adjusted, 3))
print("bias from confounding:", round(raw - adjusted, 3))

The runnable code mirrors the math: the raw contrast weights CC by the treatment-selected mix, while the intervention calculation weights each stratum by the original population mix.

04

04

Interactive Demo

Use direct manipulation to connect the explanation to a moving system.

Section prompt

Use the Causal Intervention Lab as an observation-versus-action check.

Pick a case, then decide which estimate answers the causal question:

  • the raw observed treatment-control contrast,
  • the back-door adjusted contrast,
  • or "not identified" because the needed confounder is hidden.

Before reveal, the association, adjustment, and intervention ledgers stay locked. After reveal, inspect which arrow was cut, which path was blocked, and whether the visible table was enough.

Live Concept Demo

Explore Causal Inference Basics: Correlation versus Intervention

The stage is code-native and interactive. Use it to test the explanation against the mechanism.

difficulty 4/5graduatecode-aligned
Demo Prediction Checkpoint

Manipulate one control and predict the visible change.

Commit to what Causal Inference Basics: Correlation versus Intervention should make visible before reading the result.

After The First Pass

Turn the concept into an inspected object.

Once the invariant is visible in the intuition, math, code, and demo, use these panels to inspect the mechanism visually, check source support, practice the idea, and attach a grounded research question.

Mechanism Storyboard

See the idea move before the page explains it

Causal inference separates observing X from setting X, so learners can see when raw association is causal, when adjustment is needed, and when a hidden confounder leaves the effect unidentified.

Prediction open01 / Intuition
Prediction lens

Start with the picture, metaphor, or geometric mechanism.

Commit first

Before reading further, choose the kind of change Causal Inference Basics: Correlation versus Intervention should make visible.

Visual Inquiry

Make the image answer a mathematical question

Causal inference separates observing X from setting X, so learners can see when raw association is causal, when adjustment is needed, and when a hidden confounder leaves the effect unidentified.

4/4 stages readyLive demo connected
Prediction

Which visible object should carry the first intuition?

Commit first

Pick the cue that should make Causal Inference Basics: Correlation versus Intervention easier to reason about before the page gives the answer.

Source Grounding

Canonical references for the mechanism on this page.

paper · 2009Causal inference in statistics: An overviewJudea Pearl

Primary source for structural causal models, the do-operator, intervention as replacing structural equations, and back-door adjustment.

Open source
course-notes · 2013Advanced Data Analysis from an Elementary Point of View: Estimating Causal Effects from ObservationsCosma Shalizi

Course-book source for confounding, intervention distributions, and adjustment ideas for observational causal estimation.

Open source
course-notes · 2024STATS 361: Causal InferenceStefan Wager

Stanford graduate course notes for potential outcomes, randomized experiments, treatment effects, and the distinction between prediction and causal questions.

Open source

Claim Review

Causal inference separates observing X from setting X, so learners can see when raw association is causal, when adjustment is needed, and when a hidden confounder leaves the effect unidentified.

Status1 substantive review recorded

Claims without a substantive review badge still need exact source-support review.

Sources3 references

pearl-2009-causal-inference-overview, shalizi-2013-causal-estimation, wager-2024-stats361

Local checks4 local checks

Use equations, runnable code, and demos to check whether the source support is operational.

Substantively reviewedIn a causal DAG, conditioning on X=x and intervening with do(X=x) are different operations; if a measured pre-treatment variable blocks every back-door path from X to Y, the causal effect can be estimated by summing conditional outcome means over that variable's marginal distribution.Claim metadata: source checked

The sources support the page's distinction between observed association and intervention, the graph surgery intuition for do(X=x), randomized assignment as a special case where raw treatment-control contrast can be causal, and measured-confounder adjustment as a sufficient back-door strategy in the toy DAG.

Sources: Causal inference in statistics: An overview, Advanced Data Analysis from an Elementary Point of View: Estimating Causal Effects from Observations, STATS 361: Causal InferenceFinite binary teaching graph only; excludes front-door, do-calculus proofs, longitudinal treatment, interference, measurement error, selection bias, transportability, and causal discovery.A bounded review summary is present; still check caveats and exact reference scope.

Checked Pearl for do-operator and back-door adjustment framing, Shalizi for observational causal estimation and confounding, and Wager/STATS 361 for potential-outcome and randomized-treatment framing. GPT Pro publication critique remains pending because 127.0.0.1:51672 is unavailable.

Reviewer: codex-local-source-review; reviewed 2026-07-03

Practice Loop

Try the idea before it explains itself

Causal inference separates observing X from setting X, so learners can see when raw association is causal, when adjustment is needed, and when a hidden confounder leaves the effect unidentified.

Readiness0/3 checks ready
Predict

Before touching the demo, predict one visible change that should happen in Causal Inference Basics: Correlation versus Intervention.

Hint 1

Reveal when your model needs a nudge.

Hint 2

Reveal when your model needs a nudge.

Hint 3

Reveal when your model needs a nudge.

Grounded research drawerClose
ConceptCausal Inference Basics: Correlation versus InterventionProbability

Research Room

Attach the question to a claim, equation, code, or demo

Pick the concept, equation, source, runnable code, claim, misconception, or demo state before asking for help. The handoff keeps that page item in context.
Next local actionNo local draft saved yet

Open the draft below to save one note and next action in this browser.

conceptProbability

Causal Inference Basics: Correlation versus Intervention

Attached question

What is the smallest example that makes Causal Inference Basics: Correlation versus Intervention click without losing the math?

Local action draftNo local draft saved yetExpand only when ready to capture one local next action
Local action draft

This draft stays in this browser, attached to the selected learning item.

No local draft saved.
Evidence to inspect
  • References to inspect: attached references on this page.
  • Definition, prerequisite, and contrast concept links
  • The equation or runnable code that makes the concept operational
  • One demo state that shows the invariant instead of a slogan
What would resolve this
  • The learner can state the mechanism in their own words
  • The learner can name the prerequisite that would repair confusion
  • The learner can predict how the mechanism changes under one perturbation
Grounded AI handoff

I am working in Continuous Function's research reading room. Object: concept - Causal Inference Basics: Correlation versus Intervention Selected item key: recorded for copy. Context: Probability Page anchor: recorded for copy. Open question: What is the smallest example that makes Causal Inference Basics: Correlation versus Intervention click without losing the math? Evidence to inspect: - References to inspect: attached references on this page. - Definition, prerequisite, and contrast concept links - The equation or runnable code that makes the concept operational - One demo state that shows the invariant instead of a slogan What would resolve this: - The learner can state the mechanism in their own words - The learner can name the prerequisite that would repair confusion - The learner can predict how the mechanism changes under one perturbation Answer as a careful research tutor: stay source-grounded, separate verified evidence from assumptions, name the relevant math objects, and end with one next action.

View it in context
concept/concept-notebook/probability/causal-inference-basics concept:probability/causal-inference-basics