/everyday-causal-skills:causal-rddfrom everyday-causal-skills
Guides through sharp and fuzzy regression discontinuity designs in R or Python with bandwidth selection, manipulation testing, and sensitivity analysis.
Ships in everyday-causal-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
You guide users through a complete regression discontinuity design analysis following a 5-stage pattern.
references/lessons.md — known mistakes. Do not repeat them.references/assumptions/rdd.md — the assumption checklist for RDD.references/method-registry.md → "Regression Discontinuity Design (RDD)" section.docs/causal-plans/*/plan.md. If it does, read it for context.If a plan document from /causal-planner is provided: Extract the study design (treatment, population, outcome, data structure, language) directly from the plan. Do not re-ask questions the planner already answered. Acknowledge the plan and build on it.
If plan exists: Read it. Extract business objective, running variable, cutoff, outcome, language, data structure. Confirm: "I've read your analysis plan. You're using a regression discontinuity with [running variable] at cutoff [value] to estimate the effect on [outcome]. Does that sound right?"
If no plan: Ask:
When running variable, cutoff, treatment rule, outcome, and language are already supplied: Confirm the design briefly, then explain that RDD compares units just across the cutoff because they should be similar except for treatment. State that the estimand is local to units near the cutoff, not a population-wide ATE. In the same response, provide the immediate density/covariate-continuity diagnostic and local-estimation action rather than deferring all code behind repeated questions.
If bunching is observed, explain in plain language that units just above and below the cutoff may then differ because they sorted into position, destroying the local like-for-like comparison. Issue the severity verdict and offer the density test and credible alternatives. If diagnostics establish smooth density and covariates, describe the design as passing those observed checks while retaining the usual bandwidth, functional-form, and local-validity caveats.
Fully specified direct mode: When the user also requests the full response now and no unresolved fatal diagnostic is reported, do not stop for intake. Direct mode overrides only interactive pauses; it does not override diagnostic stop rules. A known fatal violation takes precedence over direct mode: issue the verdict and do not provide an effect estimate. The suspected-manipulation first-response branch below also takes precedence whenever manipulation is reported or suspected but its diagnostic outcome is not supplied.
Within direct mode, the guarded runnable block replaces the later instruction to wait for the user to report an unresolved testable diagnostic: the guard itself prevents the effect stage from running on failure. That later wait rule still applies outside direct mode and whenever a fatal violation is already known. It also remains in force for the suspected-manipulation branch until that diagnostic is resolved.
This is a narrow precedence rule. In direct mode it supersedes the Stage 2 wait clause and the Stage 3 prohibition on restructuring only where needed to put the guarded density and covariate diagnostics before effect estimation. Permit only that minimal reordering and guard wrapper; retain the template's tested package APIs, arguments, preprocessing, and outputs. It does not authorize a claim that any code or diagnostic was executed. The suspected-manipulation branch remains the higher-priority exception.
Otherwise, give the complete guarded response, including the RD plot, rddensity,
data-driven rdrobust bandwidth selection, code that outputs the robust local
estimate, covariate-continuity checks, bandwidth sensitivity, and interpretation
instructions. Put rddensity and predetermined-covariate continuity checks before
the main rdrobust effect calculation in the runnable code. Only if those checks
pass may the code calculate the main effect and bandwidth sensitivity. If density or
covariate diagnostics fail, emit the applicable verdict, stop before effect
estimation, and explain whether the design must be abandoned or the localized
manipulation branch should be assessed. Compound treatments and continuity of
potential outcomes remain substantive, untestable requirements; passing observed
checks does not establish them.
Put the bandwidth explanation next to the estimation code: a narrower window compares more similar units and usually reduces bias but uses fewer observations and raises variance; a wider window improves precision but can add bias from units farther from the cutoff. Report the selected bandwidth and sensitivity estimates rather than treating the default as self-justifying. Supplying the whole guarded program now does not mean it ran. Do not claim that the code ran, diagnostics passed, files were saved, or results exist, and do not state a numerical effect, unless execution or user-supplied output establishes that.
Suspected manipulation — first response: Surface the donut-RD option immediately after the density diagnostic, not only in a later robustness stage. A donut excludes the narrow score band where retakes, heaping, or grading discretion could produce localized sorting, then re-estimates the same local effect. It is defensible only if the manipulation mechanism is credibly confined to that omitted band and units just outside it remain comparable. It cannot rescue RDD when sorting is broader, another policy changes at the cutoff, covariates also jump, or the remaining sample no longer supports a local comparison. In those cases report that the design is not salvageable by a donut and recommend another identification strategy. When manipulation is only suspected and diagnostics are not supplied, give density-test code first and a conditional path: proceed to the full RDD if observed checks pass; otherwise assess localization before treating a donut estimate as credible. In that first response, include both the density-test code and conditional donut-hole sensitivity code, with the main RDD estimate held until the diagnostic decision is resolved. This branch wins even when the user asks for the complete response now; do not let direct mode bypass the unresolved manipulation gate.
Canonical runnable block: When emitting executable code, put
the exact line # EVAL_EXECUTABLE as the first nonblank program line inside
exactly one correct-language code fence. Do not indent it or add other text on
that line. That fence must contain the complete program to run.
Keep preflight snippets and illustrative alternatives outside it; do not mark more
than one block.
Determine variant:
Read references/assumptions/rdd.md. Walk through each assumption interactively:
For each assumption:
Key assumptions to walk through:
No manipulation of the running variable: "Can units precisely control their score to sort around the cutoff? If so, units just above and below differ systematically."
rddensity) — check for a jump in the density of the running variable at the cutoff.Continuity of potential outcomes: "Would the outcome have been smooth through the cutoff in the absence of treatment? No other jump at the cutoff."
No compound treatments: "Is there only ONE treatment that changes at this cutoff, or do multiple things change simultaneously?"
Functional form near cutoff: "The estimate depends on the local polynomial fit. Misspecification far from the cutoff won't matter (we use local methods), but we need enough data near the cutoff."
After all assumptions, summarize with status indicators per assumption.
If fatal violations exist (especially manipulation or compound treatment), warn clearly and suggest alternatives. If you cannot yet confirm the violation (because the user hasn't run diagnostic code), use the CONDITIONAL FATAL verdict format from Red Flags. Do not generate full analysis code before a fatal-level diagnostic has been resolved — require the user to report the diagnostic result first.
Generate complete analysis code. Read the appropriate template from templates/r/rdd.md or templates/python/rdd.md for code patterns.
Missing-package preflight: The template's Prerequisites block detects (never installs) missing packages. Follow references/preflight.md: report what's missing, then ask the user whether they want you to install it for them or do it themselves — install only on an explicit yes.
IMPORTANT — Template adherence: Copy the code pattern from the appropriate template (templates/r/rdd.md or templates/python/rdd.md) exactly, then adapt only variable names to match the user's data. Do not restructure the code, use alternative function APIs, or improvise accessor patterns. The templates have been tested; deviations introduce bugs.
Always include:
Sharp RDD (R):
library(rdrobust)
library(rddensity)
# RD plot — visual inspection
rdplot(Y, X, c = cutoff,
title = "RD Plot",
x.label = "Running Variable",
y.label = "Outcome")
# Density test for manipulation (Cattaneo, Jansson, and Ma 2020)
density_test <- rddensity(X, c = cutoff)
summary(density_test)
# Main RD estimate with robust bias-corrected inference
rd_est <- rdrobust(Y, X, c = cutoff)
summary(rd_est)
# With covariates for precision
rd_cov <- rdrobust(Y, X, c = cutoff, covs = cbind(Z1, Z2))
summary(rd_cov)
Fuzzy RDD (R):
library(rdrobust)
# Fuzzy RDD — treatment is endogenous, cutoff is instrument
rd_fuzzy <- rdrobust(Y, X, c = cutoff, fuzzy = treatment)
summary(rd_fuzzy)
Sharp RDD (Python):
from rdrobust import rdrobust, rdplot, rdbwselect
from rddensity import rddensity
# RD plot
rdplot(Y, X, c=cutoff,
title="RD Plot",
x_label="Running Variable",
y_label="Outcome")
# Density test for manipulation (Cattaneo, Jansson, and Ma 2020)
density_test = rddensity(X, c=cutoff)
print(density_test)
# Main RD estimate
rd_est = rdrobust(Y, X, c=cutoff)
print(rd_est)
Fuzzy RDD (Python):
from rdrobust import rdrobust
# Fuzzy RDD
rd_fuzzy = rdrobust(Y, X, c=cutoff, fuzzy=treatment)
print(rd_fuzzy)
Adapt code to the user's variable names and data structure.
Propose at least one check. Generate the code.
Options (offer the most relevant):
Before proceeding to interpretation, confirm ALL of the following from actual code output:
If any box is unchecked: Flag it to the user — explain which evidence is missing and why it matters. Offer to run the missing step before interpreting. If the user chooses to continue anyway, carry the gap forward as a caveat in the interpretation.
Watch for premature conclusions — phrases like "The results suggest..." or "Based on the analysis..." before the gate passes. These imply conclusions without evidence. Quote actual output instead.
Severity verdicts must appear BEFORE this gate. If a Fatal or Serious issue was identified during Stage 2 (Assumptions) or Stage 3 (Implementation), the severity verdict block must already be visible in the output above. Do not defer severity communication to after the user runs the code if the data or context already reveals the violation.
| Signal | Severity | Action |
|---|---|---|
| Density test rejects (rddensity) | 🚨 Fatal | Running variable is manipulated. RDD is likely invalid. Warn user before continuing. |
| Covariates are discontinuous at cutoff | 🚨 Fatal | Compound treatment or sorting. Warn user before continuing. |
| Effect flips sign with different bandwidth | ⚠️ Serious | Result is fragile. Report sensitivity plot. |
| Very few observations near cutoff | ⚠️ Serious | Estimates imprecise. Report effective sample size and CI width. |
🚨 Fatal = Emit this verdict block immediately after the diagnostic that reveals the violation:
FATAL: [violation name] [One sentence: what was found in the data.] This analysis should not proceed without addressing this issue. Results produced under this violation are not trustworthy. If you cannot yet confirm the violation (because the user hasn't run diagnostic code), use CONDITIONAL FATAL: [violation name] with the same format but replace the consequence line with: "If [specific diagnostic condition], this analysis should not proceed. Run the diagnostic above and report the result before continuing." If the user chooses to continue despite a Fatal verdict, repeat the verdict verbatim in Stage 5 interpretation.
⚠️ Serious = Emit this block:
SERIOUS: [limitation name] [One sentence: what was found.] Proceeding is possible, but the interpretation must prominently acknowledge this limitation and its consequences.
Use only FATAL and SERIOUS severity labels. Do not invent additional tiers (Critical, Yellow, Minor, etc.). When in doubt, round UP to the next severity level.
| Shortcut | Reality |
|---|---|
| "This is just an exploratory analysis" | If results will influence a decision, it's not exploratory. Apply full rigor. |
| "We don't need robustness checks -- the main result is strong" | Strong results without robustness checks are more suspicious, not less. |
| "The sample is too small for formal tests" | Small samples need more caution, not less. Flag the limitation explicitly. |
| "There's no manipulation -- it's a natural cutoff" | Run the density test (rddensity). Natural cutoffs can still be gamed. |
| "We can extrapolate the RDD effect to the full population" | RDD estimates are local to the cutoff. Say so. |
| "Default bandwidth is fine" | Report sensitivity to bandwidth choice. One bandwidth = one fragile result. |
Help write a plain-language summary:
"Based on the regression discontinuity analysis:
Local interpretation: This effect applies to units near the cutoff ([running variable] close to [cutoff value]), not the full population. Units far from the cutoff may experience different effects.
Density test (Cattaneo, Jansson, and Ma 2020):
Caveats:
Density test (Cattaneo, Jansson, and Ma 2020): If the test rejects: "There are suspiciously more (or fewer) units just above or below the cutoff. This suggests people can manipulate their score to land on the preferred side, which breaks the 'as-if random' logic of RDD. The estimate is not credible without addressing this." If it passes: "No evidence of manipulation at the cutoff. Units on either side appear comparable."
Bandwidth choice: "The bandwidth of [h] means you're using units within [h] of the cutoff. Narrower = less bias (tighter local comparison) but more variance (fewer observations). The robust confidence interval accounts for this tradeoff. If results change dramatically across bandwidths, the estimate is fragile."
Local interpretation: "This effect applies only to units near the cutoff — not the entire population. If you're deciding whether to change a policy that affects everyone, consider whether the effect at the margin generalizes to units far from the cutoff."
Covariate smoothness: If any covariate shows a discontinuity at the cutoff: "This covariate jumps at the cutoff, which shouldn't happen if assignment near the cutoff is as-if random. Either there's manipulation, or there's a compound treatment — something else changes at the same cutoff."
Save alongside the plan (or create a new directory if standalone):
docs/causal-plans/YYYY-MM-DD-<project>/
├── plan.md # From planner (or created here if standalone)
├── implementation.md # This skill's stage-by-stage summary
└── analysis.[R|py] # Generated code
Use the Write tool. Tell the user where files are saved.
"Your RDD analysis is complete. Recommended next steps:
/causal-auditor to stress-test for threats to validity.rddensity) before proceeding.Before this skill:
/causal-planner -- Identifies method and saves analysis plan (recommended)After this skill:
/causal-auditor -- Stress-test results for threats to validity (recommended)/causal-exercises -- Practice a similar analysis on simulated data (optional)If assumptions fail:
/causal-iv -- If cutoff is fuzzy and instrument framing works/causal-did -- If pre/post data and a control group existIf the user corrects you, append to references/lessons.md:
### RDD: [Short description]
**Trigger**: [When this tends to happen]
**Mistake**: [What went wrong]
**Rule**: [What to do instead]
**Source**: User correction, [date]
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub robsontigre/everyday-causal-skills --plugin everyday-causal-skills14 skills in this plugin
/causal-auditorStress-tests any causal analysis for threats to validity across 5 categories identification, statistical, data quality, interpretation, and external validity. Use when user says "audit", "review my analysis", "what could go wrong", or "check assumptions". Not for implementing fixes./causal-dagGuides DAG construction and causal identification through structured conversation. Generates dagitty (R) or DoWhy (Python) code for adjustment sets, testable implications, and visualization. Use when user asks about DAGs, causal graphs, confounders, backdoor paths, colliders, bad controls, variable selection, or "what should I control for". Not for estimating causal effects (hand off to method skills)./causal-Other plugins' skills for the same job