Announcement

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

  • Oaxaca Decomposition with dummy variables

    I am trying to use the Oaxaca command. My code looks like this:

    oaxaca ln(p010h) ln(hgsize) ln(hgroom) hgeqpgar hgnuts1_ew hgeqpter hgeqpbas, by(syear_x) categorical(hgeqpgar hgnuts1_ew hgeqpter hgeqpbas)

    p010h, hgsize, hgroom are numeric variables.
    syear_X consists of 0 and 1
    All other variables are also dummy variables consisting of 0 and 1.

    I always get the following error message: "factor-variable and time-series operators not allowed"

    I would be very thankful for your help
    Best
    Jakob

  • #2
    There is no -ln()- syntax in any part of Stata that I know of. You need to create separate logged variables.

    Comment


    • #3
      Sorry, worked too much with R in the past. I have now adjusted the code. It now reades:

      oaxaca p010h hgsize hgroom hgeqpgar hgnuts1_ew hgeqpter hgeqpbas, by(syear_x) categorical(hgeqpgar hgnuts1_ew hgeqpter hgeqpbas)

      It yields the following error message: oaxaca_normalize(): 3498 inconsistent dummy set: hgeqpgar hgnuts1_ew hgeqpter
      > hgeqpbas
      <istmt>: - function returned error
      How do i solve this issue? There are no missing values in the dataframe.

      Thank you Andrew. I really appreciate the help. You already helped me with a different issue a couple of month ago.


      Comment


      • #4
        Originally posted by Jakob Smith View Post

        oaxaca p010h hgsize hgroom hgeqpgar hgnuts1_ew hgeqpter hgeqpbas, by(syear_x) categorical(hgeqpgar hgnuts1_ew hgeqpter hgeqpbas)

        If you do not want the results of the decompositions to depend on the omitted categories, you need -normalize()- within the main command.

        Code:
        oaxaca p010h hgsize hgroom normalize(hgeqpgar hgnuts1_ew hgeqpter hgeqpbas), by(syear_x)
        Otherwise try

        Code:
        foreach var in hgeqpgar hgnuts1_ew hgeqpter hgeqpbas{
            assert inlist(`var', 0, 1)
            tab `var', g(`var')
        }
        oaxaca p010h hgsize hgroom normalize(hgeqpgar? hgnuts1_ew? hgeqpter? hgeqpbas?), by(syear_x)
        If you get an error from the assert command, some of your variables are not 0/1 indicators or they have missing values.

        Comment


        • #5
          Thank you so much for the quick response. I added noisily and relax to the code.

          oaxaca p010h hgsize hgroom normalize(hgeqpgar? hgnuts1_ew? hgeqpter? hgeqpbas?), by
          > (syear_x) noisily relax

          Model for group 1

          Source | SS df MS Number of obs = 5,931
          -------------+---------------------------------- F(6, 5924) = 223.08
          Model | 3.8482e+13 6 6.4137e+12 Prob > F = 0.0000
          Residual | 1.7032e+14 5,924 2.8751e+10 R-squared = 0.1843
          -------------+---------------------------------- Adj R-squared = 0.1835
          Total | 2.0880e+14 5,930 3.5211e+10 Root MSE = 1.7e+05

          ------------------------------------------------------------------------------
          p010h | Coefficient Std. err. t P>|t| [95% conf. interval]
          -------------+----------------------------------------------------------------
          hgsize | 1717.092 71.93704 23.87 0.000 1576.069 1858.114
          hgroom | -10896 1910.109 -5.70 0.000 -14640.51 -7151.491
          hgeqpgar2 | -33875.61 7487.872 -4.52 0.000 -48554.57 -19196.65
          hgnuts1_ew1 | 54668.95 5983.449 9.14 0.000 42939.2 66398.69
          hgnuts1_ew2 | 0 (omitted)
          hgeqpter1 | 26075.56 6753.896 3.86 0.000 12835.47 39315.66
          hgeqpter2 | 0 (omitted)
          hgeqpbas1 | 27072.74 11220.02 2.41 0.016 5077.419 49068.07
          hgeqpbas2 | 0 (omitted)
          _cons | -13125.97 13307.58 -0.99 0.324 -39213.68 12961.73
          ------------------------------------------------------------------------------
          (model 1 has zero variance coefficients)

          Model for group 2

          Source | SS df MS Number of obs = 7,139
          -------------+---------------------------------- F(6, 7132) = 274.77
          Model | 6.3753e+13 6 1.0626e+13 Prob > F = 0.0000
          Residual | 2.7580e+14 7,132 3.8671e+10 R-squared = 0.1878
          -------------+---------------------------------- Adj R-squared = 0.1871
          Total | 3.3955e+14 7,138 4.7570e+10 Root MSE = 2.0e+05

          ------------------------------------------------------------------------------
          p010h | Coefficient Std. err. t P>|t| [95% conf. interval]
          -------------+----------------------------------------------------------------
          hgsize | 1847.854 75.00852 24.64 0.000 1700.815 1994.893
          hgroom | -8235.219 2050.034 -4.02 0.000 -12253.89 -4216.544
          hgeqpgar2 | -9751.148 7978.049 -1.22 0.222 -25390.49 5888.195
          hgnuts1_ew1 | 83938.51 6142.633 13.66 0.000 71897.13 95979.9
          hgnuts1_ew2 | 0 (omitted)
          hgeqpter1 | 58739.49 8256.562 7.11 0.000 42554.18 74924.8
          hgeqpter2 | 0 (omitted)
          hgeqpbas1 | 18265.54 9687.509 1.89 0.059 -724.8559 37255.93
          hgeqpbas2 | 0 (omitted)
          _cons | -69849.34 13581.12 -5.14 0.000 -96472.37 -43226.32
          ------------------------------------------------------------------------------
          (model 2 has zero variance coefficients)
          _error(): 3300 argument out of range
          oaxaca_normalize(): - function returned error
          <istmt>: - function returned error


          Unfortunately there is still an error message. Somehow the normalize function seems to not be working. The first line of code suggested by you unfortunately also resulted in an error message that was linked to the normalization.

          Comment


          • #6
            First update the command and try again

            Code:
            ssc install oaxaca, replace
            If the problem persists, send an email to the author with a dataset that reproduces the error.

            Comment

            Working...
            X