Skip to content
StatsOtter A workspace for causal thinking
Method library WORKFLOW / 038
Research workflow/4 steps

Bayesian regression discontinuity with credible intervals (CausalPy)

Source CausalPy — PyMC Labs
01
The method workspace

Follow the analysis.

Select a node to explore the method

Method mapInput → 4 steps → output
START WITHInput data
ARRIVE ATResults
Read step 01
Inside the methodReasoning, equations & implementation
Step 1 of 4
01
Data prep

Running variable, threshold, outcome

Data preparation — shapes the raw inputs into what the estimator expects.

What happens here

Treatment switches on at the cutoff c. Identification rests on continuity of everything else at c.

Formula
\tau=\lim_{x\downarrow c}\mathbb E[Y\mid X{=}x]-\lim_{x\uparrow c}\mathbb E[Y\mid X{=}x]
Reads fromNot specified Feeds intoNot specified
Key code
import causalpy as cp
# x running variable, cutoff c, treated = (x >= c)

Reference / docs ↗

Discussion on this step (0)
StatsOtterDiscussion starter · Editorial note

Before using this step, make its assumptions and its output explicit. A useful peer note explains what you would check, what could go wrong, or what would change your interpretation.

Questions to explore
  1. Which assumption matters most here, and what evidence could challenge it?
  2. What would you check before passing this output to the next step?

Peer discussion

  • Bring your experience, a question, or a different perspective.
02
Data contract

Inputs & data

A running variable with a known threshold, a binary treatment that switches on at the cutoff, and an outcome.

Show data format & exampleHide example

Format — x (running variable), y (outcome), treatment = 1{x ≥ cutoff}.

import causalpy as cp
result = cp.pymc_experiments.RegressionDiscontinuity(
    df, formula='y ~ 1 + x + treated', running_variable_name='x',
    treatment_threshold=0.5)
result.plot()
03
Read the evidence

Results & interpretation

2 figures Workflow discussion 2
01FigureBayesian RD: the posterior-mean fit with a 94% credible band on each side of the cutoff — the jump at the red threshold is the estimated effect.
02FigureA bandwidth-restricted refit using only points near the cutoff: the discontinuity estimate shifts — exactly why bandwidth is a robustness check, not a footnote.

Figures reproduced from CausalPy — PyMC Labs — unofficial community showcase; all credit to the original authors.

Context & interpretation

⚠️ Unofficial community showcase of causalpy. Not affiliated with the authors; all credit to them.

Fit a model on each side of the cutoff, put a posterior on the jump, and report a credible interval for the discontinuity — plus an honest look at how it moves with the bandwidth.

Peer notes

Discuss the workflow (2)

  • 2

    A full posterior on the discontinuity beats a point estimate ± SE for communicating uncertainty to non-stats stakeholders.

  • 0

    Nice that the bandwidth refit is built in as a robustness step. The estimate moving with the window is the whole RD ballgame.

    1

    Exactly — I always show the narrow-window and full-sample fits next to each other so nobody thinks the number is bandwidth-free.

IN THE MARGINS

Peer discussion