Announcement

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

  • Am having problem using Blinder-Oaxaca decomposition command as used by Ben Jann

    Hi All
    Am trying to use the commands use by Ben Jann in his article ‘The Blinder-Oaxaca decomposition for linear regression models” on his own data but I have the following errors for each of the commands after using them as stated below:
    1. svyset [pw=wt]

    pweight: wt
    VCE: linearized
    Single unit: missing
    Strata 1: <one>
    SU 1: <observations>
    FPC 1: <zero>

    . pweight: wt
    unrecognized command:pweight
    r(199);

    end of do-file

    r(199);


    (ii) tabulate isco, nofreq generate(isco)
    .oaxaca lnwage educ exper tenure isco2-isco9, by(female) pooled ///
    > detail(exp_ten: exper tenure, isco: isco?) categorical(isco?)
    option > not allowed
    r(198);

    end of do-file

    r(198);
    Can anybody assist me to fix it?
    Thanks in anticipation
    Sola Olorunfemi
    Last edited by olorunfemi sola; 18 Feb 2015, 15:04.

  • #2
    To have the first situation squared out please go for
    Code:
    help svy
    Last edited by Zuhumnan Dapel; 18 Feb 2015, 17:11.

    Comment


    • #3
      It appears you are copying and pasting from Ben Jann's article directly into Stata without separating commands from output, and dealing with line breaks properly.

      So, in the first situation, -svyset [pw = wt]- is a command, but everything after that, including pweight: wt is Stata's output in response to that command. So you can't feed that back in as if it were commands.

      In the second situation,
      Code:
      oaxaca lnwage educ exper tenure isco2-isco9, by(female) pooled ///
      > detail(exp_ten: exper tenure, isco: isco?) categorical(isco?)
      is how Stata logs will record a long command that is split over two lines. In particular, the > character is not part of the command, but is inserted as Stata logs it to call visual attention to the continuation of the command on a second line. But, not being part of the command, if you try to feed it into Stata as if it were, Stata complains. The correct way to issue this command to Stata is:
      Code:
      oaxaca lnwage educ exper tenure isco2-isco9, by(female) pooled detail(exp_ten: exper tenure, isco: isco?) categorical(isco?)
      More generally, just copying and pasting log-file output into Stata as commands will not work. It requires a bit of editing.
      Last edited by Clyde Schechter; 18 Feb 2015, 17:51. Reason: Note: in the final code block, my intention was to have the command appear on a single line: I did not see that it would fail to show up that way. But you can still type it in that way (to the Comman

      Comment


      • #4
        I want to thank Clyde Schechter for been able to address my ignorance. Your suggestions work perfectly. I appreciate Zuhumnan Dapel too. Please one more thing, why is Ben Jann using " isco2-isco9" as one of his variables as this is not in the table showing his data set? Thanks in anticipation.

        Comment


        • #5
          Good day

          I'm having a problem running the oaxaca command I get the "command oaxaca is unrecognized " error, this is the code i sued: "oaxaca lfps yrschool age agesq maristat exprnc coloured indian white , by(male) noisily if qtr==1"

          What can I do differently?

          Comment


          • #6
            Originally posted by Nkanyiso Maphanga View Post
            I get the "command oaxaca is unrecognized " error, this is the code i sued: "oaxaca lfps yrschool age agesq maristat exprnc coloured indian white , by(male) noisily if qtr==1"
            What can I do differently?
            oaxaca is community-contributed software and not part of official Stata; you will have to install the command, first. I am not sure this is the latest version, but you can install the command by typing

            Code:
            ssc install oaxaca
            If this does not solve the problem, you probably need to change your ado paths (we will deal with this if needed).

            Best
            Daniel

            Comment


            • #7
              Thank yo that was helpful, i was able to run my code.

              Comment


              • #8
                Hi,
                I am using Stata 14 and am trying to use oaxaca command for decomposition of earnings (labour market) for different groups. I have installed package oaxaca from
                http://fmwww.bc.edu/repec/bocode/o: 'OAXACA': module to compute the Blinder-Oaxaca decomposition
                Thhe command I tried was
                oaxaca LgWg Rural1 NeverMarried1 TechEdu1 YearsOfSchooling Age AgeSq normalize(SocialGrp1 SocialGrp2 SocialGrp3 b.SocialGrp4, Relign1 Relign2 b.Relign3), by(Female1) detail pooled
                Result
                b.Relign3 not allowed
                r(198);
                where lgwg is usual log of earnings; Rural1 is binary variable (1-rural/0-urban0); Nevermarried1- binary variable (1-not married/0-married); TechEdu1- binrary (1-has technical education/0-does not have); YearsofSchooling- continuous variable (no.of years taken in school); Age and age sq are continuous variables; Socialgrp1-4 are dummies for 4 category variable Socialgroup with 4th group as the base; Relign1-3- 3 dummies for 3 category variable Religion with 3rd category as the base.
                I used normalize, as I had read in Ben Jann's (https://www.stata-journal.com/sjpdf....iclenum=st0151) article and a chapter by Fortin. N., et.al (https://www.sciencedirect.com/handbo.../vol/4/part/PA) that the choice of base group has serious effect on the results.

                Removing Relign
                oaxaca LgWg Rural1 NeverMarried1 TechEdu1 YearsOfSchooling Age AgeSq normalize(SocialGrp1 SocialGrp2 SocialGrp3 b.SocialGrp4), by(Female1) detail pooled

                oaxaca_normalize(): 3498 inconsistent dummy set: SocialGrp1 SocialGrp2 SocialGrp3 SocialGrp4
                <istmt>: - function returned error
                r(3498);
                Using categorical instead of normalize
                oaxaca LgWg Rural1 NeverMarried1 TechEdu1 YearsOfSchooling Age AgeSq SocialGrp1 SocialGrp2 SocialGrp3, by(Female1) detail pooled categorical(SocialGrp1 SocialGrp2 SocialGrp3 b.SocialGrp4)

                factor variables and time-series operators not allowed
                r(101);
                wihtout specifing which one to take as base group
                oaxaca LgWg Rural1 NeverMarried1 TechEdu1 YearsOfSchooling Age AgeSq SocialGrp1 SocialGrp2 SocialGrp3, by(Female1) detail pooled categorical(SocialGrp1 SocialGrp2 SocialGrp3 SocialGrp4)
                oaxaca_normalize(): 3498 inconsistent dummy set: SocialGrp1 SocialGrp2 SocialGrp3 SocialGrp4
                <istmt>: - function returned error
                but if i run the command taking my specific base and without normalize/ categorical
                oaxaca LgWg Rural1 NeverMarried1 TechEdu1 YearsOfSchooling Age AgeSq SocialGrp1 SocialGrp2 SocialGrp3 Relign1 Relign2 ,by(Female1) detail pooled

                Blinder-Oaxaca decomposition Number of obs = 84,279
                Model = linear
                Group 1: Female1 = 0 N of obs 1 = 63988
                Group 2: Female1 = 1 N of obs 2 = 20291
                Robust
                LgWg Coef. Std. Err. z P>z [95% Conf. Interval]
                overall
                group_1 4.526128 .0033489 1351.54 0.000 4.519564 4.532692
                group_2 3.882628 .00634 612.41 0.000 3.870202 3.895054
                difference .6435 .0071701 89.75 0.000 .6294469 .6575531
                explained .2017233 .0049231 40.98 0.000 .1920742 .2113723
                unexplained .4417767 .0055427 79.70 0.000 .4309133 .4526402
                explained
                Rural1 .0101074 .0007199 14.04 0.000 .0086965 .0115183
                NeverMarried1 -.0059328 .0005666 -10.47 0.000 -.0070434 -.0048222
                TechEdu1 .0038111 .0005352 7.12 0.000 .0027621 .00486
                YearsOfSchooling .1812202 .0037093 48.86 0.000 .1739501 .1884902
                Age .0050753 .0055929 0.91 0.364 -.0058865 .0160371
                AgeSq -.0028538 .0039108 -0.73 0.466 -.0105188 .0048112
                SocialGrp1 .0007689 .0002372 3.24 0.001 .0003039 .0012339
                SocialGrp2 .0042137 .0005155 8.17 0.000 .0032033 .005224
                SocialGrp3 .0036787 .0005894 6.24 0.000 .0025235 .0048338
                Relign1 .0013467 .0004311 3.12 0.002 .0005017 .0021917
                Relign2 .000288 .0006321 0.46 0.649 -.0009509 .0015268
                unexplained
                Rural1 -.0059295 .0072843 -0.81 0.416 -.0202065 .0083475
                NeverMarried1 .0101336 .0037994 2.67 0.008 .0026869 .0175804
                TechEdu1 -.0056356 .0017255 -3.27 0.001 -.0090176 -.0022536
                YearsOfSchooling -.0692977 .0065519 -10.58 0.000 -.0821392 -.0564563
                Age .7408358 .0959907 7.72 0.000 .5526975 .9289741
                AgeSq -.2237564 .0471882 -4.74 0.000 -.3162435 -.1312692
                SocialGrp1 -.0206385 .0027832 -7.42 0.000 -.0260934 -.0151835
                SocialGrp2 -.0138324 .0042121 -3.28 0.001 -.022088 -.0055769
                SocialGrp3 -.0035054 .005742 -0.61 0.542 -.0147594 .0077487
                Relign1 .0027664 .0016095 1.72 0.086 -.0003881 .005921
                Relign2 .0054985 .0021415 2.57 0.010 .0013012 .0096958
                _cons .0251378 .05597 0.45 0.653 -.0845614 .1348371
                the result obviously keeps changing if i change my base category. I tried uninstalling and re installing the package as well. Kindly help.

                Comment


                • #9
                  As far as I understand the package, then the package behaves as expected and re-installing won't save the problem.
                  According to my understanding of the package, I would change the line
                  Code:
                  oaxaca LgWg Rural1 NeverMarried1 TechEdu1 YearsOfSchooling Age AgeSq normalize(SocialGrp1 SocialGrp2 SocialGrp3 b.SocialGrp4, Relign1 Relign2 b.Relign3), by(Female1) detail pooled
                  to
                  Code:
                  oaxaca LgWg Rural1 NeverMarried1 TechEdu1 YearsOfSchooling Age AgeSq normalize(SocialGrp1 SocialGrp2 SocialGrp3 b.SocialGrp4) normalize(Relign1 Relign2 b.Relign3), by(Female1) detail pooled
                  Using two normalize groups instead of one. That's at least how I deal with multiple categorical variables in my decomposition.
                  As far as I understand the help file of the package, then the normalize "option" can only deal with one group of categorical or interacted variables at a time.

                  Comment


                  • #10
                    Hi Sven-Kristjan,
                    Thanks you for responding to my query. I tried your suggestion by using normalize separately for two groups but got an error.
                    . oaxaca LgWg Rural1 NeverMarried1 TechEdu1 YearsOfSchooling Age AgeSq normalize(SocialGrp1 SocialGrp2 SocialGrp3 b.SocialGrp4) normalize(Relign1 Relign2 b.Relign3), by(Female1) detail pooled
                    oaxaca_normalize(): 3498 inconsistent dummy set: SocialGrp1 SocialGrp2 SocialGrp3 SocialGrp4
                    <istmt>: - function returned error

                    Comment


                    • #11
                      Could you show an example of your dataset? Just run the dataex command in Stata and post the results here. If you do not have the dataex command installed, then run
                      Code:
                      ssc install dataex
                      .
                      My guess is that there is something wrong with your SocialGrp variable. As far as I understand the code of the oaxaca_normalize function, then you should have somewhere the case that an individual belongs to two social groups. If my understanding is correct, then oaxaca command points you to a problem in your dataset.

                      Comment


                      • #12
                        Hi Sven,
                        Thank you for the response.
                        I ran the said command dataex for the categorical variables that I want to use in my decomposition
                        dataex SocialGrp1 SocialGrp2 SocialGrp3 SocialGrp4 Relign1 Relign2 Relign3
                        copy starting from the next line -----------------------
                        Code:
                        * Example generated by -dataex-. To install: ssc install dataex
                        clear
                        input double(SocialGrp1 SocialGrp2 SocialGrp3 SocialGrp4 Relign1 Relign2 Relign3)
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 1 0 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 1 0 0 0 1 0
                        0 1 0 0 0 1 0
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        1 0 0 0 0 0 1
                        1 0 0 0 0 0 1
                        1 0 0 0 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 1 0 0 0 1
                        1 0 0 0 0 0 1
                        1 0 0 0 0 0 1
                        0 0 1 0 0 0 1
                        0 0 1 0 0 0 1
                        0 0 1 0 0 0 1
                        0 0 0 1 0 0 1
                        0 0 1 0 1 0 0
                        0 0 1 0 1 0 0
                        0 0 1 0 1 0 0
                        0 0 1 0 1 0 0
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 1 0 0
                        0 0 0 1 1 0 0
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 1 0
                        0 0 0 1 0 0 1
                        0 1 0 0 0 0 1
                        1 0 0 0 0 0 1
                        0 0 1 0 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 1 0 0 0 1
                        0 0 1 0 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 1 0 0
                        0 0 1 0 0 0 1
                        0 0 1 0 0 0 1
                        0 0 1 0 0 0 1
                        0 0 0 1 1 0 0
                        0 0 1 0 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        0 0 0 1 0 0 1
                        end
                        copy up to and including the previous line ------------------
                        Listed 100 out of 84322 observations
                        Use the count() option to list more
                        .

                        Comment


                        • #13
                          Your data example looks fine for me, so the problem might be in a part that you did not show.
                          You could run something like
                          Code:
                          egen SocialGrp = rowtotal(SocialGrp*) //Calculate in how many social groups a person is.
                          count if SocialGrp!=1 //Gives you the number of observations which are in more than one social group or in no Social Grp
                          list if SocialGrp!=1 // Show the faulty observations
                          This code reproduces somewhat the behaviour of the oaxaca command when it fails.

                          Comment


                          • #14
                            Thank you for your response.
                            I have not run the above command will try that, though I tried to work around by making only two categories for my variable social group. Am I right in not using the normalize option for variables with only two categories?
                            Thanks lot for your help

                            Comment


                            • #15
                              Yes, you are correct that you do not need the normalize option for variables with two categories. That's at least my understanding.

                              Comment

                              Working...
                              X