3
$\begingroup$

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,
                  family = binomial(link="logit"))

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

EDIT2: Frequency table asked in the comments:

> table(df$y, df$gender)

         0      1
  0 194276  88007
  1    995    237
$\endgroup$
11
  • $\begingroup$ Are you able to fit the two logistic models for males and females separately without this issue arising? $\endgroup$
    – awhug
    Commented Sep 7, 2021 at 9:30
  • $\begingroup$ @awhug that's a very very good question, I will try shortly. Thank you very much $\endgroup$ Commented Sep 7, 2021 at 10:00
  • $\begingroup$ @awhug Yes I am. I have edited the question $\endgroup$ Commented Sep 7, 2021 at 10:12
  • $\begingroup$ I have further edited the question to fix typos and explain what formulas I am using exactly $\endgroup$ Commented Sep 7, 2021 at 10:19
  • 1
    $\begingroup$ Provide a frequency table of $y \times$ gender. $\endgroup$ Commented Sep 7, 2021 at 11:43

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.