designmatch package output in 1:2 matching

Viewed 104

I am trying to use designmatch package for cardinality matching of a treated group (n=88) to two untreated contols. The output returns 88x3=264 group_id and 88 t_id, but only 88 c_id (instead of 88x2=176). I understand designmatch does not use replacement by default so I don't understand why I only get 88 c_id.

out <- bmatch(t_ind = t_ind,  near_exact =  near_exact, n_controls=2)

out

$obj_total
[1] -88

$obj_dist_mat
NULL

$t_id
 [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
[44] 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
[87] 87 88

$c_id
 [1] 108 308 279 131 220 147 231 437 194 278 153 445 383 290 482 105 241 335 238 202 289 301 323 312 159 262 176 315 443 200 377 393
[33] 885 581 927 398 217 117 240 448 263 554 525 854 169 352 317 119 386 414 518 477 424 469 280 286 297 513 316  97 936 609 387 455
[65] 168 702 284 432 349 379 446 543 552 293 851 185 713 501 232 641 997 561 499 310 485 466 675 647

$group_id
  [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
 [44] 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
 [87] 87 88  1  1  2  2  3  3  4  4  5  5  6  6  7  7  8  8  9  9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21
[130] 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42
[173] 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52 52 53 53 54 54 55 55 56 56 57 57 58 58 59 59 60 60 61 61 62 62 63 63 64
[216] 64 65 65 66 66 67 67 68 68 69 69 70 70 71 71 72 72 73 73 74 74 75 75 76 76 77 77 78 78 79 79 80 80 81 81 82 82 83 83 84 84 85 85
[259] 86 86 87 87 88 88

Thanks for any help

1 Answers

Answer

The function does not seem to work properly, thus this is likely not possible. The package also does not seem to be actively maintained. My recommendation is moving on to a different package, like MatchIt.

Details

I had an extensive look at the source code of the package. I made several observations.

  1. The group_id element in the output does not seem based on anything.

In the output, you indeed see group_id that seems to have the correct dimensions. However, the numbers don't seem to represent anything meaningful:

group_id_t = 1:(length(t_id))
group_id_c = sort(rep(1:(length(t_id)), n_controls))
group_id = c(group_id_t, group_id_c)

As you can see, they just create a vector group_id_t that runs from 1 to length(t_id) (the IDs of the treated group, see t_id in your output). Next, they create a vector group_id_c that is the exact same thing, just repeated n_controls times. The final group_id is just the concatenated version of that.

I looked around for a matrix where you could enter this, or a matrix that has the number of rows/columns that matches the length of group_id. I cannot find one. The numbers in group_id seem to have no value.

  1. The optimizer seems to optimize for n_controls or less

The bmatch function has several steps. First, it calculates some initial parameters. Second, it puts those parameters in an optimizer (in the default case: glpk using Rglpk::Rglpk_solve_LP). Third, it does some calculations to create the output.

When you vary n_controls (1, 2, 10, etc.), it changes only 1 parameter of the initial parameters (bvec). This parameter essentially carries information on how many matches should be found, and are then entered as a constraint into the optimizer. However, I'm getting the impression that something is wrong with bvec. It gets entered with the condition <=, meaning that the optimizer only has to find a solution where you get n_controls or fewer. I tried looking deeper into how the initial parameters are determined, but that's several hundreds of lines of code, so I gave up.

Final thoughts

The package was last updated on 2018-06-18, which suggests to me that the authors haven't looked at it for a while. You can/should contact them and see what they say. Alternatively, there are other packages like MatchIt that have been verified extensively. You can also switch to one of those packages instead.

Related