Written and maintained by CASRAI Editorial Board
Published
On this page
rdrobust is a free software package, available for R, Python and Stata, that estimates the effect of a treatment in a regression discontinuity (RD) design: it fits local polynomial regressions on each side of a cutoff, chooses the bandwidth from the data, and reports a point estimate with bias-corrected robust confidence intervals. The R package (version 4.1.1 on CRAN) is maintained by Sebastian Calonico with Matias Cattaneo, Max Farrell and Rocio Titiunik as co-authors, and the Python port is published on PyPI as rdrobust 2.1.1.
This page is a package reference. It covers installation from the official sources, the arguments that change an estimate, a numbered worked example on the Senate data shipped with the package, how to read the output, and the problems that most often trip up a first analysis. For the design itself, see the guide to regression discontinuity design; for treatment that changes only partly at the cutoff, see fuzzy regression discontinuity.
What rdrobust is used for in research
A regression discontinuity design applies when a unit receives a treatment, or a different probability of treatment, because a running variable crosses a known cutoff. The package estimates the jump in the outcome at that cutoff. Its documented functions are rdrobust() for estimation and inference, rdbwselect() for bandwidth selection alone, rdplot() for RD plots, and a plot method for fitted rdrobust objects. The package also ships a dataset, rdrobust_RDsenate, with 1,390 observations of United States Senate elections.
Three design variants are handled by the same call. A sharp RD is the default. Supplying a treatment-status variable to fuzzy= gives a fuzzy RD, in which case the output adds first-stage results. Setting deriv=1 estimates a kink RD, which targets a change in slope rather than a jump in level; combined with fuzzy= it gives a fuzzy kink design. The methodology behind the defaults is published in Calonico, Cattaneo and Titiunik (2014, Econometrica 82(6):2295-2326), with the R implementation described in the R Journal (2015, 7(1):38-51), and the manual cites further papers on coverage-error-rate bandwidths and covariate adjustment.
The package sits in the CRAN task views for causal inference and econometrics. In a research workflow it answers one question: what is the local treatment effect at the cutoff, and how sensitive is it to the bandwidth, the kernel, the polynomial order and the covariates. It does not by itself test whether units could manipulate the running variable; that check belongs to the design stage described in the design guide linked above, and the wider logic of identification is covered in the causal analysis guide.
Install or access rdrobust from the official source
R
The package is on CRAN and needs R 3.6.0 or later. It imports ggplot2 and MASS, suggests broom, gridExtra and testthat, needs no compilation, and is licensed GPL-3. Install and load it with:
install.packages("rdrobust")library(rdrobust)
If you have not installed packages from CRAN before, the guide on how to install R packages covers library paths and mirrors. The CRAN citation for the package is DOI 10.32614/CRAN.package.rdrobust.
Python
The Python package requires Python 3.9 or later and installs from PyPI with pip install rdrobust. Its listed dependencies are numpy, pandas, scipy, plotnine and matplotlib, it is licensed GPL-3.0-only, and it offers optional extras named formula and speed. The Python functions mirror the R names: rdrobust, rdbwselect, rdplot, plot_rdrobust, and the Senate dataset rdrobust_RDsenate.
Stata
The project repository gives this installation line for Stata:
net install rdrobust, from(https://raw.githubusercontent.com/rdpackages/rdrobust/main/stata) replace
The repository has separate Python, R and stata folders, and the R folder contains illustration scripts (rdrobust_illustration.r, rdplot_illustration.R) together with the Senate data as rdrobust_senate.csv. The rest of this page uses the R interface.
Step-by-step: a sharp RD on the Senate data
The Senate dataset follows Cattaneo, Frandsen and Titiunik (2015, Journal of Causal Inference 3(1):1-24) and covers elections from 1914 to 2010. The running variable margin is the Democratic vote margin in the election at time t, so the cutoff is 0. The outcome vote is the Democratic vote share in the election two years later (t+2). Other variables include state (usable as a cluster), class, termshouse, termssenate and population. The steps follow the project’s own R illustration script.
- Load the data. Read the CSV from the repository folder:
rdrobust_senate = read.csv("rdrobust_senate.csv"). The commands below use the bare column namesvote,marginandstateas the project script does; if those columns are not visible in your session, passdata=rdrobust_senate, which the manual documents fory,x,covs,clusterand similar arguments. - Plot first. Run
rdplot(y=vote, x=margin, binselect="es", ci=95, title="RD Plot - Senate Election Data", y.label="Vote Share in Election at time t+2", x.label="Vote Share in Election at time t"). The plot shows binned means with confidence intervals and a global polynomial fit (the default order inrdplot()is p=4), so use it to look at the jump, not to estimate it. - Estimate. Run
summary(rdrobust(y=vote, x=margin)). With the defaults this uses a local linear fit (p=1), a bias-correction polynomial of order 2 (q=2), a triangular kernel, the MSE-optimal common bandwidth (bwselect="mserd") and nearest-neighbour variance estimation with three neighbours. - See all three estimates. Run
summary(rdrobust(y=vote, x=margin), all=TRUE)to print the Conventional, Bias-Corrected and Robust rows. - Store the object and extract components.
est = rdrobust(y=vote, x=margin), thenest$bws[1,1]andest$bws[1,2]give the estimation bandwidths left and right of the cutoff, andest$ci[3,]gives the robust confidence interval. - Add covariates.
rdrobust(y=vote, x=margin, covs=cbind(class, termshouse, termssenate))adjusts for pre-determined covariates. Compare the robust interval length with and without them. - Cluster where the design calls for it.
summary(rdrobust(y=vote, x=margin, vce="nn", cluster=state))clusters on state. - Inspect the bandwidths alone.
rdbwselect(y=vote, x=margin, all=TRUE)lists every bandwidth selector.
The manual also includes a self-contained simulated example that needs no data file: x = runif(1000,-1,1), y = 5 + 3*x + 2*(x>=0) + rnorm(1000), then rdrobust(y,x) and summary(rdrobust(y, x), all = TRUE). Because the true jump in that simulation is 2, it is a useful sanity check that an installation behaves as expected. Covariates can be passed as a one-sided formula with data=, for example rdrobust(y, x, covs = ~ z1 + z2, data = df), as a character vector of column names (also with data=), or as a matrix or data frame.
Output and how to read it
Since version 4.0.0, printing options moved from rdrobust() to summary(). The default summary is a compact one-row table holding the point estimate with robust bias-corrected inference. With all=TRUE it has three rows: Conventional (local polynomial estimate with conventional standard errors), Bias-corrected (the estimate after bias correction, with conventional standard errors) and Robust (the bias-corrected estimate with standard errors that account for the bias-correction step). With detail=TRUE it has two rows, Conventional and Robust. Report the Robust row for inference.
The stored object holds these components, according to the manual:
N,N_h,N_bandM: sample sizes overall and within the estimation and bias bandwidths, and the count of unique observations.c,p,q,kernel,vce,bwselect,level,masspoints: the settings actually used.bws: a matrix whose first row is the estimation bandwidth h and second row the bias bandwidth b, with columns for left and right of the cutoff.tau_clandtau_bc: the conventional and bias-corrected estimates;coef,se,z,pvandcihold the Conventional, Bias-Corrected and Robust results in that row order.n_clustwhen clustering is used, and for fuzzy designs the first-stage results (tau_T,se_T,z_T,pv_T,ci_T).
Use coef() to extract the three coefficients. The manual warns that vcov() returns only a diagonal placeholder with zeros off the diagonal, so it should not be used for Wald tests across rows. Older tutorials and the older illustration script refer to fields such as Estimate; the manual for version 4.1.1 documents the component names above, so use those on a current install.
The plot method, plot.rdrobust(x, y, x_run, nbins=20, ci=TRUE, show_effect=FALSE), draws a binned scatter inside the bandwidth with local polynomial curves; show_effect produces two panels and needs gridExtra.
Arguments that change the estimate
The data table below lists the defaults and valid values of the main rdrobust() arguments, compiled from the CRAN reference manual. The ones most worth reporting in a paper are the kernel, the polynomial orders, the bandwidth selector and the variance estimator, because a reader cannot reproduce the estimate without them. Bandwidths can be fixed manually: h and b each accept one value, or two values in the order left then right of the cutoff, as in the script’s h=c(12,15), b=c(18,20). The bandwidth selector names combine an error criterion with a variant: those starting mse minimize mean square error, those starting cer minimize coverage error rate, and the suffixes rd, two, sum, comb1 and comb2 distinguish the variants within each family.
Troubleshooting
Clustering and the variance estimator
The default vce="nn" uses nearest-neighbour matching with nnmatch=3. The alternatives are hc0 to hc3, and cr1, cr2 and cr3, which require the cluster argument. When a cluster variable is supplied, only the cr options are valid; other choices are mapped to a cluster option with a warning, and cr3 is the most conservative.
Repeated values of the running variable
The masspoints argument handles repeated running-variable values: "adjust" is the default, "check" only checks, and "off" ignores them. bwcheck sets a minimum number of unique observations on each side of the cutoff and defaults to 10 unique observations.
Collinear covariates
covs_drop=TRUE is the default, which drops covariates that cause collinearity problems rather than failing; ginv.tol controls the tolerance for the generalized inverse (default 1e-15).
Output looks different from a tutorial
Tutorials written before version 4.0.0 call rdrobust() with print options and expect a three-row table by default. On current versions, wrap the call in summary() and add all=TRUE. If a script uses est$Estimate and fails, switch to est$coef and est$pv.
Asymmetric or hand-picked bandwidths
bwrestrict=TRUE is the default and restricts bandwidths to the support of the running variable. If you set h by hand, state the value and its source in your methods section, and compare it with the data-driven value from rdbwselect().
Free alternatives and ports
rdrobust is itself free software, and the same authors publish it for three environments. The table lists what the project’s official sources state for each.
| Environment | Install command | Requirements and licence stated by the source |
|---|---|---|
| R | install.packages("rdrobust") |
R 3.6.0 or later; GPL-3 (CRAN) |
| Python | pip install rdrobust |
Python 3.9 or later; GPL-3.0-only (PyPI) |
| Stata | net install rdrobust, from(https://raw.githubusercontent.com/rdpackages/rdrobust/main/stata) replace |
Stata folder in the project repository, with PDF help files for rdrobust, rdbwselect, rdplot and rdrobustplot |
For other free statistical tools used alongside it, see the guide to free statistical software. When you publish results, cite the package and the methodological papers named above; the guide on citing software and R packages explains the form.
Sources
- CRAN, rdrobust package page (version 4.1.1, published 2026-10-07): https://cran.r-project.org/web/packages/rdrobust/index.html, read 2026-11-15.
- CRAN, rdrobust reference manual (dated 2026-10-08): https://cran.r-project.org/web/packages/rdrobust/rdrobust.pdf, read 2026-11-15.
- rdpackages project repository, rdrobust: https://github.com/rdpackages/rdrobust, read 2026-11-15.
- rdpackages R illustration script: https://raw.githubusercontent.com/rdpackages/rdrobust/main/R/rdrobust_illustration.r, read 2026-11-15.
- PyPI, rdrobust 2.1.1 (released 2026-10-07): https://pypi.org/project/rdrobust/, read 2026-11-15.
Data: rdrobust() main arguments: defaults and valid values
Defaults and accepted values of the main arguments of the rdrobust() function in the rdrobust R package version 4.1.1, compiled from the CRAN reference manual dated 2026-10-08. Each row is one argument; the default kernel is written tri in the manual.
| Argument | Default | Meaning and valid values |
|---|---|---|
| c | 0 | Cutoff value of the running variable |
| p | 1 | Polynomial order for the point estimate (local linear) |
| q | 2 | Polynomial order for bias correction |
| kernel | tri | Kernel: triangular by default; the manual also lists epanechnikov and uniform |
| bwselect | mserd | Bandwidth selector: mserd, msetwo, msesum, msecomb1, msecomb2, cerrd, certwo, cersum, cercomb1, cercomb2 |
| vce | nn | Variance estimator: nn, hc0, hc1, hc2, hc3; cr1, cr2, cr3 require cluster |
| nnmatch | 3 | Minimum number of neighbours for the nn variance estimator |
| level | 95 | Confidence level in percent |
| masspoints | adjust | Repeated running-variable values: off, check or adjust |
| bwcheck | 10 | Minimum unique observations on each side of the cutoff |
| covs_drop | TRUE | Drop collinear covariates instead of failing |
| bwrestrict | TRUE | Restrict bandwidths to the support of the running variable |
| fuzzy | NULL | Treatment-status variable; supplying it requests a fuzzy RD |
| deriv | NULL | Derivative order; 1 requests a kink RD |
Sources
- rdrobust reference manual (CRAN) (accessed 2026-11-15)
Compiled by CASRAI from the sources above. Free to reuse under CC BY 4.0 with attribution.







