WeightIt
WeightIt copied to clipboard
Discrepancy between weighit() and glm()
Hi Noah,
Love your R packages, and thankful for all the work you've put into making them usable and well documented.
I have what I hope is a simple question. Apologies that I cannot produce the example explicitly here as the data is restricted. I am trying to run weightit()
as follows:
weightit(treatment ~ covariates, method = 'ps', link = 'logit', estimand = 'ATE', data = my_data)
I get the following error message: glm.fit: algorithm did not converge, glm.fit: fitted probabilities 0 or 1 occured
I expected this was due to sparsity in some covariates within one or both levels of the treatment, but on inspection of the raw data this does not seem to be the case, and when I run:
lr_mod <- glm(treatment ~ covariates, family = 'binomial, data = my_data)
and generate the propensity scores by hand: predict(lr_mod, type = 'response')
I get no convergence warnings, and a reasonable looking distribution of propensity scores. I can easily take these values and do the PS weighting myself by hand, but I am curious if you have any idea what is causing the discrepancy between weightit
and glm
Any thoughts much appreciated!