sinanpl / OaxacaBlinder

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

Error in modify_group_var_to_dummy(input_data, formula) : Grouping variable should have 2 unique values #54

Closed dverdin72 closed 1 month ago

dverdin72 commented 1 month ago

I'm running into this error message when I run your code

OaxacaBlinder::twofold` <- OaxacaBlinderDecomp( formula = real_wage ~ age + education | female, data = chicago_long, type = "twofold", baseline_invariant = TRUE, n_bootstraps = 100)

can you help me move past this issue?

sinanpl commented 1 month ago

hi @dverdin72 I am not able to reproduce this error and therefore closing. Please check the example below, and reopen the issue with a reproducible example (reprex) if experiencing issues.

library(OaxacaBlinder)
x <- OaxacaBlinderDecomp(
  formula = real_wage ~ age + education | female,
  data = chicago_long,
  type = "twofold",
  baseline_invariant = TRUE,
  n_bootstraps = 100
)
summary(x)
#> Oaxaca Blinder Decomposition model
#> ----------------------------------
#> Type: twofold
#> Formula: real_wage ~ age + education | female
#> Data: chicago_long
#> 
#> Descriptives
#>             n    %n mean(real_wage)
#> female==0 412 57.9%           17.52
#> female==1 300 42.1%           13.69
#> 
#> Gap: 3.83
#> % Diff: 21.88%
#>               coefficient   % of gap        se      2.5%     97.5%
#> explained           -0.53     -13.9% 0.3818509 -1.093071 0.2668554
#> unexplained          4.37     113.9% 0.6411761  3.179346 5.5927270
#> unexplained_a        1.89      49.2% 0.2865029  1.355759 2.4172551
#> unexplained_b        2.48      64.6% 0.3787487  1.794146 3.1781623