| Type: | Package |
| Title: | Estimation and Inference for Boundary Discontinuity Designs |
| Version: | 0.1.0 |
| URL: | https://rdpackages.github.io/, https://github.com/rdpackages/rd2d |
| BugReports: | https://github.com/rdpackages/rd2d/issues |
| Description: | Provides pointwise and uniform estimation and inference methods for boundary discontinuity (BD) designs, a causal inference design that generalizes univariate regression discontinuity (RD) designs to settings with bivariate scores. Implements local polynomial methods for location-based and distance-based analyses, including sharp and fuzzy designs, data-driven bandwidth selection, pointwise confidence intervals, and uniform confidence bands. Methodology is developed in Cattaneo, Titiunik, and Yu (2026) <doi:10.48550/arXiv.2505.05670> for location-based methods and Cattaneo, Titiunik, and Yu (2026) <doi:10.48550/arXiv.2510.26051> for distance-based methods. For an overview and empirical guidance, see Cattaneo, Titiunik, and Yu (2026) <doi:10.48550/arXiv.2511.06474>. The companion software article is Cattaneo, Titiunik, and Yu (2025) <doi:10.48550/arXiv.2505.07989>. |
| Imports: | MASS, expm, ggplot2 |
| Suggests: | testthat (≥ 3.0.0) |
| License: | GPL-2 |
| Encoding: | UTF-8 |
| Maintainer: | Matias D. Cattaneo <matias.d.cattaneo@gmail.com> |
| NeedsCompilation: | no |
| Author: | Matias D. Cattaneo [aut, cre], Rocio Titiunik [aut], Ruiqi Rae Yu [aut] |
| Config/testthat/edition: | 3 |
| Config/roxygen2/version: | 8.0.0 |
| Packaged: | 2026-05-13 14:22:26 UTC; cattaneo |
| Repository: | CRAN |
| Date/Publication: | 2026-05-14 08:40:02 UTC |
rd2d: Estimation and Inference for Boundary Discontinuity Designs
Description
rd2d implements pointwise and uniform estimation and inference procedures for boundary discontinuity (BD) designs using local polynomial methods. The package includes location-based and distance-based methods, sharp and fuzzy designs, automatic bandwidth selection, pointwise confidence intervals, and uniform confidence bands. Distance-based methods in this package target level effects at two-dimensional boundary points.
Included functions are: rd2d for location-based estimation and inference, rdbw2d for location-based bandwidth selection, rd2d.distance for distance-based estimation and inference, and rdbw2d.distance for distance-based bandwidth selection.
print() and summary() methods are available for all four
functions.
Related Stata, R, and Python packages useful for inference in RD designs are described at:
For an introduction to regression discontinuity designs, see Cattaneo and Titiunik (2022, doi:10.1146/annurev-economics-051520-021409) and references therein.
Author(s)
Matias D. Cattaneo, Princeton University. matias.d.cattaneo@gmail.com. Rocio Titiunik, Princeton University. titiunik@princeton.edu. Ruiqi Rae Yu, Princeton University. raeyuuuu@gmail.com.
References
Cattaneo, M. D., and Titiunik, R. (2022). Regression Discontinuity Designs. doi:10.1146/annurev-economics-051520-021409.
Cattaneo, M. D., Titiunik, R., and Yu, R. R. (2026). Estimation and Inference in Boundary Discontinuity Designs: Location-Based Methods.
Cattaneo, M. D., Titiunik, R., and Yu, R. R. (2026). Estimation and Inference in Boundary Discontinuity Designs: Distance-Based Methods.
Cattaneo, M. D., Titiunik, R., and Yu, R. R. (2026). Boundary Discontinuity Designs: Theory and Practice.
Cattaneo, M. D., Titiunik, R., and Yu, R. R. (2025). rd2d: Causal Inference in Boundary Discontinuity Designs.
See Also
Useful links:
Report bugs at https://github.com/rdpackages/rd2d/issues
Print Method for 2D Local Polynomial RD Estimation
Description
Prints the results of a 2D local polynomial regression discontinuity (RD)
estimation, as obtained from rd2d.
Usage
## S3 method for class 'rd2d'
print(x, ...)
Arguments
x |
An object of class |
... |
Additional arguments passed to the method (currently ignored). |
Value
No return value. This function is called for its side effects, which are to
print the rd2d results.
Author(s)
Matias D. Cattaneo, Princeton University. matias.d.cattaneo@gmail.com
Rocio Titiunik, Princeton University. titiunik@princeton.edu
Ruiqi Rae Yu, Princeton University. raeyuuuu@gmail.com
See Also
rd2d for conducting 2D local polynomial RD estimation.
Supported methods: print.rd2d, summary.rd2d.
Print Method for 2D Local Polynomial RD Estimation (Distance-Based)
Description
Prints the results of a 2D local polynomial regression discontinuity (RD) estimation using distance-based evaluation, as obtained from rd2d.distance.
Usage
## S3 method for class 'rd2d.distance'
print(x, ...)
Arguments
x |
An object of class |
... |
Additional arguments passed to the method (currently ignored). |
Value
No return value. This function is called for its side effects: it prints the rd2d.distance results.
Author(s)
Matias D. Cattaneo, Princeton University. matias.d.cattaneo@gmail.com
Rocio Titiunik, Princeton University. titiunik@princeton.edu
Ruiqi Rae Yu, Princeton University. raeyuuuu@gmail.com
See Also
rd2d.distance for estimation using distance-based methods in 2D local polynomial RD designs.
Supported methods: print.rd2d.distance, summary.rd2d.distance.
Print Method for Bandwidth Selection for 2D Local Polynomial RD Design
Description
The print method for bandwidth selection for 2D local polynomial RD design
Usage
## S3 method for class 'rdbw2d'
print(x, ...)
Arguments
x |
Class |
... |
Additional arguments passed to the method (currently ignored). |
Value
No return value, called to print rdbw2d results.
Author(s)
Matias D. Cattaneo, Princeton University. matias.d.cattaneo@gmail.com
Rocio Titiunik, Princeton University. titiunik@princeton.edu
Ruiqi Rae Yu, Princeton University. raeyuuuu@gmail.com
See Also
rdbw2d for bandwidth selection for 2D local polynomial RD design
Supported methods: print.rdbw2d, summary.rdbw2d.
Print Method for Bandwidth Selection (Distance-Based) in 2D Local Polynomial RD Design
Description
Print method for displaying summary information from distance-based bandwidth selection in 2D local polynomial regression discontinuity (RD) designs, as produced by rdbw2d.distance.
Usage
## S3 method for class 'rdbw2d.distance'
print(x, ...)
Arguments
x |
An object of class |
... |
Additional arguments passed to the method (currently ignored). |
Value
No return value. This function is called for its side effects: it prints summary information of rdbw2d.distance.
Author(s)
Matias D. Cattaneo, Princeton University. matias.d.cattaneo@gmail.com
Rocio Titiunik, Princeton University. titiunik@princeton.edu
Ruiqi Rae Yu, Princeton University. raeyuuuu@gmail.com
See Also
rdbw2d.distance for distance-based bandwidth selection in 2D local polynomial RD design.
Supported methods: print.rdbw2d.distance, summary.rdbw2d.distance.
Location-Based Methods for Boundary Discontinuity Design
Description
rd2d implements location-based local polynomial boundary
discontinuity (BD) point estimators with robust bias-corrected pointwise
confidence intervals and uniform confidence bands.
See Cattaneo, M. D., Titiunik, R., and Yu, R. R. (2026)
for methodological background.
Companion commands are: rdbw2d for data-driven bandwidth selection.
For other packages of RD designs, visit https://rdpackages.github.io/
Usage
rd2d(
Y,
X,
assignment,
b,
h = NULL,
deriv = c(0, 0),
tangvec = NULL,
p = 1,
q = NULL,
kernel = c("tri", "triangular", "epa", "epanechnikov", "uni", "uniform", "gau",
"gaussian"),
kernel_type = c("prod", "rad"),
vce = c("hc1", "hc0", "hc2", "hc3"),
masspoints = c("check", "adjust", "off"),
cluster = NULL,
level = 95,
params.other = NULL,
params.cov = NULL,
side = c("two", "left", "right"),
repp = 1000,
bwselect = c("mserd", "cerrd", "imserd", "icerrd", "msetwo", "certwo", "imsetwo",
"icertwo", "user provided"),
bwparam = c("main", "itt"),
method = c("dpi", "rot"),
bwcheck = 50 + p + 1,
scaleregul = 3,
scalebiascrct = 1,
stdvars = TRUE,
fuzzy = NULL
)
Arguments
Y |
Dependent variable; a numeric vector of length |
X |
Bivariate running variable (a.k.a score variable); a numeric
matrix or data frame of dimension |
assignment |
Treatment assignment indicator; a logical or binary vector indicating assignment to the treated side. |
b |
Evaluation points; a matrix or data frame specifying boundary
points |
h |
Bandwidths. Either a positive scalar (same bandwidth for all
dimensions and groups), or a matrix/data frame of size |
deriv |
The order of the derivatives of the regression functions to be
estimated; a nonnegative integer vector of length 2 specifying the number
of derivatives in each coordinate (e.g., |
tangvec |
Tangent vectors; a matrix or data frame of dimension
|
p |
Polynomial order for point estimation ( |
q |
Polynomial order for robust confidence interval construction. Must
satisfy |
kernel |
Kernel function to use. Options are |
kernel_type |
Kernel structure. Either |
vce |
Variance-covariance estimation method. Options are:
Default is |
masspoints |
Handling of mass points in the running variable. Options are:
|
cluster |
Cluster ID variable used for cluster-robust variance estimation
with degrees-of-freedom weights. Default is |
level |
Nominal confidence level for intervals/bands, between 0 and 100 (default is 95). |
params.other |
Optional character vector requesting companion-side
result tables. Options are |
params.cov |
Optional character vector requesting covariance matrices
to store for later use by |
side |
Type of confidence interval. Options: |
repp |
Number of repetitions for critical value simulation (used in uniform confidence bands). Default is 1000. |
bwselect |
Bandwidth selection strategy. Options:
|
bwparam |
Target parameter used for fuzzy automatic bandwidth
selection. Options are |
method |
Bandwidth selection method for bias estimator based on local
polynomials. Either |
bwcheck |
If a positive integer is provided, the preliminary bandwidth
used in the calculations is enlarged so that at least |
scaleregul |
Scaling factor for the regularization term in bandwidth selection. Default is 3. |
scalebiascrct |
Scaling factor used for bias correction based on higher order expansions. Default is 1. |
stdvars |
Logical. If |
fuzzy |
Optional treatment receipt/status variable used for fuzzy RD
estimation. The default is |
Value
An object of class "rd2d", a list with components:
mainA data frame with point estimates, standard errors, t-statistics, p-values, confidence intervals, and bandwidths at each evaluation point.
b1,b2First and second coordinate of evaluation points
\mathbf{b} = (b_1,b_2).estimate.pPoint estimate
\widehat{\tau}_p(\mathbf{b}).std.err.pStandard error of
\widehat{\tau}_p(\mathbf{b}).estimate.qBias-corrected point estimate
\widehat{\tau}_q(\mathbf{b}).std.err.qStandard error of the bias-corrected estimate
\widehat{\tau}_q(\mathbf{b}).t.value,p.valuet-statistic and p-value based on the bias-corrected estimate.
ci.lower,ci.upperPointwise confidence intervals.
h01,h02,h11,h12Bandwidths used in each coordinate and group.
N.Co,N.TrEffective sample size for the control and treatment sides, respectively.
main.0,main.1For sharp RD only, companion-side outcome tables requested through
params.other; otherwiseNA.bwBandwidth and effective sample size table.
ittFor fuzzy RD only, same structure as
mainbut for the reduced-form or intention-to-treat outcome discontinuity.itt.0,itt.1For fuzzy RD only, outcome summaries for the control and treated sides requested through
params.other; otherwiseNA.fsFor fuzzy RD only, same structure as
mainbut for the first-stage treatment receipt/status discontinuity.fs.0,fs.1For fuzzy RD only, first-stage summaries for the control and treated sides requested through
params.other; otherwiseNA.tau.hatPoint estimates at each evaluation point.
tau.hat.qBias-corrected estimates at each evaluation point.
se.hatStandard errors corresponding to
tau.hat.se.hat.qStandard errors corresponding to
tau.hat.q.params.covList of covariance matrices for aggregate inference in
summary.rd2d. Contains only entries requested throughparams.cov.cbList with pointwise confidence intervals.
pvaluesTwo-sided p-values based on bias-corrected estimates.
tvaluest-statistics based on bias-corrected estimates.
tau.itt,tau.itt.qFor fuzzy RD, reduced-form outcome estimates using polynomial orders
pandq; otherwiseNA.tau.fs,tau.fs.qFor fuzzy RD, first-stage treatment receipt/status estimates using polynomial orders
pandq; otherwiseNA.rdmodelCharacter label describing the fitted RD model.
callMatched function call.
optList of options used in the function call.
Author(s)
Matias D. Cattaneo, Princeton University. matias.d.cattaneo@gmail.com
Rocio Titiunik, Princeton University. titiunik@princeton.edu
Ruiqi Rae Yu, Princeton University. raeyuuuu@gmail.com
References
Cattaneo, M. D., and Titiunik, R. (2022). Regression Discontinuity Designs. doi:10.1146/annurev-economics-051520-021409.
Cattaneo, M. D., Titiunik, R., and Yu, R. R. (2026). Estimation and Inference in Boundary Discontinuity Designs: Location-Based Methods.
Cattaneo, M. D., Titiunik, R., and Yu, R. R. (2026). Boundary Discontinuity Designs: Theory and Practice.
Cattaneo, M. D., Titiunik, R., and Yu, R. R. (2025). rd2d: Causal Inference in Boundary Discontinuity Designs.
See Also
rdbw2d, print.rd2d,
summary.rd2d
Examples
# Simulated example
set.seed(123)
n <- 800
X1 <- rnorm(n)
X2 <- rnorm(n)
assignment <- as.numeric(X1 > 0)
Y <- 3 + 2 * X1 + 1.5 * X2 + assignment + rnorm(n)
X <- cbind(X1, X2)
b <- matrix(c(0, 0, 0, 1), ncol = 2)
# Estimate treatment effect using rd2d
result <- rd2d(Y, X, assignment, b, params.cov = "main",
masspoints = "off", bwcheck = 10, repp = 49)
print(result)
summary(result, cbands = "main")
# Fuzzy RD example
fuzzy <- as.numeric(runif(n) < ifelse(assignment == 1, 0.8, 0.2))
Y.fuzzy <- 3 + 2 * X1 + 1.5 * X2 + 1.5 * fuzzy + rnorm(n)
result.fuzzy <- rd2d(Y.fuzzy, X, assignment, b, fuzzy = fuzzy,
bwparam = "main", masspoints = "off",
bwcheck = 10, repp = 49)
print(result.fuzzy)
summary(result.fuzzy, output = "itt")
Distance-Based Methods for Boundary Discontinuity Design
Description
rd2d.distance implements distance-based local polynomial boundary
discontinuity (BD) point estimators with robust bias-corrected pointwise
confidence intervals and uniform confidence bands.
The command targets level effects at two-dimensional boundary points.
See Cattaneo, M. D., Titiunik, R., and Yu, R. R. (2026)
for methodological background.
Companion commands are: rdbw2d.distance for data-driven bandwidth selection.
For other packages of RD designs, visit https://rdpackages.github.io/
Usage
rd2d.distance(
Y,
distance,
h = NULL,
b = NULL,
p = 1,
q = NULL,
kink.unknown = c(FALSE, FALSE),
kink.position = NULL,
kernel = c("tri", "triangular", "epa", "epanechnikov", "uni", "uniform", "gau",
"gaussian"),
level = 95,
cbands = TRUE,
side = c("two", "left", "right"),
repp = 1000,
bwselect = c("mserd", "cerrd", "imserd", "icerrd", "msetwo", "certwo", "imsetwo",
"icertwo", "user provided"),
bwparam = c("main", "itt"),
params.other = NULL,
params.cov = NULL,
vce = c("hc1", "hc0", "hc2", "hc3"),
bwcheck = 50 + p + 1,
masspoints = c("check", "adjust", "off"),
cluster = NULL,
scaleregul = 1,
cqt = 0.5,
fuzzy = NULL
)
Arguments
Y |
Dependent variable; a numeric vector of length |
distance |
Signed distance scores; a numeric matrix or data frame of
dimension |
h |
Bandwidths. A positive scalar uses the same bandwidth for both
groups and all evaluation points. A matrix/data frame of size
|
b |
Optional evaluation points; a matrix or data frame specifying boundary points |
p |
Polynomial order for point estimation. Default is |
q |
Polynomial order for bias-corrected estimation. Must satisfy
|
kink.unknown |
Logical value or vector of length 2 controlling
unknown-kink bandwidth adjustments. A scalar |
kink.position |
Optional boundary positions of known kink points.
Either a logical vector with one entry per boundary point, where |
kernel |
Kernel function to use. Options are |
level |
Nominal confidence level for intervals/bands, between 0 and 100 (default is 95). |
cbands |
Logical. If |
side |
Type of confidence interval. Options: |
repp |
Number of bootstrap repetitions used for critical value simulation. Default is |
bwselect |
Bandwidth selection strategy. Options:
|
bwparam |
Target parameter used for fuzzy automatic bandwidth
selection. Options are |
params.other |
Optional character vector requesting companion output
tables. In sharp designs, available values are |
params.cov |
Optional character vector requesting covariance matrices
for aggregate inference or confidence bands. Available values are
|
vce |
Variance-covariance estimator for standard errors. Options:
|
bwcheck |
If a positive integer is provided, the preliminary bandwidth used in the calculations is enlarged so that at least |
masspoints |
Strategy for handling mass points in the running variable. Options:
|
cluster |
Cluster ID variable used for cluster-robust variance estimation with degrees-of-freedom weights. Default is |
scaleregul |
Scaling factor for the regularization term in bandwidth selection. Default is |
cqt |
Constant controlling subsample fraction for initial bias estimation. Default is |
fuzzy |
Optional treatment receipt/status variable for fuzzy RD designs. If
supplied, |
Value
An object of class "rd2d.distance", a list containing:
mainData frame of point estimates, standard errors, confidence intervals, and bandwidths:
b1First coordinate of the evaluation point.
b2Second coordinate of the evaluation point.
estimate.pPoint estimate with polynomial order
p.std.err.pStandard error for
estimate.p.estimate.qBias-corrected estimate with polynomial order
q.std.err.qStandard error for
estimate.q.t.valuet-statistic based on
\widehat{\tau}_{\text{distance},q}(\mathbf{b}).p.valueTwo-sided p-value based on
T_{\text{distance},q}(\mathbf{b}).ci.lowerLower bound of confidence interval.
ci.upperUpper bound of confidence interval.
h0Bandwidth used for the control group (negative signed distance).
h1Bandwidth used for the treatment group (non-negative signed distance).
h0.rbcBandwidth used for control-side inference.
h1.rbcBandwidth used for treated-side inference.
N.CoEffective sample size for the control side.
N.TrEffective sample size for the treatment side.
main.0Sharp-design summary table for the control side only.
main.1Sharp-design summary table for the treated side only.
ittFuzzy-design reduced-form outcome summary table.
itt.0,itt.1Optional fuzzy-design side-specific reduced-form outcome summary tables requested through
params.other.fsFuzzy-design first-stage treatment receipt/status summary table.
fs.0,fs.1Optional fuzzy-design side-specific first-stage treatment receipt/status summary tables requested through
params.other.bwBandwidth and effective-sample-size table.
tau.hatVector of point estimates
\widehat{\tau}_p(\mathbf{b}).tau.hat.qVector of bias-corrected estimates
\widehat{\tau}_q(\mathbf{b}).se.hatStandard errors corresponding to
\widehat{\tau}_p(\mathbf{b}).se.hat.qStandard errors corresponding to
\widehat{\tau}_q(\mathbf{b}).params.covList containing covariance matrices requested for aggregate or uniform inference.
cbPointwise confidence interval endpoints.
pvaluesTwo-sided p-values based on bias-corrected estimates.
tvaluest-statistics based on bias-corrected estimates.
tau.itt,tau.itt.q,tau.fs,tau.fs.qFuzzy reduced-form and first-stage point estimates with polynomial orders
pandq; these areNULLin sharp designs.rdmodelCharacter label describing the fitted RD model.
callMatched function call.
optA list of estimation options (e.g.,
p,q,kernel,level, etc.) and internal variables such as sample sizeN.
Author(s)
Matias D. Cattaneo, Princeton University. matias.d.cattaneo@gmail.com
Rocio Titiunik, Princeton University. titiunik@princeton.edu
Ruiqi Rae Yu, Princeton University. raeyuuuu@gmail.com
References
Cattaneo, M. D., and Titiunik, R. (2022). Regression Discontinuity Designs. doi:10.1146/annurev-economics-051520-021409.
Cattaneo, M. D., Titiunik, R., and Yu, R. R. (2026). Estimation and Inference in Boundary Discontinuity Designs: Distance-Based Methods.
Cattaneo, M. D., Titiunik, R., and Yu, R. R. (2026). Boundary Discontinuity Designs: Theory and Practice.
Cattaneo, M. D., Titiunik, R., and Yu, R. R. (2025). rd2d: Causal Inference in Boundary Discontinuity Designs.
See Also
rdbw2d.distance, rd2d, print.rd2d.distance, summary.rd2d.distance
Examples
set.seed(123)
n <- 800
# Generate running variables x1 and x2
x1 <- rnorm(n)
x2 <- rnorm(n)
# Define treatment assignment: treated if x1 >= 0
assignment <- as.numeric(x1 >= 0)
# Generate outcome variable Y with some treatment effect
Y <- 3 + 2 * x1 + 1.5 * x2 + 1.5 * assignment + rnorm(n, sd = 0.5)
# Define evaluation points (e.g., at the origin and another point)
eval <- data.frame(x.1 = c(0, 0), x.2 = c(0, 1))
# Compute Euclidean distances to evaluation points
distance.a <- sqrt((x1 - eval$x.1[1])^2 + (x2 - eval$x.2[1])^2)
distance.b <- sqrt((x1 - eval$x.1[2])^2 + (x2 - eval$x.2[2])^2)
# Combine distances into a matrix
distance <- as.data.frame(cbind(distance.a, distance.b))
# Assign positive distances for treatment group, negative for control
assignment_expanded <- matrix(rep(2 * assignment - 1, times = ncol(distance)),
nrow = nrow(distance), ncol = ncol(distance))
distance <- distance * assignment_expanded
# Run the rd2d.distance function
result <- rd2d.distance(Y, distance = distance, b = eval, cbands = FALSE,
masspoints = "off", bwcheck = 10)
# View the estimation results
print(result)
summary(result)
# Fuzzy distance-based fit with a user-supplied bandwidth
fuzzy <- as.numeric(runif(n) < ifelse(assignment == 1, 0.8, 0.2))
Y.fuzzy <- 3 + 2 * x1 + 1.5 * x2 + 1.5 * fuzzy + rnorm(n, sd = 0.5)
fuzzy.result <- rd2d.distance(Y.fuzzy, distance = distance, h = 0.8, b = eval, fuzzy = fuzzy,
cbands = FALSE, masspoints = "off")
summary(fuzzy.result)
Bandwidth Selection for Location-Based Methods for Boundary Discontinuity Design
Description
rdbw2d implements bandwidth selectors for location-based local
polynomial boundary discontinuity (BD) estimation and inference.
See Cattaneo, M. D., Titiunik, R., and Yu, R. R. (2026)
for methodological background.
Companion commands are: rd2d for point estimation and inference procedures.
For other packages of RD designs, visit https://rdpackages.github.io/
Usage
rdbw2d(
Y,
X,
assignment,
b,
p = 1,
deriv = c(0, 0),
tangvec = NULL,
kernel = c("tri", "triangular", "epa", "epanechnikov", "uni", "uniform", "gau",
"gaussian"),
kernel_type = c("prod", "rad"),
bwselect = c("mserd", "cerrd", "imserd", "icerrd", "msetwo", "certwo", "imsetwo",
"icertwo"),
bwparam = c("main", "itt"),
method = c("dpi", "rot"),
vce = c("hc1", "hc0", "hc2", "hc3"),
bwcheck = 20,
masspoints = c("check", "adjust", "off"),
cluster = NULL,
scaleregul = 1,
scalebiascrct = 1,
stdvars = TRUE,
fuzzy = NULL
)
Arguments
Y |
Dependent variable; a numeric vector of length |
X |
Bivariate running variable (a.k.a score variable); a numeric matrix or data frame of dimension |
assignment |
Treatment assignment indicator; a logical or binary vector indicating assignment to the treated side. |
b |
Evaluation points; a matrix or data frame specifying boundary points |
p |
Polynomial order of the local polynomial estimator. Default is
|
deriv |
The order of the derivatives of the regression functions to be estimated; a nonnegative integer vector of length 2 specifying the number of derivatives in each coordinate (e.g., |
tangvec |
Tangent vectors; a matrix or data frame of dimension |
kernel |
Kernel function to use. Options are |
kernel_type |
Kernel structure. Either |
bwselect |
Bandwidth selection strategy. Options:
|
bwparam |
Target parameter used for fuzzy bandwidth selection.
Options are |
method |
Bandwidth selection method for bias estimator based on local polynomials. Either |
vce |
Variance-covariance estimation method. Options are:
Default is |
bwcheck |
If a positive integer is provided, the preliminary bandwidth used in the calculations is enlarged so that at least |
masspoints |
Handling of mass points in the running variable. Options are:
|
cluster |
Cluster ID variable used for cluster-robust variance estimation with degrees-of-freedom weights. Default is |
scaleregul |
Scaling factor for the regularization term in bandwidth selection. Default is 1. |
scalebiascrct |
Scaling factor used for bias correction based on higher order expansions. Default is 1. |
stdvars |
Logical. If |
fuzzy |
Optional treatment receipt/status variable used to construct
bandwidth selectors for fuzzy RD estimation. If supplied, |
Value
A list of class "rdbw2d" containing:
bwsData frame of estimated bandwidths for each evaluation point:
b1First coordinate of the evaluation point.
b2Second coordinate of the evaluation point.
h01Estimated bandwidth for
X_{1i}in the control group (\mathcal{A}_0).h02Estimated bandwidth for
X_{2i}in the control group (\mathcal{A}_0).h11Estimated bandwidth for
X_{1i}in the treatment group (\mathcal{A}_1).h12Estimated bandwidth for
X_{2i}in the treatment group (\mathcal{A}_1).
mseconstsData frame of intermediate quantities used in bandwidth calculation:
N.CoEffective sample size for the control group
\mathcal{A}_0.N.TrEffective sample size for the treatment group
\mathcal{A}_1.bias.0Bias constant estimate for the control group.
bias.1Bias constant estimate for the treatment group.
var.0Variance constant estimate for the control group.
var.1Variance constant estimate for the treatment group.
reg.bias.0Bias correction adjustment for the control group.
reg.bias.1Bias correction adjustment for the treatment group.
reg.var.0Variance of the bias estimate for the control group.
reg.var.1Variance of the bias estimate for the treatment group.
optList containing:
pPolynomial order used for estimation.
kernelKernel function used.
kernel_typeType of kernel (product or radial).
stdvarsLogical indicating if standardization was applied.
bwselectBandwidth selection strategy used.
bwparamTarget parameter for fuzzy bandwidth selection.
methodBandwidth estimation method.
vceVariance estimation method.
scaleregulScaling factor for regularization.
scalebiascrctScaling factor for bias correction.
NTotal sample size
N.
callMatched function call.
Author(s)
Matias D. Cattaneo, Princeton University. matias.d.cattaneo@gmail.com
Rocio Titiunik, Princeton University. titiunik@princeton.edu
Ruiqi Rae Yu, Princeton University. raeyuuuu@gmail.com
References
Cattaneo, M. D., and Titiunik, R. (2022). Regression Discontinuity Designs. doi:10.1146/annurev-economics-051520-021409.
Cattaneo, M. D., Titiunik, R., and Yu, R. R. (2026). Estimation and Inference in Boundary Discontinuity Designs: Location-Based Methods.
Cattaneo, M. D., Titiunik, R., and Yu, R. R. (2026). Boundary Discontinuity Designs: Theory and Practice.
Cattaneo, M. D., Titiunik, R., and Yu, R. R. (2025). rd2d: Causal Inference in Boundary Discontinuity Designs.
See Also
rd2d, print.rdbw2d, summary.rdbw2d
Examples
# Simulated example
set.seed(123)
n <- 800
X1 <- rnorm(n)
X2 <- rnorm(n)
assignment <- as.numeric(X1 > 0)
Y <- 3 + 2 * X1 + 1.5 * X2 + assignment + rnorm(n)
X <- cbind(X1, X2)
b <- matrix(c(0, 0, 0, 1), ncol = 2)
# MSE optimal bandwidth for rd2d
bws <- rdbw2d(Y, X, assignment, b, masspoints = "off", bwcheck = 10)
# View the bandwidth selection results
print(bws)
summary(bws)
# Fuzzy bandwidth selection can target the Wald ratio or the reduced form
fuzzy <- as.numeric(runif(n) < ifelse(assignment == 1, 0.8, 0.2))
Y.fuzzy <- 3 + 2 * X1 + 1.5 * X2 + 1.5 * fuzzy + rnorm(n)
bws.fuzzy <- rdbw2d(Y.fuzzy, X, assignment, b, fuzzy = fuzzy, bwparam = "main",
masspoints = "off", bwcheck = 10)
print(bws.fuzzy)
Bandwidth Selection for Distance-Based Methods for Boundary Discontinuity Design
Description
rdbw2d.distance implements bandwidth selectors for distance-based local
polynomial boundary discontinuity (BD) estimation and inference.
The command targets level effects at two-dimensional boundary points.
See Cattaneo, M. D., Titiunik, R., and Yu, R. R. (2026)
for methodological background.
Usage
rdbw2d.distance(
Y,
distance,
b = NULL,
p = 1,
kink.unknown = c(FALSE, FALSE),
kink.position = NULL,
kernel = c("tri", "triangular", "epa", "epanechnikov", "uni", "uniform", "gau",
"gaussian"),
bwselect = c("mserd", "cerrd", "imserd", "icerrd", "msetwo", "certwo", "imsetwo",
"icertwo"),
bwparam = c("main", "itt"),
vce = c("hc1", "hc0", "hc2", "hc3"),
bwcheck = 20 + p + 1,
masspoints = c("check", "adjust", "off"),
cluster = NULL,
scaleregul = 1,
cqt = 0.5,
fuzzy = NULL
)
Arguments
Y |
Dependent variable; a numeric vector of length |
distance |
Signed distance scores; a numeric matrix or data frame of
dimension |
b |
Optional evaluation points; a matrix or data frame specifying boundary points |
p |
Polynomial order for point estimation. Default is |
kink.unknown |
Logical value or vector of length 2 controlling
unknown-kink bandwidth adjustments. A scalar |
kink.position |
Optional boundary positions of known kink points.
Either a logical vector with one entry per boundary point, where |
kernel |
Kernel function to use. Options are |
bwselect |
Bandwidth selection strategy. Options:
|
bwparam |
Target parameter used for fuzzy automatic bandwidth
selection. Options are |
vce |
Variance-covariance estimator for standard errors. Options:
|
bwcheck |
If a positive integer is provided, the preliminary bandwidth used in the calculations is enlarged so that at least |
masspoints |
Strategy for handling mass points in the running variable. Options:
|
cluster |
Cluster ID variable used for cluster-robust variance estimation with degrees-of-freedom weights. Default is |
scaleregul |
Scaling factor for the regularization term in bandwidth selection. Default is |
cqt |
Constant controlling subsample fraction for initial bias estimation. Default is |
fuzzy |
Optional treatment receipt/status variable used for fuzzy RD
bandwidth selection. If supplied, |
Value
An object of class "rdbw2d.distance", containing:
bwsData frame of optimal bandwidths for each evaluation point:
b1First coordinate of the evaluation point
b1.b2Second coordinate of the evaluation point
b2.h0Bandwidth for observations with negative signed distance.
h1Bandwidth for observations with non-negative signed distance.
mseconstsData frame of intermediate bias and variance constants used for MSE/IMSE calculations, including
N.CoandN.Tr, the effective sample sizes for observations with negative and non-negative signed distances, respectively.optA list of options and settings used in estimation, including
p,kernel, sample sizeN, and user-specified choices.callMatched function call.
Author(s)
Matias D. Cattaneo, Princeton University. matias.d.cattaneo@gmail.com
Rocio Titiunik, Princeton University. titiunik@princeton.edu
Ruiqi Rae Yu, Princeton University. raeyuuuu@gmail.com
References
Cattaneo, M. D., and Titiunik, R. (2022). Regression Discontinuity Designs. doi:10.1146/annurev-economics-051520-021409.
Cattaneo, M. D., Titiunik, R., and Yu, R. R. (2026). Estimation and Inference in Boundary Discontinuity Designs: Distance-Based Methods.
Cattaneo, M. D., Titiunik, R., and Yu, R. R. (2026). Boundary Discontinuity Designs: Theory and Practice.
Cattaneo, M. D., Titiunik, R., and Yu, R. R. (2025). rd2d: Causal Inference in Boundary Discontinuity Designs.
See Also
rd2d.distance, rd2d, summary.rdbw2d.distance, print.rdbw2d.distance
Examples
set.seed(123)
n <- 800
# Generate running variables x1 and x2
x1 <- rnorm(n)
x2 <- rnorm(n)
# Define treatment assignment: treated if x1 >= 0
assignment <- as.numeric(x1 >= 0)
# Generate outcome variable Y with some treatment effect
Y <- 3 + 2 * x1 + 1.5 * x2 + 1.5 * assignment + rnorm(n, sd = 0.5)
# Define evaluation points (e.g., at the origin and another point)
eval <- data.frame(x.1 = c(0, 0), x.2 = c(0, 1))
# Compute Euclidean distances to evaluation points
distance.a <- sqrt((x1 - eval$x.1[1])^2 + (x2 - eval$x.2[1])^2)
distance.b <- sqrt((x1 - eval$x.1[2])^2 + (x2 - eval$x.2[2])^2)
# Combine distances into a matrix
distance <- as.data.frame(cbind(distance.a, distance.b))
# Assign positive distances for treatment group, negative for control
assignment_expanded <- matrix(rep(2 * assignment - 1, times = ncol(distance)),
nrow = nrow(distance), ncol = ncol(distance))
distance <- distance * assignment_expanded
# Run the rdbw2d.distance function
bws <- rdbw2d.distance(Y, distance = distance, b = eval, masspoints = "off", bwcheck = 10)
# View the estimation results
print(bws)
summary(bws)
# Fuzzy distance-based bandwidths
fuzzy <- as.numeric(runif(n) < ifelse(assignment == 1, 0.8, 0.2))
Y.fuzzy <- 3 + 2 * x1 + 1.5 * x2 + 1.5 * fuzzy + rnorm(n, sd = 0.5)
bws.fuzzy <- rdbw2d.distance(Y.fuzzy, distance = distance, b = eval, fuzzy = fuzzy,
bwparam = "main", masspoints = "off",
bwcheck = 10)
print(bws.fuzzy)
Summary Method for 2D Local Polynomial RD Estimation
Description
Summarizes estimation and bandwidth results from a 2D local polynomial
regression discontinuity (RD) design, as produced by rd2d.
Usage
## S3 method for class 'rd2d'
summary(object, ...)
Arguments
object |
An object of class |
... |
Optional named arguments. Unsupported option names produce an error. Supported options include:
|
Value
Invisibly returns a list with displayed tables and uniform
confidence bands requested through cbands. Each returned estimate
table has the same columns as the corresponding rd2d output,
with cb.lower and cb.upper added only when uniform bands are
requested. Requested WBATE and LBATE rows are appended to the corresponding
returned table.
Author(s)
Matias D. Cattaneo, Princeton University. matias.d.cattaneo@gmail.com
Rocio Titiunik, Princeton University. titiunik@princeton.edu
Ruiqi Rae Yu, Princeton University. raeyuuuu@gmail.com
See Also
rd2d for estimation using 2D local polynomial RD
design.
Supported methods: print.rd2d, summary.rd2d.
Summary Method for 2D Local Polynomial RD Estimation (Distance-Based)
Description
Summarizes estimation and bandwidth results from a 2D local polynomial regression discontinuity (RD) design using distance-based methods, as returned by rd2d.distance.
Usage
## S3 method for class 'rd2d.distance'
summary(object, ...)
Arguments
object |
An object of class |
... |
Optional arguments. Supported options include:
|
Value
Invisibly returns an object of class "summary.rd2d.distance", a
list with elements:
-
tables: named list of returned summary tables. -
cbands: named list of confidence-band endpoints for outputs requested throughcbands. -
outputs: character vector of summarized outputs. -
call: matched summary call.
Requested WBATE and LBATE rows are appended to the returned estimation
table(s), except for output = "bw".
The function is also called for its side effect of printing a formatted
summary.
Author(s)
Matias D. Cattaneo, Princeton University. matias.d.cattaneo@gmail.com
Rocio Titiunik, Princeton University. titiunik@princeton.edu
Ruiqi Rae Yu, Princeton University. raeyuuuu@gmail.com
See Also
rd2d.distance for estimation using distance-based 2D local polynomial RD design.
Supported methods: print.rd2d.distance, summary.rd2d.distance.
Summary Method for Bandwidth Selection for 2D Local Polynomial RD Design
Description
Summary method for objects of class rdbw2d, displaying bandwidth selection results for 2D local polynomial regression discontinuity designs.
Usage
## S3 method for class 'rdbw2d'
summary(object, ...)
Arguments
object |
An object of class |
... |
Optional arguments. Supported options include:
|
Value
No return value. Called for its side effects of printing a formatted summary of rdbw2d results.
Author(s)
Matias D. Cattaneo, Princeton University. matias.d.cattaneo@gmail.com
Rocio Titiunik, Princeton University. titiunik@princeton.edu
Ruiqi Rae Yu, Princeton University. raeyuuuu@gmail.com
See Also
rdbw2d for bandwidth selection in 2D local polynomial RD design.
Supported methods: print.rdbw2d, summary.rdbw2d.
Summary Method for Bandwidth Selection in 2D Local Polynomial RD Design (Distance-Based)
Description
Summarizes bandwidth selection results from a 2D local polynomial regression discontinuity (RD) design using distance-based methods, as returned by rdbw2d.distance.
Usage
## S3 method for class 'rdbw2d.distance'
summary(object, ...)
Arguments
object |
An object of class |
... |
Optional arguments. Supported options include:
|
Value
No return value. This function is called for its side effects: it prints a formatted summary of rdbw2d.distance results.
Author(s)
Matias D. Cattaneo, Princeton University. matias.d.cattaneo@gmail.com
Rocio Titiunik, Princeton University. titiunik@princeton.edu
Ruiqi Rae Yu, Princeton University. raeyuuuu@gmail.com
See Also
rdbw2d.distance for bandwidth selection using 2D local polynomial RD design with distance-based methods.
Supported methods: print.rdbw2d.distance, summary.rdbw2d.distance.