Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • decomposition for medians?

    I'm working with data that are skewed even when logged (total assets and debt), so the oaxaca decomposition results aren't working for me. I don't want to drop observations because I'm already dealing with some smaller sample sizes with subgroup analyses. I tried oaxaca_rif, which did give me median, but doesn't give me the results by variable or group of variable that I need. Looking for any and all recommendations for how to proceed. Ideally, I would like to have the endowments and coefficents for the full model, but also for individual variables and groups of variables that I specify, but taking into account the median values of the 2 groups rather than the mean.

  • #2
    oaxaca_rif gives me the overall, explained, and unexplained pieces. It's a two-way. Are you looking for the interactions?

    Comment


    • #3
      oaxaca gives endowments and coefficients, but also let's you get endowments and coefficients for individual or groups of variables, which I was hoping to replicate with oaxaca_rif. :/

      Comment


      • #4
        oaxaca_rif and oaxaca are from SSC (FAQ Advice #12).

        Originally posted by Zawadi Rucks-Ahidiana View Post
        oaxaca gives endowments and coefficients, but also let's you get endowments and coefficients for individual or groups of variables, which I was hoping to replicate with oaxaca_rif. :/
        Not sure exactly what you mean. The syntax of the two commands is similar, so I can get results for a group of variables by explicitly defining the group in the command line (see below).

        Code:
        use http://fmwww.bc.edu/RePEc/bocode/o/oaxaca.dta, clear
        *INDIVIDUAL VARIABLES
        oaxaca_rif lnwage educ exper tenure, by(female) wgt(1) rif(q(50))
        *GROUPING EXPERIENCE AND TENURE
        oaxaca_rif lnwage educ (job: exper tenure), by(female) wgt(1) rif(q(50))
        Res.:

        Code:
        . *INDIVIDUAL VARIABLES
        
        .
        . oaxaca_rif lnwage educ exper tenure, by(female) wgt(1) rif(q(50))
        No Reweighted Strategy Choosen
        Estimating Standard RIF-OAXACA using RIF:q(50)
        Model  : Blinder-Oaxaca RIF-decomposition
        Type   : Standard
        RIF    : q(50)
        Scale  : 1
        Group 1: female = 0 x1*b1                        N of obs 1      = 751
        Group c: x2*b1                                   N of obs C      =          .
        Group 2: female = 1 x2*b2                        N of obs 2      = 683
        
        ------------------------------------------------------------------------------
              lnwage | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
        -------------+----------------------------------------------------------------
        overall      |
             group_1 |   3.471406   .0162183   214.04   0.000     3.439619    3.503193
             group_2 |   3.334947   .0196443   169.77   0.000     3.296445    3.373449
          difference |   .1364586   .0254741     5.36   0.000     .0865302     .186387
           explained |   .0669252    .010453     6.40   0.000     .0464378    .0874126
         unexplained |   .0695334   .0240815     2.89   0.004     .0223345    .1167322
        -------------+----------------------------------------------------------------
        explained    |
                educ |    .032043   .0078299     4.09   0.000     .0166968    .0473893
               exper |   .0121175   .0045679     2.65   0.008     .0031647    .0210703
              tenure |   .0227647   .0062972     3.62   0.000     .0104225    .0351069
        -------------+----------------------------------------------------------------
        unexplained  |
                educ |  -.2260105   .1116666    -2.02   0.043     -.444873   -.0071481
               exper |  -.0240455   .0376449    -0.64   0.523    -.0978282    .0497372
              tenure |   .0068316    .025028     0.27   0.785    -.0422224    .0558857
               _cons |   .3127577   .1255673     2.49   0.013     .0666504     .558865
        ------------------------------------------------------------------------------
        
        .
        . *GROUPING EXPERIENCE AND TENURE
        
        .
        . oaxaca_rif lnwage educ (job: exper tenure), by(female) wgt(1) rif(q(50))
        No Reweighted Strategy Choosen
        Estimating Standard RIF-OAXACA using RIF:q(50)
        Model  : Blinder-Oaxaca RIF-decomposition
        Type   : Standard
        RIF    : q(50)
        Scale  : 1
        Group 1: female = 0 x1*b1                        N of obs 1      = 751
        Group c: x2*b1                                   N of obs C      =          .
        Group 2: female = 1 x2*b2                        N of obs 2      = 683
        
        ------------------------------------------------------------------------------
              lnwage | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
        -------------+----------------------------------------------------------------
        overall      |
             group_1 |   3.471406   .0162183   214.04   0.000     3.439619    3.503193
             group_2 |   3.334947   .0196443   169.77   0.000     3.296445    3.373449
          difference |   .1364586   .0254741     5.36   0.000     .0865302     .186387
           explained |   .0669252    .010453     6.40   0.000     .0464378    .0874126
         unexplained |   .0695334   .0240815     2.89   0.004     .0223345    .1167322
        -------------+----------------------------------------------------------------
        explained    |
                educ |    .032043   .0078299     4.09   0.000     .0166968    .0473893
                 job |   .0348822   .0075067     4.65   0.000     .0201693    .0495951
        -------------+----------------------------------------------------------------
        unexplained  |
                educ |  -.2260105   .1116666    -2.02   0.043     -.444873   -.0071481
                 job |  -.0172138   .0317636    -0.54   0.588    -.0794694    .0450417
               _cons |   .3127577   .1255673     2.49   0.013     .0666504     .558865
        ------------------------------------------------------------------------------
        job: exper tenure
        
        .
        Last edited by Andrew Musau; 05 Dec 2025, 06:05.

        Comment


        • #5
          Thanks Andrew. I was only getting the overall no matter what I tried and it wouldn't run with a parenthetical reference to any groups of variables. I'm going to try this with the code that you've provided though because the syntax I had was slightly different in the options. I'll report back shortly!

          The language is definitely different in the results, which is leading to some communication problems here. I'm not sure what explained/unexplained is actually. Endowments and coefficients provide the difference between the 2 groups based on differences in the mean characteristics at that variable versus returns from that variable. Not sure how that translates to explained/unexplained, but will compare results across the two models.

          Comment


          • #6
            Very interesting...I don't get the results by variable when I run oaxaca_rif for the full model and I get an error message when I add in the parenthetical to add the group of variables...very odd!!

            Comment


            • #7
              I'm wondering if this is a version of Stata problem...thank you Andrew and George for your attempts to help!! Much appreciated!!

              Comment


              • #8
                oaxaca_rif is community contribited. I have:

                Code:
                . which oaxaca_rif
                C:\Users\amus\ado\plus\o\oaxaca_rif.ado
                *!version 2.4 Nov 2020 Fernando Rios Avila
                Try

                Code:
                ssc install rif, replace
                and try again. If you struggle with translating the output of oaxaca_rif to match the output of oaxaca, post back and I will offer an explanation.

                Comment


                • #9
                  Well I have the same version and when I ran the ssc install command that you shared it said I had the latest update, but here's what I get:

                  . oaxaca_rif lntotassets /*shortplan*/ midplan longplan high_risk average_risk /*low_risk*/ borrow use_savings /*p
                  > ostpone_payments*/ cut_back work_more saveforfam saveforinvest saveforsafetynet save3 save4 save5 save6 lntotval
                  > ueinherit has_financial_emergency providing_financial_support lnincome managerocc1 /*stemocc1 serviceocc1 cons
                  > tocc1 artsocc1*/ institutions_within_half_mile ownbusiness student_loans colleducated marr age_category haskidsi
                  > nhh [aw=x42001], by(blackbygender) rif(q(50))
                  No wgt specified. Using default 0
                  No Reweighted Strategy Choosen
                  Estimating Standard RIF-OAXACA using RIF:q(50)
                  Model : Blinder-Oaxaca RIF-decomposition
                  Type : Standard
                  RIF : q(50)
                  Scale : 1
                  Group 1: blackbygender = 1 x1*b1 N of obs 1 = 925
                  Group c: x1*b2 N of obs C = .
                  Group 2: blackbygender = 2 x2*b2 N of obs 2 = 778

                  -------------------------------------------------------------------------------
                  lntotassets | Coef. Std. Err. z P>|z| [95% Conf. Interval]
                  --------------+----------------------------------------------------------------
                  Differential |
                  Prediction_1 | 10.56245 .1075547 98.21 0.000 10.35165 10.77326
                  Prediction_2 | 11.47353 .1121621 102.29 0.000 11.2537 11.69337
                  Difference | -.9110799 .1553974 -5.86 0.000 -1.215653 -.6065066
                  --------------+----------------------------------------------------------------
                  Decomposition |
                  Explained | -.4303789 .1544611 -2.79 0.005 -.7331171 -.1276407
                  Unexplained | -.480701 .164075 -2.93 0.003 -.8022821 -.1591199
                  -------------------------------------------------------------------------------

                  Comment


                  • #10
                    Also note that oaxaca_rif calls oaxaca, so make sure that you also have the latest version of oaxaca.

                    Code:
                    ssc install oaxaca, replace
                    My current version:

                    Code:
                     which oaxaca
                    C:\Users\amus\ado\plus\o\oaxaca.ado
                    *! version 4.1.1  24apr2023  Ben Jann
                    If the above are all up to date, show us what you get when you run the following:

                    Code:
                    use http://fmwww.bc.edu/RePEc/bocode/o/oaxaca.dta, clear
                    *INDIVIDUAL VARIABLES
                    oaxaca_rif lnwage educ exper tenure, by(female) wgt(1) rif(q(50))
                    *GROUPING EXPERIENCE AND TENURE
                    oaxaca_rif lnwage educ (job: exper tenure), by(female) wgt(1) rif(q(50))
                    Last edited by Andrew Musau; 08 Dec 2025, 09:24.

                    Comment


                    • #11
                      AHHHH...THAT appears to be the culprit!!! I tried it with the sample dataset (below) and with my data and it's finally working!!!! THANK YOU ANDREW!!!!!

                      . oaxaca_rif lnwage educ exper tenure, by(female) wgt(1) rif(q(50))
                      No Reweighted Strategy Choosen
                      Estimating Standard RIF-OAXACA using RIF:q(50)
                      Model : Blinder-Oaxaca RIF-decomposition
                      Type : Standard
                      RIF : q(50)
                      Scale : 1
                      Group 1: female = 0 x1*b1 N of obs 1 = 751
                      Group c: x2*b1 N of obs C = .
                      Group 2: female = 1 x2*b2 N of obs 2 = 683

                      ------------------------------------------------------------------------------
                      lnwage | Coef. Std. Err. z P>|z| [95% Conf. Interval]
                      -------------+----------------------------------------------------------------
                      overall |
                      group_1 | 3.471406 .0162183 214.04 0.000 3.439619 3.503193
                      group_2 | 3.334947 .0196443 169.77 0.000 3.296445 3.373449
                      difference | .1364586 .0254741 5.36 0.000 .0865302 .186387
                      explained | .0669252 .010453 6.40 0.000 .0464378 .0874126
                      unexplained | .0695334 .0240815 2.89 0.004 .0223345 .1167322
                      -------------+----------------------------------------------------------------
                      explained |
                      educ | .032043 .0078299 4.09 0.000 .0166968 .0473893
                      exper | .0121175 .0045679 2.65 0.008 .0031647 .0210703
                      tenure | .0227647 .0062972 3.62 0.000 .0104225 .0351069
                      -------------+----------------------------------------------------------------
                      unexplained |
                      educ | -.2260105 .1116666 -2.02 0.043 -.444873 -.0071481
                      exper | -.0240455 .0376449 -0.64 0.523 -.0978282 .0497372
                      tenure | .0068316 .025028 0.27 0.785 -.0422224 .0558857
                      _cons | .3127577 .1255673 2.49 0.013 .0666504 .558865
                      ------------------------------------------------------------------------------

                      . oaxaca_rif lnwage educ (job:exper tenure), by(female) wgt(1) rif(q(50))
                      No Reweighted Strategy Choosen
                      Estimating Standard RIF-OAXACA using RIF:q(50)
                      Model : Blinder-Oaxaca RIF-decomposition
                      Type : Standard
                      RIF : q(50)
                      Scale : 1
                      Group 1: female = 0 x1*b1 N of obs 1 = 751
                      Group c: x2*b1 N of obs C = .
                      Group 2: female = 1 x2*b2 N of obs 2 = 683

                      ------------------------------------------------------------------------------
                      lnwage | Coef. Std. Err. z P>|z| [95% Conf. Interval]
                      -------------+----------------------------------------------------------------
                      overall |
                      group_1 | 3.471406 .0162183 214.04 0.000 3.439619 3.503193
                      group_2 | 3.334947 .0196443 169.77 0.000 3.296445 3.373449
                      difference | .1364586 .0254741 5.36 0.000 .0865302 .186387
                      explained | .0669252 .010453 6.40 0.000 .0464378 .0874126
                      unexplained | .0695334 .0240815 2.89 0.004 .0223345 .1167322
                      -------------+----------------------------------------------------------------
                      explained |
                      educ | .032043 .0078299 4.09 0.000 .0166968 .0473893
                      job | .0348822 .0075067 4.65 0.000 .0201693 .0495951
                      -------------+----------------------------------------------------------------
                      unexplained |
                      educ | -.2260105 .1116666 -2.02 0.043 -.444873 -.0071481
                      job | -.0172138 .0317636 -0.54 0.588 -.0794694 .0450417
                      _cons | .3127577 .1255673 2.49 0.013 .0666504 .558865
                      ------------------------------------------------------------------------------
                      job: exper tenure

                      Comment


                      • #12
                        Now I have a new question: How does explained/unexplained align with endowments/coefficients?

                        Comment


                        • #13
                          Let's use the output in #11:

                          Code:
                          . oaxaca_rif lnwage educ exper tenure, by(female) wgt(1) rif(q(50))
                          No Reweighted Strategy Choosen
                          Estimating Standard RIF-OAXACA using RIF:q(50)
                          Model : Blinder-Oaxaca RIF-decomposition
                          Type : Standard
                          RIF : q(50)
                          Scale : 1
                          Group 1: female = 0 x1*b1 N of obs 1 = 751
                          Group c: x2*b1 N of obs C = .
                          Group 2: female = 1 x2*b2 N of obs 2 = 683
                          
                          ------------------------------------------------------------------------------
                          lnwage | Coef. Std. Err. z P>|z| [95% Conf. Interval]
                          -------------+----------------------------------------------------------------
                          overall |
                          group_1 | 3.471406 .0162183 214.04 0.000 3.439619 3.503193
                          group_2 | 3.334947 .0196443 169.77 0.000 3.296445 3.373449
                          difference | .1364586 .0254741 5.36 0.000 .0865302 .186387
                          explained | .0669252 .010453 6.40 0.000 .0464378 .0874126
                          unexplained | .0695334 .0240815 2.89 0.004 .0223345 .1167322
                          -------------+----------------------------------------------------------------
                          explained |
                          educ | .032043 .0078299 4.09 0.000 .0166968 .0473893
                          exper | .0121175 .0045679 2.65 0.008 .0031647 .0210703
                          tenure | .0227647 .0062972 3.62 0.000 .0104225 .0351069
                          -------------+----------------------------------------------------------------
                          unexplained |
                          educ | -.2260105 .1116666 -2.02 0.043 -.444873 -.0071481
                          exper | -.0240455 .0376449 -0.64 0.523 -.0978282 .0497372
                          tenure | .0068316 .025028 0.27 0.785 -.0422224 .0558857
                          _cons | .3127577 .1255673 2.49 0.013 .0666504 .558865
                          ------------------------------------------------------------------------------


                          Start with the wage gap:

                          group1 − group2 = 3.4714063.334947 = 0.136459 (total gap).

                          So in the Blinder–Oaxaca decomposition (including the RIF variant), the wage gap is decomposed into two conceptually distinct components:

                          1. Explained = differences in endowments \((X \text{'s})\): This part measures how much of the median wage gap is due to the fact that men and women differ in their observed characteristics (i.e., education, experience, tenure, etc. in the example).

                          Explained (sum of endowment contributions) = 0.032043 + 0.0121175 + 0.0227647 = 0.0669252.


                          2. Unexplained = differences in coefficients \((\beta \text{'s})\)

                          This part measures how much of the wage gap is due to men and women receiving different returns to the same characteristics.

                          Unexplained (sum of coefficient contributions + constant) = −0.2260105 + (−0.0240455) + 0.0068316 + 0.3127577 = 0.0695334.

                          explained + unexplained = 0.0669252 + 0.0695334 = 0.1364586

                          Comment


                          • #14
                            Ahhh gotcha!! Andrew - I'm adding you to the acknowledgments for this article whenever it will be published. Your help is very much appreciated!!! Thank you!!

                            Comment


                            • #15
                              Thanks, glad to help!

                              Comment

                              Working...
                              X