# Blinder-Oaxaca decomposition, logistic regression and unbalanced dataset: fitted probabilities numerically 0 or 1 occurred

I have a binary y outcome, a dummy variable gender for gender, and a set of covariates x (including some factor variables converted into dummies, excluding one dummy in each of the factor variables) and a set of control dummies cdummies (they come from one single factor variable, I have excluded one dummy) for which I want the oaxaca package to apply the Gardeazabal and Ugidos (2004) correction.

I am estimating a logistic regression of Y on gender and the covariates x and cdummies.

Then, using the R oaxaca package, I am decomposing the difference in the outcome among the two genders.

Given: f = y ~ x + cdummies | gender | cdummies

The function I am calling is:

results <- oaxaca(f,
data = df,
R = 1000,
reg.fun = glm,


The problem is that, after the calculations have finished, it gives me a lot of warnings of the type:

glm.fit: fitted probabilities numerically 0 or 1 occurred


I think this is due to my dataset being unbalanced: only 0.5% of the observations get the outcome.

This, I think, causes the algorithm, during bootstrapping of the standard error, to randomly pick only observations for which the outcome never happens.

How can I fix this problem?

One solution could be oversampling, but in this case the difference in the probability of the outcome occurring would turn out to be 0.

Another solution would be stratified sampling for the bootstrapped sample, but I would have to modify the package.

How can I fix this?

Or can I just ignore the warnings?

EDIT: I am able to fit the two regressions separately for the two genders without errors:

fit_males <- glm(ftest,
data=df[df$d_gender_female==0,], family=binomial) fit_females <- glm(ftest, data=df[df$d_gender_female==1,],
family=binomial)


However ftest is a bit different than f.

In fact ftest = y ~ gender + x + cdummies

While f = y ~ x + cdummies | gender | cdummies

> table(df$$y, df$$gender)

• Provide a frequency table of $y \times$ gender. Commented Sep 7, 2021 at 11:43