# Re: st: Mc Crary Test

 From "Austin Nichols" To statalist@hsphsun2.harvard.edu Subject Re: st: Mc Crary Test Date Fri, 24 Aug 2007 22:29:24 -0400

```Decio Coviello--
Justin McCrary's test for a discontinuity in the density of Z (at some
point Z0 where there is a "known" discontinuity in X, the RHS variable
of interest) is described very well in the working paper by McCrary
that Arun refers to, and in a working paper by Imbens and Lemieux
(http://nber.org/papers/w13039), and is mentioned briefly in
http://www.stata.com/meeting/6nasug/causal.pdf (slide 66 of 85 in the
pdf). Note in particular that as McCrary points out, the bandwidth
choice is somewhat tricky.  Without regard to bandwidth choice, you
could use code similar to this simple example (modifying to suit your
specific problem as necessary):

cap prog drop discont
prog discont, rclass
version 8.2
cap drop z f0 f1
g z=_n in 1/99
kdensity share if share<50, gen(f0) at(z) nogr tri w(2)
kdensity share if share>=50, gen(f1) at(z) nogr tri w(2)
return scalar d='=f1[50]-f0[50]'
end

clear
set obs 3000
g share=uniform()*100
g winvote=share>=50
bootstrap r(d), reps(50): discont

where failure to reject the null that the difference in density
estimates just to the left and just to the right of Z0 is good news
for your assumption of exchangability around the discontinuity.  You
will want to try out a few bandwidth choices in the width option of
-kdensity- (also -ssc inst kdens- for more options), and report the
results for each, and you will want many more than 50 reps in the
bootstrap.  Note also the grid for density estimates and the
discontinuity are hard-coded in the program above partly to ensure you
get estimates of f(Z) at Z0, approaching the discontinuity from both
sides.

On 8/23/07, Arun Rajamohan <arajamoh@uwo.ca> wrote:
>
> It is always a good idea to give the complete reference as all of us on
> statalist are not students or scholars in Economics. Many of us are
> biologists or epidemiologists or just statisticians and it does take a lot
> of time to find the references and read through the paper.
>
> http://www-personal.umich.edu/~jmccrary/mccrary2006_DCdensity.pdf
>
> On 23-Aug-07, at 3:59 AM, Coviello, Decio wrote:
>
> Hi I would like to know how to implement the Mc Crary (2007) test for the
> manipulation of the running variale in Regression Discontinuities Design.
>
> Thanks,
> Decio
>
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```