Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem running McCrary-Test in Stata

    Dear all,
    working on a paper including a regression discontinuity design (RDD), I’m currently trying to implement the McCrary-Test in Stata (McCrary 2008: http://eml.berkeley.edu/~jmccrary/mc..._DCdensity.pdf), which tests if there systematic sorting below/above the discontinuity threshold of the running variable. Therefore, I use the user-written Stata command “dcdensity” available on Prof. McCrary’s web-site (http://eml.berkeley.edu/~jmccrary/DCdensity/). Unfortunately, I have a problem to run the provided ado-file.
    Here is how I proceeded:
    First, I saved the ado-file with the test from McCrary’s web-site in my personal ado-directory “ c:\ado\personal\”dcdensity.ado”.
    Then, I tried to test the program, using the provided example do-file. Stata returned the error message:
    “<istmt>: 3499 DCdensitysub() not found”
    I tried to run the ado-file as a do-file. This time, Stata returned the error message:
    “ variable loopover undeclared
    (0 lines skipped) “

    To me, it seems that there is something wrong with the code. Maybe, it’s because I’m using Stata version12, while the command was written in version 9?
    I’d be very happy if anyone had an idea how to fix this?!
    Many greetings,
    Johanna

  • #2
    The ado code ran fine for me with the do file from the source you cite. I cut the line

    Code:
     
    set mem 2G
    which is quite unnecessary for the example.

    I see no reason why using Stata 12 would be a problem.

    You should open up your copy of the ado with e.g

    Code:
     
    viewsource dcdensity.ado
    to check that it is complete.

    My guess is that you copied and pasted the Stata program between the lines program ... and end and omitted the Mata function which is essential for the program to run. Right or not, Stata's complaint is that it can't see the Mata function called in the main program, but the code is all there on the website.

    Comment


    • #3
      Dear Nick,

      thanks a lot for the answer. That's strange. I copied+pasted+saved the ado-file several times. It never worked out. And I'm sure that I didn't omit anything. The same happened to a colleague of mine. So, I don't know anymore.

      Thanks anyways!

      Many greetings,

      Johanna

      Comment


      • #4
        Here is the ado file from my computer. I've never had a problem running it, so if you do, it's a problem on your end...
        Attached Files

        Comment


        • #5
          Hi Johanna,

          We have the same exact problem, and the fixes suggested here didn't work for us either - did you ever fix it on your end? Inquiring minds want to know.

          MD

          Comment


          • #6
            In case anyone else encounters this issue...before, after saving the .ado file to the correct location, I was double clicking on the .do file I use for my project (which also pulls up Stata) to run the code for DCdensity. I haven't found this issue with other programs, but I found it necessary to open Stata 12 first, then open the .do file within Stata, and then run your DCdensity code. Now it works perfectly.

            Comment


            • #7
              I have the same problem and I have attempted all the suggestions above to no avail. Any further help with be appreciated

              Comment


              • #8
                Same here ... has anyone managed to solve the issue with alternative solutions?

                Comment


                • #9
                  I am using STATA 13 and trying to run rdcv and getting a similar error: <istmt>: 3499 mm_kern() not found.

                  Comment


                  • #10
                    Hi, Johanna et al.

                    I don't know if this thread is still relevant for people, but I just started using dcdensity and ran into this problem myself, and I think I've figured out a solution. Here's what I did (line references have include the full "Notes" preamble):

                    1) Change line 36 to "version 14.0" (this might be unnecessary, but it seems to work; I'm running STATA 14 at work, change as needed for earlier versions)
                    2) Change line 109 to "graph save" rather than "graph export"
                    3) Insert a new line of text at line 150 reading "real scalar loopover".

                    I've uploaded a copy of this modified code. I'm also running this as a do-file inside other do files rather than moving it to my ado folder - easier for me to do things this way given work rules, but mileage may vary.

                    Hopefully this helps!
                    Attached Files

                    Comment


                    • #11
                      Thanks Ariel Linden, it finally worked!

                      In order to avoid errors using "Select All" I saved an exact copy of the code as in http://eml.berkeley.edu/~jmccrary/DCdensity/ and always get the error "program error: code follows on the same line as open brace" I tried also to run the DCdensity_example.do stored on the website with the same result which was even more weird, anyways, I decided give a try to the file uploaded by Ariel Linden and this one worked out immediately.

                      Based on the issue with the original file and the comment of Dan Leeds it might be a compatibility issue.

                      (Stata 13).

                      Comment


                      • #12
                        Hello, I'm trying to run DCdensity after installing the same .ado, but it gives me an error too: "<istmt>: 3499 DCdensitysub() not found". It could be that the .ado is too old for my Stata 17.0? Thank you!!

                        Comment


                        • #13
                          Dear everyone,

                          this post is for those who stumble upon the same issue and are as inexperienced with ado-files as I am.

                          The file has to be put into "ado -> base -> d". It will not be found if you just insert it into "ado".

                          Best wishes,
                          Björn.

                          Comment

                          Working...
                          X