StatsOtter Causal inference workflows
11
Workflow·3 steps

Did someone manipulate the cutoff? (rddensity)

Summary by StatsOtter

The standard manipulation test for RD designs — checks whether the running variable's density jumps at the cutoff (a sign units sorted around it).

1

Input · what goes in

A numeric vector of the running (forcing) variable and the cutoff c.

Show data format & exampleHide example
running var x
-0.42
-0.05
0.18
0.77
2

Pipeline · the recipe

↑ Click any step in the diagram to read its logic, code, assumptions & discussion.

1
Data prep

Take the running variable

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

What happens here

Collect the forcing variable (centered so the cutoff is 0).

Reads from the input data Feeds into #2
Key code
# Install:  install.packages("rddensity")   # R  ·  pip install rddensity  (Python)
library(rddensity)
set.seed(42)
x <- rnorm(2000, mean = 0, sd = 1)

Reference / docs ↗

Discussion on this step (0)
  • No comments on this step yet — be the first.
2
Diagnostic / pre-tests

Run the manipulation test

A pre-flight check — run this before trusting any estimate downstream.

What happens here

rddensity fits local-polynomial densities on both sides and tests for a jump at the cutoff.

Reads from #1 Feeds into #3
Key code
out <- rddensity(X = x, c = 0)
summary(out)

Reference / docs ↗

Discussion on this step (0)
  • No comments on this step yet — be the first.
3
Reporting

Plot the two densities

Reporting — turn the numbers into a figure or table a reader can act on.

What happens here

rdplotdensity overlays the estimated densities with confidence bands so you can see whether they meet at the cutoff.

Reads from #2 Feeds into the final output
Key code
rdplotdensity(out, x)

Reference / docs ↗

Discussion on this step (0)
  • No comments on this step yet — be the first.
3

Output · what you get

Estimated density of the running variable on each side of the cutoff — overlapping confidence bands at the cutoff mean no manipulation.
Fig 1Estimated density of the running variable on each side of the cutoff — overlapping confidence bands at the cutoff mean no manipulation.

Result figure rendered by StatsOtter from the package's documented example — unofficial community showcase; all credit to the original authors.

Result · the numbers

T=\dfrac{\hat f_{+}(c)-\hat f_{-}(c)}{\sqrt{\widehat{\mathrm{Var}}}}\ \xrightarrow{\ H_0\ }\ \mathcal N(0,1)

⚠️ Unofficial community showcase of rddensity (docs). Not affiliated with the authors — all credit to Matias D. Cattaneo, Michael Jansson & Xinwei Ma; this summarizes public documentation.

What it does. A regression-discontinuity design is only credible if units couldn't precisely manipulate the running variable. rddensity runs the density-continuity (manipulation) test: is there a discontinuity in the density of the running variable exactly at the cutoff?

How it works. It fits local-polynomial density estimators on each side of the cutoff and tests whether they differ there, using a robust bias-corrected statistic. A large p-value supports no manipulation; a small one warns that sorting may invalidate the design. rdplotdensity() draws the two estimated densities.

Assumptions. Smoothness of the density away from the cutoff; the test targets manipulation, a necessary (not sufficient) check for RD validity.

Implements the no-manipulation diagnostic for the RD designs Imbens co-founded; package by Cattaneo, Jansson & Ma.

What you get — A robust manipulation-test statistic and p-value (large p ⇒ no evidence of sorting at the cutoff).

Example output

Manipulation testing using local polynomial density estimation.

Number of obs =       2000
Model =               unrestricted
BWmethod =            comb
Kernel =              triangular

Method                T          P > |T|
Robust              -0.31         0.7541

Links: package · paper

Discussion (0)

  • No comments yet — start the conversation.