ngreifer / WeightIt

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

Extract last reltol value from WeightIt run #32

Closed cromer043 closed 1 year ago

cromer043 commented 2 years ago

Using entropy balancing, method = ebal, when sample sizes are relatively small, entropy balancing will fail. In order to handle this, the convergence tolerance level in optim()needs to be raised up from sqrt(.Machine$double.eps). The reltol can be adjusted but it’s unclear what it can/should be adjusted to. The process should grab the last reltol value from optim(), then make it available to pass it to WeightIt() to get weights at a higher tolerance level. In Stata, the ebalance package returns the tolerance level after each run. See example below. Is it possible to similarly include the last reltol in W1$obj?

Attachment-1

ngreifer commented 2 years ago

Hello,

My understanding is that optim() does not provide this, so wieghtit() cannot either if this is so. It looks like you can do this with the ebal package, which was also written by Hainmueller. You can use cobalt::get.w() to extract the weights from the ebalance() function and WeightIt::as_weightit() to get back to a weightit object if you want.

For fine control over how much imbalance is allowed, check out my optweight package, which performs an optimization similar to entropy balancing.