Package RDD': R Topics Documented
Package RDD': R Topics Documented
Package RDD': R Topics Documented
R topics documented:
rdd-package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
DCdensity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
IKbandwidth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
kernelwts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
plot.RD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
print.RD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
RDestimate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
summary.RD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Index 11
1
2 DCdensity
Description
Regression discontinuity estimation package
Details
rdd supports both sharp and fuzzy RDD utilizing the AER package for 2SLS regression under
the fuzzy design. Local linear regressions are performed to either side of the cutpoint using the
Imbens-Kalyanamaran optimal bandwidth calculation, IKbandwidth.
Author(s)
Drew Dimmery <[email protected]>
See Also
RDestimate, DCdensity, IKbandwidth, summary.RDplot.RD, kernelwts
Description
DCdensity implements the McCrary (2008) sorting test.
Usage
DCdensity(runvar, cutpoint, bin = NULL, bw = NULL, verbose = FALSE,
plot = TRUE, ext.out = FALSE, htest = FALSE)
Arguments
runvar numerical vector of the running variable
cutpoint the cutpoint (defaults to 0)
bin the binwidth (defaults to 2*sd(runvar)*length(runvar)^(-.5))
bw the bandwidth to use (by default uses bandwidth selection calculation from Mc-
Crary (2008))
verbose logical flag specifying whether to print diagnostic information to the terminal.
(defaults to FALSE)
plot logical flag indicating whether to plot the histogram and density estimations (de-
faults to TRUE). The user may wrap this function in additional graphical options
to modify the plot.
DCdensity 3
ext.out logical flag indicating whether to return extended output. When FALSE (the de-
fault) DCdensity will return only the p-value of the test. When TRUE, DCdensity
will return the additional information documented below.
htest logical flag indicating whether to return an "htest" object compatible with base
R’s hypothesis test output.
Value
If ext.out is FALSE, only the p value will be returned. Additional output is enabled when ext.out
is TRUE. In this case, a list will be returned with the following elements:
Author(s)
References
McCrary, Justin. (2008) "Manipulation of the running variable in the regression discontinuity de-
sign: A density test," Journal of Econometrics. 142(2): 698-714. http://dx.doi.org/10.1016/
j.jeconom.2007.05.005
Examples
#No discontinuity
x<-runif(1000,-1,1)
DCdensity(x,0)
#Discontinuity
x<-runif(1000,-1,1)
x<-x+2*(runif(1000,-1,1)>0&x<0)
DCdensity(x,0)
4 IKbandwidth
Description
IKbandwidth calculates the Imbens-Kalyanaraman optimal bandwidth for local linear regression in
Regression discontinuity designs.
Usage
Arguments
Value
Author(s)
References
Imbens, Guido and Karthik Kalyanaraman. (2009) "Optimal Bandwidth Choice for the regression
discontinuity estimator," NBER Working Paper Series. 14726. http://www.nber.org/papers/
w14726
kernelwts 5
Description
This function will calculate the appropriate kernel weights for a vector. This is useful when, for
instance, one wishes to perform local regression.
Usage
Arguments
X input x values. This variable represents the axis along which kernel weighting
should be performed.
center the point from which distances should be calculated.
bw the bandwidth.
kernel a string indicating the kernel to use. Options are "triangular" (the default),
"epanechnikov", "quartic", "triweight", "tricube", "gaussian", and "cosine".
Value
A vector of weights with length equal to that of the X input (one weight per element of X).
Author(s)
Examples
require(graphics)
X<-seq(-1,1,.01)
triang.wts<-kernelwts(X,0,1,kernel="triangular")
plot(X,triang.wts,type="l")
cos.wts<-kernelwts(X,0,1,kernel="cosine")
plot(X,cos.wts,type="l")
6 plot.RD
Description
Plot the relationship between the running variable and the outcome
Usage
Arguments
Details
It is important to note that this function will only plot the discontinuity using the bandwidth which
is first in the vector of bandwidths passed to RDestimate
Author(s)
Description
Print a very basic summary of the regression discontinuity
Usage
## S3 method for class 'RD'
print(x, digits = max(3, getOption("digits") - 3), ...)
Arguments
x rd object, typically the result of RDestimate
digits number of digits to print
... unused
Author(s)
Drew Dimmery <<[email protected]>>
Description
RDestimate supports both sharp and fuzzy RDD utilizing the AER package for 2SLS regression
under the fuzzy design. Local linear regressions are performed to either side of the cutpoint using
the Imbens-Kalyanaraman optimal bandwidth calculation, IKbandwidth.
Usage
RDestimate(formula, data, subset = NULL, cutpoint = NULL, bw = NULL,
kernel = "triangular", se.type = "HC1", cluster = NULL,
verbose = FALSE, model = FALSE, frame = FALSE)
Arguments
formula the formula of the RDD. This is supplied in the format of y ~ x for a simple
sharp RDD, or y ~ x | c1 + c2 for a sharp RDD with two covariates. Fuzzy
RDD may be specified as y ~ x + z where x is the running variable, and z
is the endogenous treatment variable. Covariates are then included in the same
manner as in a sharp RDD.
data an optional data frame
8 RDestimate
Details
Covariates are problematic for inclusion in the regression discontinuity design. This package allows
their inclusion, but cautions against them insomuch as is possible. When covariates are included in
the specification, they are simply included as exogenous regressors. In the sharp design, this means
they are simply added into the regression equation, uninteracted with treatment. Likewise for the
fuzzy design, in which they are added as regressors in both stages of estimation.
Value
RDestimate returns an object of class "RD". The functions summary and plot are used to obtain
and print a summary and plot of the estimated regression discontinuity. The object of class RD is a
list containing the following components:
Author(s)
References
Lee, David and Thomas Lemieux. (2010) "Regression Discontinuity Designs in Economics," Jour-
nal of Economic Literature. 48(2): 281-355. http://www.aeaweb.org/articles.php?doi=10.
1257/jel.48.2.281
Imbens, Guido and Thomas Lemieux. (2010) "Regression discontinuity designs: A guide to prac-
tice," Journal of Econometrics. 142(2): 615-635. http://dx.doi.org/10.1016/j.jeconom.
2007.05.001
Lee, David and David Card. (2010) "Regression discontinuity inference with specification error,"
Journal of Econometrics. 142(2): 655-674. http://dx.doi.org/10.1016/j.jeconom.2007.05.
003
Angrist, Joshua and Jorn-Steffen Pischke. (2009) Mostly Harmless Econometrics. Princeton:
Princeton University Press.
See Also
Examples
x<-runif(1000,-1,1)
cov<-rnorm(1000)
y<-3+2*x+3*cov+10*(x>=0)+rnorm(1000)
RDestimate(y~x)
# Efficiency gains can be made by including covariates
RDestimate(y~x|cov)
10 summary.RD
Description
summary method for class "RD"
Usage
## S3 method for class 'RD'
summary(object, digits = max(3, getOption("digits") - 3), ...)
Arguments
object an object of class "RD", usually a result of a call to RDestimate
digits number of digits to display
... unused
Value
summary.RD returns an object of class "summary.RD" which has the following components:
Author(s)
Drew Dimmery <<[email protected]>>
Index
class, 8, 10
DCdensity, 2, 2, 9
IKbandwidth, 2, 4, 7, 9
ivreg, 9
kernelwts, 2, 5, 9
lm, 9
plot.RD, 2, 6, 9
print.RD, 7
rdd (rdd-package), 2
rdd-package, 2
RDestimate, 2, 6, 7, 7, 10
summary.RD, 2, 9, 10
vcovHC, 8, 9
11