Announcement

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

  • Problems using cem

    Hello,

    I am having problems using coarsened exact matching (CEM) on Stata.

    when running the command(from the code in "causal inference: the mixtape"):

    Code:
    ssc install cem
    
    * Reload experimental group data
    use https://github.com/scunning1975/mixtape/raw/master/nsw_mixtape.dta, clear
    drop if treat==0
    
    * Now merge in the CPS controls from footnote 2 of Table 2 (Dehejia and Wahba 2002)
    append using https://github.com/scunning1975/mixtape/raw/master/cps_mixtape.dta
    gen agesq=age*age
    gen agecube=age*age*age
    gen edusq=educ*edu
    gen u74 = 0 if re74!=.
    replace u74 = 1 if re74==0
    gen u75 = 0 if re75!=.
    replace u75 = 1 if re75==0
    gen interaction1 = educ*re74
    gen re74sq=re74^2
    gen re75sq=re75^2
    gen interaction2 = u74*hisp
    
    cem age (10 20 30 40 60) age agesq agecube educ edusq marr nodegree black hisp re74 re75 u74 u75 interaction1, treatment(treat) 
    reg re78 treat [iweight=cem_weights], robust



    I get back this error:

    Code:
    . 
    . cem age (10 20 30 40 60) age agesq agecube educ edusq marr nodegree black hisp re74 r
    > e75 u74 u75 interaction1, treatment(treat) 
    file /Users/fuzhanghaifan/Library/Application Support/Stata/ado/plus/c/cem-mata.do
        not found
    (error occurred while loading cem.ado)
    r(601);
    
    end of do-file
    
    r(601);



    and I have tried :

    ssc uninstall cem
    ssc install cem
    ssc install cem all

    they don't work.

    Any insights would be very helpful.

    Thank you!








  • #2
    Works fine for me in Stata 17. What version of Stata are you using?

    Your last install command is missing a comma -- it should be

    ssc install cem, all
    -------------------------------------------
    Richard Williams, Notre Dame Dept of Sociology
    StataNow Version: 19.5 MP (2 processor)

    EMAIL: [email protected]
    WWW: https://www3.nd.edu/~rwilliam

    Comment


    • #3
      A similar problem is reported in https://www.statalist.org/forums/for...lems-using-cem. The solution there seemed to be getting files in the right location.
      -------------------------------------------
      Richard Williams, Notre Dame Dept of Sociology
      StataNow Version: 19.5 MP (2 processor)

      EMAIL: [email protected]
      WWW: https://www3.nd.edu/~rwilliam

      Comment


      • #4
        If the problems with cem persist, try kmatch, which also provides a CEM algorithm.
        Code:
        ssc install kmatch, replace
        Best wishes

        (Stata 16.1 MP)

        Comment


        • #5
          Originally posted by Richard Williams View Post
          Works fine for me in Stata 17. What version of Stata are you using?

          Your last install command is missing a comma -- it should be

          ssc install cem, all
          Hi Richard,

          my Stata version is 16, and I tried "ssc install cem, all'

          got this error:
          .
          . cem age (10 20 30 40 60) age agesq agecube educ edusq marr nodegree black hisp re74 r
          > e75 u74 u75 interaction1, treatment(treat)
          file /Users/fuzhanghaifan/Library/Application Support/Stata/ado/plus/c/cem-mata.do
          not found
          (error occurred while loading cem.ado)
          r(601);

          end of do-file

          r(601);

          what code should I add to find the file?

          Thank you very much.

          Comment


          • #6
            Hi all,

            unfortunately, I receive the same error message in Stata 17 when using cem:

            file C:\Users\carlok\ado\plus/c/cem-mata.do not found
            (error occurred while loading cem.ado)
            r(601);


            That is quite unfortunate because I am unable to re-run replication code for my own analysis that worked well under Stata 15.

            Does anyone have any advice on how to fix it?

            Kind regards,
            Carlo

            Comment


            • #7
              I suggest contacting the programmers for advice. Maybe this can be fixed with a few lines of code to account for the new Stata version.

              To report bugs or give comments, please contact Matthew Blackwell
              <[email protected]>.
              Best wishes

              (Stata 16.1 MP)

              Comment


              • #8
                Thank you Felix. I will do that.

                Comment


                • #9
                  Here's the error and fix: With "ssc install cem" the "cem-mata.do" file gets copied into the currently active working directory of stata, but apparently not into the one where STATA will look for it. You need to copy the "cem-mata.do" file into that directory "...\ado\plus\c" manually (at least for now). Looking at the error message, it looks like a mix of R and STATA syntax regarding slash and backslash use ("/" vs ""). See the error message: "file C:\Users\<MYUSER>\ado\plus/c/cem-mata.do not found."

                  I will share that with Matthew Blackwell. I hope that's helpful for a quick fix for some of you.

                  Comment


                  • #10
                    I had the same issue and the solution is very simple though it took forever to figure out (thanks for Matthew Blackwell for the tip!). Type in these exact commands:


                    ssc uninstall cem
                    net from https://mattblackwell.org/files/stata
                    net install cem

                    You should be able to run code after this!

                    Comment


                    • #11
                      hi
                      Romi Kher i am having some trouble getting the results of CEM command in stata. when i run the cem command it gives me no result. please note that i have successfully installed cem. when i enter the command, it gives no error, not does it show any results. and whatever command i enter after cem is not giving results, stata just does not seem to respond to it,
                      looking forward to your assistance in this regarf
                      thanks

                      Comment


                      • #12
                        Hi everyone,
                        could anyone please tell me where does the algorithm of CEM and psmatch2 differ?
                        I have been working on a project using CEM and psmatch2, using the same variables, the result for psmatch2 appear to be significant whereas the results for cem are insignificant for the same variables? anyone here can let me know why is it so? or what is causing it?
                        thanks in advance

                        Comment

                        Working...
                        X