Hi Dennis, 

Sorry for the late reply. It turns out that this was a bug with the imb function that didn't affect the matching results at all. CEM should have just omitted the imbalance results since we don't have a straightforward way to calculate imbalance with more than 2 treatment groups. In the latest version of cem (1.3), this works appropriately. 

You can update using the folllowing commands:

ado uninstall cem
net from http://www.mattblackwell.org/files/stata
net install cem

(you may need to use ", force" at the end the last command)

Hope that helps!

Cheers,
Matt

On Fri, Jul 25, 2014 at 1:25 PM, Dennis Hanseman <hanseman@one.net> wrote:

Thanks, but I’m still encountering problems.

 

I ran this code:

            use "D:\Documents\Midura Paquette\6.16.14 NCDB - Rectal CA only.dta", clear

 

generate approach1 = 1

replace  approach1 = 2 if approach == "open"

replace  approach1 = 3 if approach == "laparoscopic"

 

generate margins1 = 1

replace  margins1 = 0 if margins == "negative"

 

drop if approach1 == .

summarize margins1 age approach1

logistic margins1 i.approach1

cem margins1 age, tr(approach1)

 

and got this output:

 

. do "C:\Users\Hanseman\AppData\Local\Temp\STD00000000.tmp"

 

. use "D:\Documents\Midura Paquette\6.16.14 NCDB - Rectal CA only.dta", clear

.

. generate approach1 = 1

. replace  approach1 = 2 if approach == "open"

(6352 real changes made)

 

. replace  approach1 = 3 if approach == "laparoscopic"

(2444 real changes made)

 

.

. generate margins1 = 1

. replace  margins1 = 0 if margins == "negative"

(8512 real changes made)

.

. drop if approach1 == .

(0 observations deleted)

 

. summarize margins1 age approach1

 

    Variable |         Obs        Mean    Std. Dev.          Min        Max

-------------+------------------------------------------------------------------------

     margins1 |      9253    .0800821     .271435           0          1            

              age |       9253    62.45888    13.09845         18         90

   approach1 |      9253    2.214741    .5171413          1          3

 

. logistic margins1 i.approach1

 

Logistic regression                                          Number of obs   =       9253

                                                                        LR chi2(2)      =      21.80

                                                                        Prob > chi2     =     0.0000

Log likelihood = -2570.4092                           Pseudo R2       =     0.0042

 

------------------------------------------------------------------------------

     margins1 |    Odds Ratio   Std. Err.      z    P>|z|     [95% Conf. Interval]

-------------+--------------------------------------------------------------------------------------------

   approach1 |

                  2  |   1.754614   .3760161     2.62   0.009     1.152837    2.670516

                  3  |   1.213282    .273746     0.86   0.392     .7796687     1.88805

                      |

           _cons |   .0554273   .0116234   -13.79   0.000      .036747    .0836035

------------------------------------------------------------------------------

 

. cem margins1 age, tr(approach1)

 

Matching Summary:

-----------------

Number of strata: 28

Number of matched strata: 24

 

                       1       2        3

              All   457  6352  2444

    Matched   457  6292  2427

Unmatched     0    60        17

 

             imbalance():  3258  <tmp>[1,1] found where void required

                 <istmt>:     -  function returned error

r(3258);

 

end of do-file

 

r(3258);

 

.

 

This is a mystery to me.  Do you have other ideas as to what might be going wrong.

 

Thanks for your help.

 

Dennis Hanseman

 

From: Matt Blackwell [mailto:mblackwell@gov.harvard.edu]
Sent: Friday, July 25, 2014 8:32 AM
To: Ariel Linden
Cc: Dennis Hanseman; cem@lists.gking.harvard.edu


Subject: Re: [cem] Error when using cem with >2 treatments

 

Hi Dennis, 

 

We need to implement an "if" syntax for the imbalance command, but it's still a work in progress. For now, you can simply subset the data to non-missing treatments:

 

drop if approach1 != . 

 

That should solve the error. 

 

Cheers,

Matt

 

~~~~~~~~~~~

Matthew Blackwell

Assistant Professor of Government

Harvard University

 

On Thu, Jul 24, 2014 at 9:09 PM, Ariel Linden <ariel.linden@gmail.com> wrote:

So the matching worked, just not –imbalance- … I’ll have to Let Matt Blackwell field this error.

 

From: Dennis Hanseman [mailto:hanseman@one.net]
Sent: Thursday, July 24, 2014 8:51 PM
To: 'Ariel Linden'; cem@lists.gking.harvard.edu
Subject: RE: [cem] Error when using cem with >2 treatments

 

Tried that, but got the error message again:

 

 

. cem margins1 age if approach1 != . , tr(approach1)

 

Matching Summary:

-----------------

Number of strata: 28

Number of matched strata: 24

 

              1     2     3

      All   457  6352  2444

  Matched   457  6292  2427

Unmatched     0    60    17

 

            imbalance():  3258  <tmp>[1,1] found where void required

                 <istmt>:     -  function returned error

r(3258);

 

Dennis

 

From: Ariel Linden [mailto:ariel.linden@gmail.com]
Sent: Thursday, July 24, 2014 8:09 PM
To: Dennis Hanseman; cem@lists.gking.harvard.edu
Subject: Re: [cem] Error when using cem with >2 treatments

 

Your "if" statement needs to come before the comma

 

Ariel

 

 

From: Dennis Hanseman

Sent: Thursday, July 24, 2014 8:01 PM

Subject: [cem] Error when using cem with >2 treatments

 

I’m trying to use cem to do matching involving 3 treatments.  Prof. King (http://comments.gmane.org/gmane.comp.lang.r.matchit/393) indicated that this can be done.

 

When I tried it, I got an error message –

 

             imbalance():  3258  <tmp>[1,1] found where void required

                 <istmt>:     -  function returned error

 

There was a discussion on this site on July 24 of 2013 about a similar issue.  In that case, there were only 2 treatments but a treatment of “.”, along with “1” and “2”, showed up in the summary table.  The suggestion was to add “if indepvote != ." to the cem call.”
 
While I’m sure that there are no missing values of my treatment variable, I still tried to add the if clause to my cem call.  But it didn’t help.  I got another error:
 

. cem margins1 age, tr(approach1) if approach1 != .

option if not allowed

r(198);

 

Any ideas of how I can proceed?

 

Thanks.

 

Dennis Hanseman

 

 


-
--
cem Mailing List, served by HUIT
Send messages: cem@lists.gking.harvard.edu
[un]subscribe Options: http://lists.gking.harvard.edu/?info=cem
More information on cem: http://gking.harvard.edu/cem
Cem mailing list
Cem@lists.gking.harvard.edu

To unsubscribe from this list or get other information:

https://lists.gking.harvard.edu/mailman/listinfo/cem