ngreifer / WeightIt

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

Error in `weightit2glm.cont` when providing propensity scores #53

Open taylordunn opened 10 months ago

taylordunn commented 10 months ago

Hello, thanks for the great package. I've run into an error when calculating weights for continuous treatment and provided propensity scores (ps)

data("lalonde", package = "cobalt")
W.out.c <- WeightIt::weightit(re75 ~ age + educ + race + married +
                                nodegree + re74, 
                              data = lalonde,
                              ps = rep(1, 614),
                              method = "energy")
# Error in weightit2glm.cont(covs = covs, treat = treat, s.weights = s.weights,  : 
#  object 'gp.score' not found

Looks like this code block needs an else statement to set gp.score <- ps

ngreifer commented 10 months ago

Thanks for the report! This will be fixed in the next version.