1
$\begingroup$

I am using the MatchIt package to perform matching between two groups (obese and not obese). The dataset that I am using has no missing data. I am matching on age, sex, and race. Sex and race are categorical variables with 'M' and 'F' factors in sex, and 'American Indian or Alaska Native', 'Asian', 'Black or African American', 'Native Hawaiian or Pacific Islander', and 'White' factors in the race variable. I have:

m.out <- matchit(OBESE ~ AGE + SEX + RACE, data=match_data, method="nearest", caliper=0.1, standardize=T, ratio=1

The output is:

Call: 
matchit(formula = OBESE ~ AGE + SEX + RACE, data = match_data, 
method = "nearest", caliper = 0.1, standardize = T, ratio = 1)

Sample sizes:
          Control Treated
All          1606     413
Matched       398     398
Unmatched    1208      15
Discarded       0       0

When I call summary(m.out) I get:

Call: 
matchit(formula = OBESE ~ AGE + SEX + RACE, data = match_data, 
method = "nearest", caliper = 0.1, standardize = T, ratio = 1)

Summary of balance for all data:
                                        Means Treated Means Control SD Control
distance                                       0.2877        0.1832     0.1134
AGE                                           57.1840       62.5959    13.6155
SEXF                                           0.5448        0.5019     0.5002
SEXM                                           0.4552        0.4981     0.5002
RACEAsian                                      0.0048        0.0081     0.0896
RACEBlack or African American                  0.1186        0.0679     0.2516
RACENative Hawaiian or Pacific Islander        0.0000        0.0006     0.0250
RACEWhite                                      0.8692        0.9128     0.2822

                                        Mean Diff eQQ Med eQQ Mean eQQ Max
distance                                   0.1045  0.1023   0.1043  0.2094
AGE                                       -5.4119  6.0000   5.3729  7.0000
SEXF                                       0.0429  0.0000   0.0436  1.0000
SEXM                                      -0.0429  0.0000   0.0436  1.0000
RACEAsian                                 -0.0033  0.0000   0.0048  1.0000
RACEBlack or African American              0.0508  0.0000   0.0508  1.0000
RACENative Hawaiian or Pacific Islander   -0.0006  0.0000   0.0024  1.0000
RACEWhite                                 -0.0436  0.0000   0.0436  1.0000

Summary of balance for matched data:
                                        Means Treated Means Control SD Control
distance                                       0.2725        0.2707     0.1369
AGE                                           57.6809       57.7688    13.9209
SEXF                                           0.5452        0.5377     0.4992
SEXM                                           0.4548        0.4623     0.4992
RACEAsian                                      0.0050        0.0050     0.0708
RACEBlack or African American                  0.1080        0.0829     0.2761
RACENative Hawaiian or Pacific Islander        0.0000        0.0000     0.0000
RACEWhite                                      0.8794        0.9070     0.2907

                                        Mean Diff eQQ Med eQQ Mean eQQ Max
distance                                   0.0019  0.0026   0.0034  0.0148
AGE                                       -0.0879  1.0000   0.6156  3.0000
SEXF                                       0.0075  0.0000   0.0075  1.0000
SEXM                                      -0.0075  0.0000   0.0075  1.0000
RACEAsian                                  0.0000  0.0000   0.0000  0.0000
RACEBlack or African American              0.0251  0.0000   0.0251  1.0000
RACENative Hawaiian or Pacific Islander    0.0000  0.0000   0.0000  0.0000
RACEWhite                                 -0.0276  0.0000   0.0276  1.0000

Percent Balance Improvement:
                                        Mean Diff. eQQ Med  eQQ Mean  eQQ Max
distance                                   98.1966 97.4478   96.7201  92.9410
AGE                                        98.3751 83.3333   88.5429  57.1429
SEXF                                       82.4404  0.0000   82.7052   0.0000
SEXM                                       82.4404  0.0000   82.7052   0.0000
RACEAsian                                 100.0000  0.0000  100.0000 100.0000
RACEBlack or African American              50.5144  0.0000   50.5863   0.0000
RACENative Hawaiian or Pacific Islander   100.0000  0.0000  100.0000 100.0000
RACEWhite                                  36.5769  0.0000   36.5857   0.0000

Sample sizes:
          Control Treated
All          1606     413
Matched       398     398
Unmatched    1208      15
Discarded       0       0

In the summary output, you'll notice that 'American Indian or Alaska Native' is missing. What happened to this factor?

Note that after calling obese_matched <- match.data(m.out), the Obese and Non-obese groups each have 3 and 2 rows in which the race is 'American Indian or Alaska Native', which suggests that the factor missing in the summary output is not because the MatchIt package dropped the factors altogether.

I appreciate help in clarifying this for me.

UPDATED WITH SAMPLE

Here is a small reproducible example. The 1 factor from race is not present in summary:

set.seed(42)
# 1 = American Indian or Alaska Native
# 2 = Asian
# 3 = Black or African American
# 4 = Native Hawaiian or Pacific Islander
# 5 = White
race <- as.factor(sample(1:5, size=2000, replace=TRUE, prob=c(1,1,10,0.5,87.5)))
summary(race)

set.seed(42)
# 1 = Female
# 2 = Male
sex <- as.factor(sample(1:2, size=2000, replace=TRUE, prob=c(55,45)))
summary(sex)

set.seed(42)
age <- rnorm(2000, 0.7, 0.156)
age[which(age>1)] <- 1
age <- round(age * 89)
summary(age)

set.seed(42)
# 0 = No
# 1 = Yes
obese <- as.factor(sample(0:1, size=2000, replace=TRUE, prob=c(75,25)))
summary(obese)

d <- data.frame(age, sex, race, obese)

library(MatchIt)

set.seed(42)
m.out <- matchit(obese ~ age + sex + race, data=d, method="nearest", caliper=0.2, standardize=T, ratio=1)
summary(m.out)

Call:
matchit(formula = obese ~ age + sex + race, data = d, method = "nearest", 
    caliper = 0.2, standardize = T, ratio = 1)

Summary of balance for all data:
         Means Treated Means Control SD Control Mean Diff eQQ Med eQQ Mean eQQ Max
distance        0.7053        0.0987     0.1706    0.6066  0.5758   0.6068  1.0000
age            61.9640       61.9333    13.6453    0.0307  0.8508   0.9525  5.7335
sex1            0.0000        0.7483     0.4341   -0.7483  1.0000   0.7470  1.0000
sex2            1.0000        0.2517     0.4341    0.7483  1.0000   0.7490  1.0000
race2           0.0378        0.0000     0.0000    0.0378  0.0000   0.0378  1.0000
race3           0.4223        0.0000     0.0000    0.4223  0.0000   0.4223  1.0000
race4           0.0239        0.0000     0.0000    0.0239  0.0000   0.0239  1.0000
race5           0.4861        1.0000     0.0000   -0.5139  1.0000   0.5139  1.0000


Summary of balance for matched data:
         Means Treated Means Control SD Control Mean Diff eQQ Med eQQ Mean eQQ Max
distance        0.3938        0.3914     0.0187    0.0024  0.0023   0.0026  0.0067
age            62.3772       64.0115    12.8128   -1.6343  1.5293   1.8236  4.7634
sex1            0.0000        0.0000     0.0000    0.0000  0.0000   0.0000  0.0000
sex2            1.0000        1.0000     0.0000    0.0000  0.0000   0.0000  0.0000
race2           0.0000        0.0000     0.0000    0.0000  0.0000   0.0000  0.0000
race3           0.0000        0.0000     0.0000    0.0000  0.0000   0.0000  0.0000
race4           0.0000        0.0000     0.0000    0.0000  0.0000   0.0000  0.0000
race5           1.0000        1.0000     0.0000    0.0000  0.0000   0.0000  0.0000

Percent Balance Improvement:
         Mean Diff.  eQQ Med eQQ Mean  eQQ Max
distance    99.6101  99.6072  99.5643  99.3265
age      -5228.7855 -79.7469 -91.4556  16.9205
sex1       100.0000 100.0000 100.0000 100.0000
sex2       100.0000 100.0000 100.0000 100.0000
race2      100.0000   0.0000 100.0000 100.0000
race3      100.0000   0.0000 100.0000 100.0000
race4      100.0000   0.0000 100.0000 100.0000
race5      100.0000 100.0000 100.0000 100.0000

Sample sizes:
          Control Treated
All          1498     502
Matched       244     244
Unmatched    1254     258
Discarded       0       0
$\endgroup$
1
  • $\begingroup$ Is it possible to provide us with an reproducible example that we can run on our own machines? For instance by generating nonsense-data that is similar to your data and that gives the same situation. $\endgroup$
    – Phil
    Commented Oct 19, 2018 at 12:16

1 Answer 1

1
$\begingroup$

This is a bug/inconsistency in the MatchIt programming that occurs when you have two or more factor variables for which you are assessing balance. For the first factor variable, all levels will be displayed. For all other factor variables, all but the first level will be displayed.

It's possible to compute the mean difference for the missing factor level: it's 0 minus the sum of the mean differences of the other levels.

To solve this problem, and many others, I wrote the cobalt package which is directly compatible with MatchIt and many other pre-processing packages. To get similar output, just use bal.tab(m.out). All levels of multi-category factor levels will be displayed, and only one level of binary variables will be displayed.

$\endgroup$
2
  • $\begingroup$ This does solve the problem I was having with the missing factors. However I notice that the actual values I get after using cobalt are slightly different from summary(m.out) with MatchIt. I passed the standardize=TRUE parameter with MatchIt, does this have anything to do with the discrepancy? $\endgroup$
    – oort
    Commented Oct 23, 2018 at 17:40
  • $\begingroup$ Yes, the default in cobalt is for continuous variables to have the standardized mean difference and binary (and categorical) variables to have the raw difference in proportion. To produce identical results to summary(..., standardize = TRUE) in MatchIt, set binary = "std" in the call to bal.tab(). See ?bal.tab.matchit for more information on the arguments and their defaults. $\endgroup$
    – Noah
    Commented Oct 23, 2018 at 18:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.