ngreifer / WeightIt

WeightIt: an R package for propensity score weighting
https://ngreifer.github.io/WeightIt/
102 stars 12 forks source link

sbps error #17

Closed andrewjmc closed 3 years ago

andrewjmc commented 3 years ago

Apologies for brevity... love weightit (consider this fanmail!)

I am testing sbps but getting an error. Probs done something stupid.

test_weights_two_arm_sbps <- weightit(formula = f_sbps,
                                   data=sd_subset_two_arm_sbps,
                                   method="cbps",
                                   estimand="ATE"
)

test_weights_two_arm_sbps_by <- weightit(formula = f_sbps,
                                   data=sd_subset_two_arm_sbps,
                                   method="cbps",
                                   estimand="ATE",
                                   by="country"
)

(country is a factor and each country has every treatment level)

test_weights_two_arm_sbps_combined <- sbps(test_weights_two_arm_sbps, test_weights_two_arm_sbps_by)

error

Error in get_w(s, moderator.factor, w_o, w_s) : 
  argument "moderator.factor" is missing, with no default

I do indeed see in the code that get_w is called without passing moderator.factor.

Is this a bug, or have I missed something?

Thanks so much!

Andrew

ngreifer commented 3 years ago

Hi Andrew,

Thank you so much for letting me know about this. I was able to reproduce and fix the error. The development version of WeightIt should have the fix included. In the meantime, if you set full.search = TRUE, the error will be avoided on the old version (but it might take a long time to run).

Noah

andrewjmc commented 3 years ago

Thank you so much for fixing so quickly! Will test today.

Best wishes,

Andrew