sinanpl / OaxacaBlinder

R implementation of Oaxaca-Blinder gap decomposition
MIT License
1 stars 1 forks source link

Add sum check to main function #25

Closed davidskalinder closed 4 months ago

davidskalinder commented 4 months ago

This PR adds a block to the main function to check that the varlevel estimates sum to the gap, and to throw an error requesting a bug report if not.

@sinanpl I know that is a bit of an extreme reaction to the error, but I think it's kind of an extreme error. After all, the whole point of a decomposition is to break the gap into pieces, so if the pieces don't add up to the gap then something has gone seriously wrong and any function output shouldn't be trusted. This way the user (and hopefully we!) will hear about it any time this happens.

At the moment it's not implemented for bootstraps, but I think that wouldn't be a bad idea eventually? But if so then that should probably get a separate issue...