Title: | Power Calculations for RD Designs |
---|---|
Description: | The regression discontinuity (RD) design is a popular quasi-experimental design for causal inference and policy evaluation. The 'rdpower' package provides tools to perform power, sample size and MDE calculations in RD designs: rdpower() calculates the power of an RD design, rdsampsi() calculates the required sample size to achieve a desired power and rdmde() calculates minimum detectable effects. See Cattaneo, Titiunik and Vazquez-Bare (2019) <https://rdpackages.github.io/references/Cattaneo-Titiunik-VazquezBare_2019_Stata.pdf> for further methodological details. |
Authors: | Matias D. Cattaneo, Rocio Titiunik, Gonzalo Vazquez-Bare |
Maintainer: | Gonzalo Vazquez-Bare <[email protected]> |
License: | GPL-2 |
Version: | 2.2 |
Built: | 2025-02-12 04:40:36 UTC |
Source: | https://github.com/cran/rdpower |
The regression discontinuity (RD) design is a popular quasi-experimental design
for causal inference and policy evaluation. The 'rdpower'
package provides tools
to perform power, sample size and MDE calculations in RD designs: rdpower()
calculates
the power of an RD design, rdsampsi()
calculates the required sample size to achieve
a desired power and rdmde()
calculates minimum detectable effects. This package relies on the rdrobust
package. See Calonico, Cattaneo and Titiunik (2014, 2015) and
Calonico, Cattaneo, Farrell and Titiunik (2017).
For more details, and related Stata
and R
packages
useful for analysis of RD designs, visit https://rdpackages.github.io/.
Matias Cattaneo, Princeton University. [email protected]
Rocio Titiunik, Princeton University. [email protected]
Gonzalo Vazquez-Bare, UC Santa Barbara. [email protected]
Calonico, S., M. D. Cattaneo, M. Farrell and R. Titiunik. (2017). rdrobust
: Software for Regression Discontinuity Designs. Stata Journal 17(2): 372-404.
Calonico, S., M. D. Cattaneo, and R. Titiunik. (2014). Robust Data-Driven Inference in the Regression-Discontinuity Design. Stata Journal 14(4): 909-946.
Calonico, S., M. D. Cattaneo, and R. Titiunik. (2015). rdrobust
: An R Package for Robust Nonparametric Inference in Regression-Discontinuity Designs. R Journal 7(1): 38-51.
Cattaneo, M. D., R. Titiunik and G. Vazquez-Bare. (2019). Power Calculations for Regression Discontinuity Designs. Stata Journal, 19(1): 210-245.
rdmde()
performs MDE calculations for RD designs.
rdmde( data = NULL, cutoff = 0, alpha = 0.05, beta = 0.8, nsamples = NULL, sampsi = NULL, samph = NULL, all = FALSE, bias = NULL, variance = NULL, init.cond = NULL, covs = NULL, covs_drop = TRUE, deriv = 0, p = 1, q = NULL, h = NULL, b = NULL, rho = NULL, kernel = "triangular", bwselect = "mserd", vce = "nn", cluster = NULL, scalepar = 1, scaleregul = 1, fuzzy = NULL, level = 95, weights = NULL, masspoints = "adjust", bwcheck = NULL, bwrestrict = TRUE, stdvars = FALSE )
rdmde( data = NULL, cutoff = 0, alpha = 0.05, beta = 0.8, nsamples = NULL, sampsi = NULL, samph = NULL, all = FALSE, bias = NULL, variance = NULL, init.cond = NULL, covs = NULL, covs_drop = TRUE, deriv = 0, p = 1, q = NULL, h = NULL, b = NULL, rho = NULL, kernel = "triangular", bwselect = "mserd", vce = "nn", cluster = NULL, scalepar = 1, scaleregul = 1, fuzzy = NULL, level = 95, weights = NULL, masspoints = "adjust", bwcheck = NULL, bwrestrict = TRUE, stdvars = FALSE )
data |
a matrix (Y,R) containing the outcome variable and the running variable (as column vectors). |
cutoff |
the RD cutoff (default is 0). |
alpha |
specifies the significance level for the power function. Default is 0.05. |
beta |
specifies the desired power. Default is 0.8. |
nsamples |
sets the total sample size to the left, sample size to the left inside the bandwidth, total sample size to the right and sample size to the right of the cutoff inside the bandwidth to calculate the variance when the running variable is not specified. When not specified, the values are calculated using the running variable. |
sampsi |
sets the sample size at each side of the cutoff for power calculation. The first number is the sample size to the left of the cutoff and the second number is the sample size to the right. Default values are the sample sizes inside the chosen bandwidth. |
samph |
sets the bandwidths at each side of the cutoff for power calculation. The first number is the bandwidth to the left of the cutoff and the second number is the bandwidth to the right. Default values are the bandwidths used by |
all |
displays the power using the conventional variance estimator, in addition to the robust bias corrected one. |
bias |
set bias to the left and right of the cutoff. If not specified, the biases are estimated using |
variance |
set variance to the left and right of the cutoff. If not specified, the variances are estimated using |
init.cond |
sets the initial condition for the Newton-Raphson algorithm that finds the MDE. Default is 0.2 times the standard deviation of the outcome below the cutoff. |
covs |
option for |
covs_drop |
option for |
deriv |
option for |
p |
option for |
q |
option for |
h |
option for |
b |
option for |
rho |
option for |
kernel |
option for |
bwselect |
option for |
vce |
option for |
cluster |
option for |
scalepar |
option for |
scaleregul |
option for |
fuzzy |
option for |
level |
option for |
weights |
option for |
masspoints |
option for |
bwcheck |
option for |
bwrestrict |
option for |
stdvars |
option for |
mde |
MDE using robust bias corrected standard error |
se.rbc |
robust bias corrected standard error |
sampsi.r |
number of observations inside the window to the right of the cutoff |
sampsi.l |
number of observations inside the window to the left of the cutoff |
samph.r |
bandwidth to the right of the cutoff |
samph.l |
bandwidth to the left of the cutoff |
alpha |
significance level used in power function |
bias.r |
bias to the right of the cutoff |
bias.l |
bias to the left of the cutoff |
Vr.rb |
Robust bias corrected variance to the right of the cutoff |
Vl.rb |
Robust bias corrected variance to the left of the cutoff |
N.r |
Total sample size to the right of the cutoff |
N.l |
Total sample size to the left of the cutoff |
mde.conv |
MDE using conventional inference |
se.conv |
conventional standard error |
Matias Cattaneo, Princeton University. [email protected]
Rocio Titiunik, Princeton University. [email protected]
Gonzalo Vazquez-Bare, UC Santa Barbara. [email protected]
Cattaneo, M. D., R. Titiunik and G. Vazquez-Bare. (2019). Power Calculations for Regression Discontinuity Designs. Stata Journal, 19(1): 210-245.
# Toy dataset X <- array(rnorm(2000),dim=c(1000,2)) R <- X[,1] + X[,2] + rnorm(1000) Y <- 1 + R -.5*R^2 + .3*R^3 + (R>=0) + rnorm(1000) # MDE calculation tmp <- rdmde(data=cbind(Y,R),init.cond=0.5)
# Toy dataset X <- array(rnorm(2000),dim=c(1000,2)) R <- X[,1] + X[,2] + rnorm(1000) Y <- 1 + R -.5*R^2 + .3*R^3 + (R>=0) + rnorm(1000) # MDE calculation tmp <- rdmde(data=cbind(Y,R),init.cond=0.5)
rdpower()
performs power calculations for RD designs.
rdpower( data = NULL, cutoff = 0, tau = NULL, alpha = 0.05, nsamples = NULL, sampsi = NULL, samph = NULL, all = FALSE, bias = NULL, variance = NULL, plot = FALSE, graph.range = NULL, covs = NULL, covs_drop = TRUE, deriv = 0, p = 1, q = NULL, h = NULL, b = NULL, rho = NULL, kernel = "triangular", bwselect = "mserd", vce = "nn", cluster = NULL, scalepar = 1, scaleregul = 1, fuzzy = NULL, level = 95, weights = NULL, masspoints = "adjust", bwcheck = NULL, bwrestrict = TRUE, stdvars = FALSE )
rdpower( data = NULL, cutoff = 0, tau = NULL, alpha = 0.05, nsamples = NULL, sampsi = NULL, samph = NULL, all = FALSE, bias = NULL, variance = NULL, plot = FALSE, graph.range = NULL, covs = NULL, covs_drop = TRUE, deriv = 0, p = 1, q = NULL, h = NULL, b = NULL, rho = NULL, kernel = "triangular", bwselect = "mserd", vce = "nn", cluster = NULL, scalepar = 1, scaleregul = 1, fuzzy = NULL, level = 95, weights = NULL, masspoints = "adjust", bwcheck = NULL, bwrestrict = TRUE, stdvars = FALSE )
data |
a matrix (Y,R) containing the outcome variable and the running variable (as column vectors). |
cutoff |
the RD cutoff (default is 0). |
tau |
specifies the treatment effect under the alternative at which the power function is evaluated. The default is half the standard deviation of the outcome for the untreated group. |
alpha |
specifies the significance level for the power function. Default is 0.05. |
nsamples |
sets the total sample size to the left, sample size to the left inside the bandwidth, total sample size to the right and sample size to the right of the cutoff inside the bandwidth to calculate the variance when the running variable is not specified. When not specified, the values are calculated using the running variable. |
sampsi |
sets the sample size at each side of the cutoff for power calculation. The first number is the sample size to the left of the cutoff and the second number is the sample size to the right. Default values are the sample sizes inside the chosen bandwidth. |
samph |
sets the bandwidths at each side of the cutoff for power calculation. The first number is the bandwidth to the left of the cutoff and the second number is the bandwidth to the right. Default values are the bandwidths used by |
all |
displays the power using the conventional variance estimator, in addition to the robust bias corrected one. |
bias |
set bias to the left and right of the cutoff. If not specified, the biases are estimated using |
variance |
set variance to the left and right of the cutoff. If not specified, the variances are estimated using |
plot |
plots the power function using the conventional and robust bias corrected standard errors from |
graph.range |
range of the plot. |
covs |
option for |
covs_drop |
option for |
deriv |
option for |
p |
option for |
q |
option for |
h |
option for |
b |
option for |
rho |
option for |
kernel |
option for |
bwselect |
option for |
vce |
option for |
cluster |
option for |
scalepar |
option for |
scaleregul |
option for |
fuzzy |
option for |
level |
option for |
weights |
option for |
masspoints |
option for |
bwcheck |
option for |
bwrestrict |
option for |
stdvars |
option for |
power.rbc |
power against tau using robust bias corrected standard error |
se.rbc |
robust bias corrected standard error |
sampsi.r |
number of observations inside the window to the right of the cutoff |
sampsi.l |
number of observations inside the window to the left of the cutoff |
samph.r |
bandwidth to the right of the cutoff |
samph.l |
bandwidth to the left of the cutoff |
alpha |
significance level used in power function |
tau |
treatment effect under alternative hypothesis |
bias.r |
bias to the right of the cutoff |
bias.l |
bias to the left of the cutoff |
Vr.rb |
Robust bias corrected variance to the right of the cutoff |
Vl.rb |
Robust bias corrected variance to the left of the cutoff |
N.r |
Total sample size to the right of the cutoff |
N.l |
Total sample size to the left of the cutoff |
power.conv |
power against tau using conventional inference |
se.conv |
conventional standard error |
Matias Cattaneo, Princeton University. [email protected]
Rocio Titiunik, Princeton University. [email protected]
Gonzalo Vazquez-Bare, UC Santa Barbara. [email protected]
Cattaneo, M. D., R. Titiunik and G. Vazquez-Bare. (2019). Power Calculations for Regression Discontinuity Designs. Stata Journal, 19(1): 210-245.
# Toy dataset X <- array(rnorm(2000),dim=c(1000,2)) R <- X[,1] + X[,2] + rnorm(1000) Y <- 1 + R -.5*R^2 + .3*R^3 + (R>=0) + rnorm(1000) # Power against tau = 1 tmp <- rdpower(data=cbind(Y,R),tau=1) # Power against tau = 1 including covariates tmp <- rdpower(data=cbind(Y,R),tau=1,covs=X)
# Toy dataset X <- array(rnorm(2000),dim=c(1000,2)) R <- X[,1] + X[,2] + rnorm(1000) Y <- 1 + R -.5*R^2 + .3*R^3 + (R>=0) + rnorm(1000) # Power against tau = 1 tmp <- rdpower(data=cbind(Y,R),tau=1) # Power against tau = 1 including covariates tmp <- rdpower(data=cbind(Y,R),tau=1,covs=X)
rdsampsi()
performs sample size calculations for RD designs.
rdsampsi( data = NULL, cutoff = 0, tau = NULL, alpha = 0.05, beta = 0.8, samph = NULL, nsamples = NULL, all = FALSE, bias = NULL, variance = NULL, nratio = NULL, init.cond = NULL, plot = FALSE, graph.range = NULL, covs = NULL, covs_drop = TRUE, deriv = 0, p = 1, q = NULL, h = NULL, b = NULL, rho = NULL, kernel = "triangular", bwselect = "mserd", vce = "nn", cluster = NULL, scalepar = 1, scaleregul = 1, fuzzy = NULL, level = 95, weights = NULL, masspoints = "adjust", bwcheck = NULL, bwrestrict = TRUE, stdvars = FALSE )
rdsampsi( data = NULL, cutoff = 0, tau = NULL, alpha = 0.05, beta = 0.8, samph = NULL, nsamples = NULL, all = FALSE, bias = NULL, variance = NULL, nratio = NULL, init.cond = NULL, plot = FALSE, graph.range = NULL, covs = NULL, covs_drop = TRUE, deriv = 0, p = 1, q = NULL, h = NULL, b = NULL, rho = NULL, kernel = "triangular", bwselect = "mserd", vce = "nn", cluster = NULL, scalepar = 1, scaleregul = 1, fuzzy = NULL, level = 95, weights = NULL, masspoints = "adjust", bwcheck = NULL, bwrestrict = TRUE, stdvars = FALSE )
data |
a matrix (Y,R) containing the outcome variable and the running variable (as column vectors). |
cutoff |
the RD cutoff (default is 0). |
tau |
specifies the treatment effect under the alternative at which the power function is evaluated. The default is half the standard deviation of the outcome for the untreated group. |
alpha |
specifies the significance level for the power function. Default is 0.05. |
beta |
specifies the desired power. Default is 0.8. |
samph |
sets the bandwidths at each side of the cutoff for power calculation. The first number is the bandwidth to the left of the cutoff and the second number is the bandwidth to the right. Default values are the bandwidths used by |
nsamples |
sets the total sample size to the left, sample size to the left inside the bandwidth, total sample size to the right and sample size to the right of the cutoff inside the bandwidth to calculate the variance when the running variable is not specified. When not specified, the values are calculated using the running variable. |
all |
displays the power using the conventional variance estimator, in addition to the robust bias corrected one. |
bias |
set bias to the left and right of the cutoff. If not specified, the biases are estimated using |
variance |
set variance to the left and right of the cutoff. If not specified, the variances are estimated using |
nratio |
specifies the proportion of treated units in the window. Default is the ratio of the standard deviation of the treated to the sum of the standard deviations for treated and controls. |
init.cond |
sets the initial condition for the Newton-Raphson algorithm that finds the sample size. Default is the number of observations in the sample with non-missing values of the outcome and running variable. |
plot |
plots the power function using the conventional and robust bias corrected standard errors from |
graph.range |
range of the plot. |
covs |
option for |
covs_drop |
option for |
deriv |
option for |
p |
option for |
q |
option for |
h |
option for |
b |
option for |
rho |
option for |
kernel |
option for |
bwselect |
option for |
vce |
option for |
cluster |
option for |
scalepar |
option for |
scaleregul |
option for |
fuzzy |
option for |
level |
option for |
weights |
option for |
masspoints |
option for |
bwcheck |
option for |
bwrestrict |
option for |
stdvars |
option for |
alpha |
significance level |
beta |
desired power |
tau |
treatment effect under alternative hypothesis |
sampsi.h.tot |
total number of observations inside the window |
sampsi.h.r |
number of observations inside the window to the right of the cutoff |
sampsi.h.l |
number of observations inside the window to the left of the cutoff |
N.r |
Total sample size to the right of the cutoff |
N.l |
Total sample size to the left of the cutoff |
samph.r |
bandwidth to the right of the cutoff |
samph.l |
bandwidth to the left of the cutoff |
var.r |
Robust bias corrected variance to the right of the cutoff |
Var.l |
Robust bias corrected variance to the left of the cutoff |
sampsi.h.tot.cl |
implied total number of observations inside the window using conventional s.e. |
sampsi.h.r.cl |
number of observations inside the window to the right of the cutoff using conventional s.e. |
sampsi.h.l.cl |
number of observations inside the window to the left of the cutoff using conventional s.e. |
no.iter |
number of iterations until convergence of the Newton-Raphson algorithm |
init.cond |
initial condition of the Newton-Raphson algorithm |
Matias Cattaneo, Princeton University. [email protected]
Rocio Titiunik, Princeton University. [email protected]
Gonzalo Vazquez-Bare, UC Santa Barbara. [email protected]
Cattaneo, M. D., R. Titiunik and G. Vazquez-Bare. (2019). Power Calculations for Regression Discontinuity Designs. Stata Journal, 19(1): 210-245.
# Toy dataset X <- array(rnorm(2000),dim=c(1000,2)) R <- X[,1] + X[,2] + rnorm(1000) Y <- 1 + R -.5*R^2 + .3*R^3 + (R>=0) + rnorm(1000) # Sample size to achieve power of 0.8 against tau = 1 tmp <- rdsampsi(data=cbind(Y,R),tau=1) # Sample size against tau = 1 including covariates tmp <- rdsampsi(data=cbind(Y,R),tau=1,covs=X)
# Toy dataset X <- array(rnorm(2000),dim=c(1000,2)) R <- X[,1] + X[,2] + rnorm(1000) Y <- 1 + R -.5*R^2 + .3*R^3 + (R>=0) + rnorm(1000) # Sample size to achieve power of 0.8 against tau = 1 tmp <- rdsampsi(data=cbind(Y,R),tau=1) # Sample size against tau = 1 including covariates tmp <- rdsampsi(data=cbind(Y,R),tau=1,covs=X)