简体   繁体   English

designmatch package output 1:2 匹配

[英]designmatch package output in 1:2 matching

I am trying to use designmatch package for cardinality matching of a treated group (n=88) to two untreated contols.我正在尝试使用 designmatch package 将处理组(n = 88)与两个未处理的控制进行基数匹配。 The output returns 88x3=264 group_id and 88 t_id, but only 88 c_id (instead of 88x2=176). output 返回 88x3=264 group_id 和 88 t_id,但只有 88 c_id(而不是 88x2=176)。 I understand designmatch does not use replacement by default so I don't understand why I only get 88 c_id.我知道 designmatch 默认不使用替换,所以我不明白为什么我只得到 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谢谢你的帮助

Answer回答

The function does not seem to work properly, thus this is likely not possible. function 似乎无法正常工作,因此这可能是不可能的。 The package also does not seem to be actively maintained. package 似乎也没有得到积极维护。 My recommendation is moving on to a different package, like MatchIt .我的建议是转向不同的 package,例如MatchIt

Details细节

I had an extensive look at the source code of the package.我仔细查看了 package 的源代码。 I made several observations.我做了几个观察。

  1. The group_id element in the output does not seem based on anything. output 中的group_id元素似乎不基于任何东西。

In the output, you indeed see group_id that seems to have the correct dimensions.在 output 中,您确实看到group_id似乎具有正确的尺寸。 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).如您所见,他们只是创建了一个从 1 到length(t_id)的向量group_id_t (处理组的 ID,请参见输出中的t_id )。 Next, they create a vector group_id_c that is the exact same thing, just repeated n_controls times.接下来,他们创建了一个完全相同的向量group_id_c ,只是重复n_controls次。 The final group_id is just the concatenated version of that.最后的group_id只是它的串联版本。

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 .我四处寻找可以输入的矩阵,或者行/列数与group_id长度匹配的矩阵。 I cannot find one.我找不到一个。 The numbers in group_id seem to have no value. group_id中的数字似乎没有任何价值。

  1. The optimizer seems to optimize for n_controls or less优化器似乎针对n_controls或更少进行优化

The bmatch function has several steps. bmatch function 有几个步骤。 First, it calculates some initial parameters.首先,它计算一些初始参数。 Second, it puts those parameters in an optimizer (in the default case: glpk using Rglpk::Rglpk_solve_LP ).其次,它将这些参数放入优化器中(在默认情况下: glpk使用Rglpk::Rglpk_solve_LP )。 Third, it does some calculations to create the output.第三,它做了一些计算来创建 output。

When you vary n_controls (1, 2, 10, etc.), it changes only 1 parameter of the initial parameters ( bvec ).当您改变n_controls (1、2、10 等)时,它仅更改初始参数 ( bvec ) 的 1 个参数。 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 .但是,我的印象是bvec有问题。 It gets entered with the condition <= , meaning that the optimizer only has to find a solution where you get n_controls or fewer .它以条件<=输入,这意味着优化器只需要找到一个解决方案,您可以得到n_controls或更少 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. package 最后更新于 2018 年 6 月 18 日,这表明作者已经有一段时间没有看它了。 You can/should contact them and see what they say.你可以/应该联系他们,看看他们怎么说。 Alternatively, there are other packages like MatchIt that have been verified extensively.或者,还有其他包,如MatchIt已经过广泛验证。 You can also switch to one of those packages instead.您也可以改用其中一个包。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM