sinanpl / OaxacaBlinder

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

Handle baseline invariance for interactions #12

Open davidskalinder opened 5 months ago

davidskalinder commented 5 months ago

I confess I'm not entirely sure I'm getting this right, but from my reading of extract_betas_EX() it looks like the function will correctly do the baseline invariance adjustment for categorical variables but not for any interactions? Since first of all the loop runs over factor_variables = names(attr(modmat, "contrasts")), and second of all there's no mechanism set up to add the adjustment to the main effect instead of the intercept (as Jann (2008:463) notes)?

I realize that the current functionality might be intentional, since I think any mentions of the baseline invariance specify that it should work with factor variables but doesn't mention interactions. But it'd be nice to be able to handle the interactions correctly. (Or at a minimum specify in the docs that they can't be handled automatically right now.)

I thiink that at the moment this could be worked around for categorical-categorical interactions by simply setting up a new interacted variable manually? Though again I admit that's not entirely clear to me, and that any interactions involving continuous variables are even less clear.