WeightIt icon indicating copy to clipboard operation
WeightIt copied to clipboard

Multinomial ebal NA weights - can't investigate

Open andrewjmc opened this issue 3 years ago • 3 comments

Hello again!

+                                    data=sd_subset_three_arm,
+                                    method="ebal",
+                                    estimand="ATE"
+ )

Error in if (any(sapply(unique(treat), function(x) sd(test.w[treat == : missing value where TRUE/FALSE needed In addition: Warning message: Some weights were estimated as NA, which means a value was impossible to compute (e.g., Inf). Check for extreme values of the treatment or covariates and try removing them. Non-finite weights will be set to 0.

Looking at the code, the SD function has the argument na.rm=TRUE, so I can only assume this error arises because all weights for one or more treatment groups (three) are NA.

Does this indicate an obvious problem with my data? CBPS works fine on the same.

Because the function errors, I can't investigate which weights are missing - my skills don't extend to setting breakpoints in packages!

Thanks so much for any thoughts,

Andrew

andrewjmc avatar Feb 27 '21 10:02 andrewjmc

Thanks to trace(weightit, edit=TRUE) I added some debug output and found that my smallest group (n=94 / 527) has test.w of 0, so 0 / 0 doesn't work

When using CBPS, this group is the one which has a few variables with KS distance ~0.15, but balances well for absolute mean deviations.

Is there likely a reason in my data that it's suitable for CBPS but not ebal? Or could this be a bug? Or have I missed an obvious trick in the weightit call. I always suspect it's most likely to be my own problem.

andrewjmc avatar Feb 27 '21 11:02 andrewjmc

Hey, sorry about this issue. I made some changes to how that warning is processed so it should be more informative and not error out. An updated version is available here on GitHub. Thanks for letting me know about this.

I'm not sure why entropy balancing would give you weights of zero for just one group. It might be that the method could not converge because no solution was possible when requiring exact balance. CBPS doesn't require exact balance, so a solution with good enough balance can be produced even when entropy balancing would fail.

To assess which constraint is causing the issue, you can try using optweight() in the optweight package (which has similar syntax to weightit()). Like entropy balancing, it requires exact balance but it produces more informative messages when something goes wrong. You can look at a component of the output called the "dual variables" to see which constraint is likely causing the problem. But if you're getting adequate results with CBPS, I would just move forward with that. You might also try method = "energy" which tends to do pretty well, too.

ngreifer avatar Feb 28 '21 10:02 ngreifer

Thanks!

andrewjmc avatar Feb 28 '21 10:02 andrewjmc