Type: | Package |
Title: | Boundary Regression Discontinuity Designs |
Version: | 0.0.2 |
URL: | https://rdpackages.github.io/rd2d/ |
Description: | Provides estimation and inference procedures for boundary regression discontinuity (RD) designs using local polynomial methods, based on either bivariate coordinates or distance-based approaches. Methods are developed in Cattaneo, Titiunik, and Yu (2025) https://mdcattaneo.github.io/papers/Cattaneo-Titiunik-Yu_2025_BoundaryRD.pdf. |
Imports: | MASS, expm, ggplot2, stringr |
License: | GPL-2 |
Encoding: | UTF-8 |
RoxygenNote: | 7.3.2 |
Maintainer: | Ruiqi Rae Yu <rae.yu@princeton.edu> |
NeedsCompilation: | no |
Packaged: | 2025-06-10 19:43:09 UTC; yuruiqi |
Author: | Matias D. Cattaneo [aut], Rocio Titiunik [aut], Ruiqi Rae Yu [aut, cre] |
Repository: | CRAN |
Date/Publication: | 2025-06-10 20:00:02 UTC |
rd2d: Two Dimensional Local Polynomial Regression Discontinuity Design
Description
This package implements estimation and inference procedures for boundary regression discontinuity (RD) designs using local polynomial methods, based on either bivariate coordinates or distance-based approaches. Methods are developed in Cattaneo, Titiunik, and Yu (2025a). A companion software article is available at Cattaneo, Titiunik, and Yu (2025b).
Included functions are: rd2d for inference and estimation based on bivariate coordinates, rdbw2d for data-driven bandwidth selection based on bivariate coordinates, rd2d.dist for distance-based inference and estimation, rdbw2d.dist for distance-based bandwidth selection.
print()
and summary()
methods are available all four functions.
Related Stata, R, and Python packages useful for inference in RD designs are described in the following website:
For an introduction to regression discontinuity design, see Cattaneo, Idrobo, Titiunik (2024) and references therein.
Author(s)
Matias Cattaneo, Princeton University. cattaneo@princeton.edu. Rocio Titiunik, Princeton University. titiunik@princeton.edu. Ruiqi Rae Yu, Princeton University. rae.yu@princeton.edu.
References
Cattaneo, M. D., Titiunik, R., Yu, R. R. (2025a). Estimation and Inference in Boundary Discontinuity Designs
Cattaneo, M. D., Titiunik, R., Yu, R. R. (2025b). rd2d: Causal Inference in Boundary Discontinuity Designs
Cattaneo, M. D., Idrobo, N., Titiunik, R. (2024). A Practical Introduction to Regression Discontinuity Designs: Extensions
See Also
Useful links:
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. cattaneo@princeton.edu
Rocío Titiunik, Princeton University. titiunik@princeton.edu
Ruiqi Rae Yu, Princeton University. rae.yu@princeton.edu
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.dist
.
Usage
## S3 method for class 'rd2d.dist'
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.dist
results.
Author(s)
Matias D. Cattaneo, Princeton University. cattaneo@princeton.edu
Rocío Titiunik, Princeton University. titiunik@princeton.edu
Ruiqi Rae Yu, Princeton University. rae.yu@princeton.edu
See Also
rd2d.dist
for estimation using distance-based methods in 2D local polynomial RD designs.
Supported methods: print.rd2d.dist
, summary.rd2d.dist
.
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. cattaneo@princeton.edu
Rocío Titiunik, Princeton University. titiunik@princeton.edu
Ruiqi Rae Yu, Princeton University. rae.yu@princeton.edu
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.dist
.
Usage
## S3 method for class 'rdbw2d.dist'
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.dist
.
Author(s)
Matias D. Cattaneo, Princeton University. cattaneo@princeton.edu
Rocío Titiunik, Princeton University. titiunik@princeton.edu
Ruiqi Rae Yu, Princeton University. rae.yu@princeton.edu
See Also
rdbw2d.dist
for distance-based bandwidth selection in 2D local polynomial RD design.
Supported methods: print.rdbw2d.dist
, summary.rdbw2d.dist
.
Two-Dimensional Local Polynomial Regression Discontinuity Design
Description
rd2d
implements bivariate local polynomial boundary regression discontinuity (RD) point estimators with robust bias-corrected pointwise confidence intervals and
uniform confidence bands, developed in Cattaneo, Titiunik and Yu (2025a) with a companion software article Cattaneo, Titiunik and Yu (2025b). For robust bias-correction, see Calonico, Cattaneo, Titiunik (2014).
Companion commands are: rdbw2d
for data-driven bandwidth selection.
For other packages of RD designs, visit https://rdpackages.github.io/
Usage
rd2d(
Y,
X,
t,
b,
h = NULL,
deriv = c(0, 0),
tangvec = NULL,
p = 1,
q = 2,
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"),
C = NULL,
level = 95,
cbands = TRUE,
side = c("two", "left", "right"),
repp = 1000,
bwselect = c("mserd", "imserd", "msetwo", "imsetwo", "user provided"),
method = c("dpi", "rot"),
bwcheck = 50 + p + 1,
scaleregul = 3,
scalebiascrct = 1,
stdvars = TRUE
)
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 |
t |
Treatment indicator; a logical or binary vector indicating treatment assignment ( |
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 numeric 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:
|
masspoints |
Handling of mass points in the running variable. Options are:
|
C |
Cluster ID variable used for cluster-robust variance estimation. Default is |
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 repetitions for critical value simulation (used in uniform confidence bands). Default is 1000. |
bwselect |
Bandwidth selection strategy. Options:
|
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 TRUE, the running variables |
Value
An object of class "rd2d"
, a list with components:
results
A data frame with point estimates, variances, p-values, confidence intervals, confidence bands, bandwidths and effective sample size at each evaluation point.
b1
,b2
First and second coordinate of evaluation points
\mathbf{b} = (b_1,b_2)
.Est.p
Point estimate
\widehat{\tau}_p(\mathbf{b})
.Var.p
Variance of estimate
\widehat{\tau}_p(\mathbf{b})
.Est.q
Bias-corrected point estimate
\widehat{\tau}_q(\mathbf{b})
.Var.q
Variance of bias-corrected estimate
\widehat{\tau}_q(\mathbf{b})
.p-value
P-value based on t-statistic with bias-corrected estimate.
CI.lower
,CI.upper
Pointwise confidence intervals.
CB.lower
,CB.upper
Uniform confidence bands if computed.
h01
,h02
,h11
,h12
Bandwidths used in each coordinate and group. The four columns correspond to
h_{\text{control},1}
,h_{\text{control},2}
,h_{\text{treated},1}
,h_{\text{treated},2}
respectively.Nh0
,Nh1
Effective sample size on each side of the cutoff.
results.A0
Same structure as
results
but for control group outcomes.results.A1
Same structure as
results
but for treated group outcomes.cov.q
Covariance matrix for bias-corrected estimates
\widehat{\tau}_q(\mathbf{b})
for all point evaluations\mathbf{b}
.opt
List of options used in the function call.
rdmodel
String label for the RD model.
Author(s)
Matias D. Cattaneo, Princeton University. cattaneo@princeton.edu
Rocío Titiunik, Princeton University. titiunik@princeton.edu
Ruiqi Rae Yu, Princeton University. rae.yu@princeton.edu
References
Cattaneo, M. D., Titiunik, R., Yu, R. R. (2025a). Estimation and Inference in Boundary Discontinuity Designs
Cattaneo, M. D., Titiunik, R., Yu, R. R. (2025b). rd2d: Causal Inference in Boundary Discontinuity Designs
Calonico, S., Cattaneo, M. D., Titiunik, R. (2014) Robust Nonparametric Confidence Intervals for Regression-Discontinuity Designs
See Also
rdbw2d
, print.rd2d
, summary.rd2d
Examples
# Simulated example
set.seed(123)
n <- 5000
X1 <- rnorm(n)
X2 <- rnorm(n)
t <- as.numeric(X1 > 0)
Y <- 3 + 2 * X1 + 1.5 * X2 + t + rnorm(n)
X <- cbind(X1, X2)
b <- matrix(c(0, 0, 0, 1), ncol = 2)
# Estimate treatment effect using rd2d
result <- rd2d(Y, X, t, b, cbands = TRUE)
print(result)
summary(result)
Local Polynomial RD Estimation on Distance-Based Running Variables
Description
rd2d.dist
implements distance-based local polynomial boundary regression discontinuity (RD) point estimators with robust bias-corrected pointwise confidence intervals and
uniform confidence bands, developed in Cattaneo, Titiunik and Yu (2025a) with a companion software article Cattaneo, Titiunik and Yu (2025b). For robust bias-correction, see Calonico, Cattaneo, Titiunik (2014).
Companion commands are: rdbw2d.dist
for data-driven bandwidth selection.
For other packages of RD designs, visit https://rdpackages.github.io/
Usage
rd2d.dist(
Y,
D,
h = NULL,
b = NULL,
p = 1,
q = 2,
kink = c("off", "on"),
kernel = c("tri", "triangular", "epa", "epanechnikov", "uni", "uniform", "gau",
"gaussian"),
level = 95,
cbands = TRUE,
side = c("two", "left", "right"),
repp = 1000,
bwselect = c("mserd", "imserd", "msetwo", "imsetwo", "user provided"),
vce = c("hc1", "hc0", "hc2", "hc3"),
rbc = c("on", "off"),
bwcheck = 50 + p + 1,
masspoints = c("check", "adjust", "off"),
C = NULL,
scaleregul = 1,
cqt = 0.5
)
Arguments
Y |
Dependent variable; a numeric vector of length |
D |
Distance-based scores |
h |
Bandwidth(s); if |
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 |
Logical; whether to apply kink adjustment. Options: |
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:
|
vce |
Variance-covariance estimator for standard errors. Options:
|
rbc |
Logical. Whether to apply robust bias correction. 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:
|
C |
Cluster ID variable used for cluster-robust variance estimation. 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 |
Details
MSE bandwidth selection for geometrical RD design
Value
An object of class "rd2d.dist"
, a list containing:
results
A data frame with point estimates, variances, p-values, confidence intervals, confidence bands, and bandwidths at each evaluation point.
b1
First coordinate of the evaluation point.
b2
Second coordinate of the evaluation point.
Est.p
Point estimate
\widehat{\tau}_{\text{dist},p}(\mathbf{b})
with polynomial orderp
.Var.p
Variance of
\widehat{\tau}_{\text{dist},p}(\mathbf{b})
.Est.q
Bias-corrected estimate
\widehat{\tau}_{\text{dist},q}(\mathbf{b})
with polynomial orderq
.Var.q
Variance of
\widehat{\tau}_{\text{dist},q}(\mathbf{b})
.pvalue
Two-sided p-value based on
T_{\text{dist},q}(\mathbf{b})
.CI.lower
Lower bound of confidence interval.
CI.upper
Upper bound of confidence interval.
CB.lower
Lower bound of uniform confidence band (if
cbands=TRUE
).CB.upper
Upper bound of uniform confidence band (if
cbands=TRUE
).h0
Bandwidth used for control group (
D_i(\mathbf{b}) < 0
).h1
Bandwidth used for treatment group (
D_i(\mathbf{b}) \geq 0
).Nh0
Effective sample size for control group.
Nh1
Effective sample size for treatment group.
results.A0
Same structure as
results
but for control group outcomes.results.A1
Same structure as
results
but for treatment group outcomes.tau.hat
Vector of point estimates
\widehat{\tau}_p(\mathbf{b})
.se.hat
Standard errors corresponding to
\widehat{\tau}_p(\mathbf{b})
.cb
Confidence intervals and uniform bands.
cov.q
Covariance matrix for bias-corrected estimates
\widehat{\tau}_{\text{dist},q}(\mathbf{b})
for all point evaluations\mathbf{b}
.opt
List of options used in the function call.
Author(s)
Matias D. Cattaneo, Princeton University. cattaneo@princeton.edu
Rocío Titiunik, Princeton University. titiunik@princeton.edu
Ruiqi Rae Yu, Princeton University. rae.yu@princeton.edu
References
Cattaneo, M. D., Titiunik, R., Yu, R. R. (2025a). Estimation and Inference in Boundary Discontinuity Designs
Cattaneo, M. D., Titiunik, R., Yu, R. R. (2025b). rd2d: Causal Inference in Boundary Discontinuity Designs
Calonico, S., Cattaneo, M. D., Titiunik, R. (2014) Robust Nonparametric Confidence Intervals for Regression-Discontinuity Designs
See Also
rdbw2d.dist
, rd2d
, print.rd2d.dist
, summary.rd2d.dist
Examples
set.seed(123)
n <- 5000
# Generate running variables x1 and x2
x1 <- rnorm(n)
x2 <- rnorm(n)
# Define treatment assignment: treated if x1 >= 0
d <- as.numeric(x1 >= 0)
# Generate outcome variable y with some treatment effect
y <- 3 + 2 * x1 + 1.5 * x2 + 1.5 * d + 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
dist.a <- sqrt((x1 - eval$x.1[1])^2 + (x2 - eval$x.2[1])^2)
dist.b <- sqrt((x1 - eval$x.1[2])^2 + (x2 - eval$x.2[2])^2)
# Combine distances into a matrix
D <- as.data.frame(cbind(dist.a, dist.b))
# Assign positive distances for treatment group, negative for control
d_expanded <- matrix(rep(2 * d - 1, times = ncol(D)), nrow = nrow(D), ncol = ncol(D))
D <- D * d_expanded
# Run the rd2d.dist function
result <- rd2d.dist(y, D, b = eval)
# View the estimation results
print(result)
summary(result)
Bandwidth Selection for 2D Local Polynomial RD Design
Description
rdbw2d
implements bandwidth selector for bivariate local polynomial boundary regression discontinuity (RD) point estimators with robust bias-corrected pointwise confidence intervals and
uniform confidence bands, developed in Cattaneo, Titiunik and Yu (2025a) with a companion software article Cattaneo, Titiunik and Yu (2025b). For robust bias-correction, see Calonico, Cattaneo, Titiunik (2014).
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,
t,
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", "imserd", "msetwo", "imsetwo"),
method = c("dpi", "rot"),
vce = c("hc1", "hc0", "hc2", "hc3"),
bwcheck = 50 + p + 1,
masspoints = c("check", "adjust", "off"),
C = NULL,
scaleregul = 1,
scalebiascrct = 1,
stdvars = TRUE
)
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 |
t |
Treatment indicator; a logical or binary vector indicating treatment assignment ( |
b |
Evaluation points; a matrix or data frame specifying boundary points |
p |
Polynomial order of local polynomial estimator. |
deriv |
The order of the derivatives of the regression functions to be estimated; a numeric 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:
|
method |
Bandwidth selection method for bias estimator based on local polynomials. Either |
vce |
Variance-covariance estimation method. Options are:
|
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:
|
C |
Cluster ID variable used for cluster-robust variance estimation. Default is |
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 TRUE, the running variables |
Value
A list of class "rdbw2d"
containing:
bws
Data frame of estimated bandwidths for each evaluation point:
b1
First coordinate of the evaluation point.
b2
Second coordinate of the evaluation point.
h01
Estimated bandwidth for
X_{1i}
in the control group (\mathcal{A}_0
).h02
Estimated bandwidth for
X_{2i}
in the control group (\mathcal{A}_0
).h11
Estimated bandwidth for
X_{1i}
in the treatment group (\mathcal{A}_1
).h12
Estimated bandwidth for
X_{2i}
in the treatment group (\mathcal{A}_1
).
mseconsts
Data frame of intermediate quantities used in bandwidth calculation:
Nh0
Effective sample size for the control group
\mathcal{A}_0
.Nh1
Effective sample size for the treatment group
\mathcal{A}_1
.bias.0
Bias constant estimate for the control group.
bias.1
Bias constant estimate for the treatment group.
var.0
Variance constant estimate for the control group.
var.1
Variance constant estimate for the treatment group.
reg.bias.0
Bias correction adjustment for the control group.
reg.bias.1
Bias correction adjustment for the treatment group.
reg.var.0
Variance of the bias estimate for the control group.
reg.var.1
Variance of the bias estimate for the treatment group.
opt
List containing:
p
Polynomial order used for estimation.
kernel
Kernel function used.
kernel_type
Type of kernel (product or radial).
stdvars
Logical indicating if standardization was applied.
bwselect
Bandwidth selection strategy used.
method
Bandwidth estimation method.
vce
Variance estimation method.
scaleregul
Scaling factor for regularization.
scalebiascrct
Scaling factor for bias correction.
N
Total sample size
N
.
Author(s)
Matias D. Cattaneo, Princeton University. cattaneo@princeton.edu
Rocío Titiunik, Princeton University. titiunik@princeton.edu
Ruiqi Rae Yu, Princeton University. rae.yu@princeton.edu
References
Cattaneo, M. D., Titiunik, R., Yu, R. R. (2025a). Estimation and Inference in Boundary Discontinuity Designs
Cattaneo, M. D., Titiunik, R., Yu, R. R. (2025b). rd2d: Causal Inference in Boundary Discontinuity Designs
Calonico, S., Cattaneo, M. D., Titiunik, R. (2014) Robust Nonparametric Confidence Intervals for Regression-Discontinuity Designs
See Also
rd2d
, print.rdbw2d
, summary.rdbw2d
Examples
# Simulated example
set.seed(123)
n <- 5000
X1 <- rnorm(n)
X2 <- rnorm(n)
t <- as.numeric(X1 > 0)
Y <- 3 + 2 * X1 + 1.5 * X2 + t + rnorm(n)
X <- cbind(X1, X2)
b <- matrix(c(0, 0, 0, 1), ncol = 2)
# MSE optimal bandwidth for rd2d
bws <- rdbw2d(Y, X, t, b)
# View the bandwidth selection results
print(bws)
summary(bws)
Bandwidth Selection for Distance-Based RD Designs
Description
rdbw2d.dist
implements bandwidth selector for distance-based local polynomial boundary regression discontinuity (RD) point estimators with robust bias-corrected pointwise confidence intervals and
uniform confidence bands, developed in Cattaneo, Titiunik and Yu (2025a) with a companion software article Cattaneo, Titiunik and Yu (2025b). For robust bias-correction, see Calonico, Cattaneo, Titiunik (2014).
Usage
rdbw2d.dist(
Y,
D,
b = NULL,
p = 1,
kink = c("off", "on"),
kernel = c("tri", "triangular", "epa", "epanechnikov", "uni", "uniform", "gau",
"gaussian"),
bwselect = c("mserd", "imserd", "msetwo", "imsetwo"),
vce = c("hc1", "hc0", "hc2", "hc3"),
bwcheck = 20 + p + 1,
masspoints = c("check", "adjust", "off"),
C = NULL,
scaleregul = 1,
cqt = 0.5
)
Arguments
Y |
Dependent variable; a numeric vector of length |
D |
Distance-based scores |
b |
Optional evaluation points; a matrix or data frame specifying boundary points |
p |
Polynomial order for point estimation. Default is |
kink |
Logical; whether to apply kink adjustment. Options: |
kernel |
Kernel function to use. Options are |
bwselect |
Bandwidth selection strategy. Options:
|
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:
|
C |
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 |
Value
An object of class "rdbw2d.dist"
, containing:
bws
Data frame of optimal bandwidths for each evaluation point:
b1
First coordinate of the evaluation point
b1
.b2
Second coordinate of the evaluation point
b2
.h0
Bandwidth for observations with distance
D_{i}(\mathbf{b}) < 0
.h1
Bandwidth for observations with distance
D_{i}(\mathbf{b}) \geq 0
.Nh0
Effective sample size for
D_{i}(\mathbf{b}) < 0
.Nh1
Effective sample size for
D_{i}(\mathbf{b}) \geq 0
.
mseconsts
Data frame of intermediate bias and variance constants used for MSE/IMSE calculations.
opt
List of options used in the function call.
Author(s)
Matias D. Cattaneo, Princeton University. cattaneo@princeton.edu
Rocío Titiunik, Princeton University. titiunik@princeton.edu
Ruiqi Rae Yu, Princeton University. rae.yu@princeton.edu
References
Cattaneo, M. D., Titiunik, R., Yu, R. R. (2025a). Estimation and Inference in Boundary Discontinuity Designs
Cattaneo, M. D., Titiunik, R., Yu, R. R. (2025b). rd2d: Causal Inference in Boundary Discontinuity Designs
Calonico, S., Cattaneo, M. D., Titiunik, R. (2014) Robust Nonparametric Confidence Intervals for Regression-Discontinuity Designs
See Also
rd2d.dist
, rd2d
, summary.rdbw2d.dist
, print.rdbw2d.dist
Examples
set.seed(123)
n <- 5000
# Generate running variables x1 and x2
x1 <- rnorm(n)
x2 <- rnorm(n)
# Define treatment assignment: treated if x1 >= 0
d <- as.numeric(x1 >= 0)
# Generate outcome variable y with some treatment effect
y <- 3 + 2 * x1 + 1.5 * x2 + 1.5 * d + 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
dist.a <- sqrt((x1 - eval$x.1[1])^2 + (x2 - eval$x.2[1])^2)
dist.b <- sqrt((x1 - eval$x.1[2])^2 + (x2 - eval$x.2[2])^2)
# Combine distances into a matrix
D <- as.data.frame(cbind(dist.a, dist.b))
# Assign positive distances for treatment group, negative for control
d_expanded <- matrix(rep(2 * d - 1, times = ncol(D)), nrow = nrow(D), ncol = ncol(D))
D <- D * d_expanded
# Run the rd2d.dist function
bws <- rdbw2d.dist(y, D, b = eval)
# View the estimation results
print(bws)
summary(bws)
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 arguments. Supported options include:
|
Value
No return value. This function is called for its side effects: it prints a formatted summary of rd2d
results.
Author(s)
Matias D. Cattaneo, Princeton University. cattaneo@princeton.edu
Rocío Titiunik, Princeton University. titiunik@princeton.edu
Ruiqi Rae Yu, Princeton University. rae.yu@princeton.edu
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.dist
.
Usage
## S3 method for class 'rd2d.dist'
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 rd2d.dist
results.
Author(s)
Matias D. Cattaneo, Princeton University. cattaneo@princeton.edu
Rocío Titiunik, Princeton University. titiunik@princeton.edu
Ruiqi Rae Yu, Princeton University. rae.yu@princeton.edu
See Also
rd2d.dist
for estimation using distance-based 2D local polynomial RD design.
Supported methods: print.rd2d.dist
, summary.rd2d.dist
.
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. cattaneo@princeton.edu
Rocío Titiunik, Princeton University. titiunik@princeton.edu
Ruiqi Rae Yu, Princeton University. rae.yu@princeton.edu
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.dist
.
Usage
## S3 method for class 'rdbw2d.dist'
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.dist
results.
Author(s)
Matias D. Cattaneo, Princeton University. cattaneo@princeton.edu
Rocío Titiunik, Princeton University. titiunik@princeton.edu
Ruiqi Rae Yu, Princeton University. rae.yu@princeton.edu
See Also
rdbw2d.dist
for bandwidth selection using 2D local polynomial RD design with distance-based methods.
Supported methods: print.rdbw2d.dist
, summary.rdbw2d.dist
.