DCdensity implements the McCrary (2008) sorting
test.DCdensity(runvar, cutpoint, bin = NULL, bw = NULL,
verbose = FALSE, plot = TRUE, ext.out = FALSE)2*sd(runvar)*length(runvar)^(-.5))FALSE)TRUE). The user may wrap this function in
additional graphical options to modify the plot.FALSE (the default)
DCdensity will return only the p-value of the
test. When TRUE, DCdensity will return the
additional informaext.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:thetacellmp (the midpoints of
each cell) and cellval (the normalized height of
each cell)#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)Run the code above in your browser using DataLab