ngreifer / WeightIt

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

Error in summary.weightit #19

Closed andrewjmc closed 3 years ago

andrewjmc commented 3 years ago
test_weights_two_arm <- weightit(formula = f,
                                   data=sd_subset_two_arm,
                                   method="cbps",
                                   estimand="ATE",
                                   missing="ind"
)
summary(test_weights_two_arm)
                 Summary of weights

- Weight ranges:

Error in rep(" ", spaces1) : invalid 'times' argument
In addition: Warning messages:
1: In min(w[w > 0 & t == 1]) :
  no non-missing arguments to min; returning Inf
2: In max(w[w > 0 & t == 1]) :
  no non-missing arguments to max; returning -Inf
3: In min(w[w > 0 & t == 0]) :
  no non-missing arguments to min; returning Inf
4: In max(w[w > 0 & t == 0]) :
  no non-missing arguments to max; returning -Inf

Weights are reasonable (1-6.8)

The error comes deep into the print.summary function, and I cannot play with trace(..., edit=TRUE) to work out why it's going wrong!

andrewjmc commented 3 years ago

Solved -- exposure category was character not factor (interestingly doesn't cause an issue for multinomial treatments).