Announcement

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

  • CEM command: why the resutls are different for such code?

    I want to use Coarsened Exact, however, I didn't understand why the weights calculated are different for the code below:
    Could please anyone help me out? Which one is correct?
    Code:
    sysuse auto,clear
    cem weight price turn rep78(1 2 3 4 5) length,treat(foreign)
    su cem_weights
    cem weight price turn rep78(1 (1) 5) length,treat(foreign)
    su cem_weights

  • #2
    We first learn that cem is a community-contributed command available from SSC (as the FAQ asks you to report when using a command that is not part of the Stata distribution).

    After installing it, the output of help cem tells us that the contents of the optional parentheses forllowing a variable name is to be a numlist. The following experimentation shows that the first and second have identical results. Inspection of cem.ado suggests that the code it uses to parse its arguments does not expect parentheses within the numlist, even though that is one type of numlist. As a consequence, the third and fourth give a different, identical result. The fifth gives the same result as the first two, which suggests that those three are the correct results, and also there was no need to specify cutpoints for rep78 in this example.
    Code:
    sysuse auto,clear
    quietly cem weight price turn rep78(1 2 3 4 5) length,treat(foreign)
    su cem_weights
    quietly cem weight price turn rep78(1/5) length,treat(foreign)
    su cem_weights
    quietly cem weight price turn rep78(1(1)5) length,treat(foreign)
    su cem_weights
    quietly cem weight price turn rep78(1) length,treat(foreign)
    su cem_weights
    quietly cem weight price turn rep78 length,treat(foreign)
    su cem_weights
    Code:
    . * ssc install cem
    . sysuse auto,clear
    (1978 automobile data)
    
    . quietly cem weight price turn rep78(1 2 3 4 5) length,treat(foreign)
    
    . su cem_weights
    
        Variable |        Obs        Mean    Std. dev.       Min        Max
    -------------+---------------------------------------------------------
     cem_weights |         74    .1081081    .3439324          0          2
    
    . quietly cem weight price turn rep78(1/5) length,treat(foreign)
    
    . su cem_weights
    
        Variable |        Obs        Mean    Std. dev.       Min        Max
    -------------+---------------------------------------------------------
     cem_weights |         74    .1081081    .3439324          0          2
    
    . quietly cem weight price turn rep78(1(1)5) length,treat(foreign)
    
    . su cem_weights
    
        Variable |        Obs        Mean    Std. dev.       Min        Max
    -------------+---------------------------------------------------------
     cem_weights |         74    .1081081    .3126365          0          1
    
    . quietly cem weight price turn rep78(1) length,treat(foreign)
    
    . su cem_weights
    
        Variable |        Obs        Mean    Std. dev.       Min        Max
    -------------+---------------------------------------------------------
     cem_weights |         74    .1081081    .3126365          0          1
    
    . quietly cem weight price turn rep78 length,treat(foreign)
    
    . su cem_weights
    
        Variable |        Obs        Mean    Std. dev.       Min        Max
    -------------+---------------------------------------------------------
     cem_weights |         74    .1081081    .3439324          0          2
    
    .

    Comment


    • #3
      Thanks William for the help! Now I know the third way is wrong.

      Comment

      Working...
      X