Announcement

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

  • Oaxaca-Blinder decomposition with dummy variables

    Hello all,

    I'm tring to use the Oaxaca command. My code is:

    oaxaca logtime age age2 i.i301 i.i18 i.i14 i.sni, by(i10)

    It says "factor variables and time-series operators not allowed"

    So what should I do if I want to do an Oaxaca decomposition with some dummy variables?

    Thank you!

  • #2
    Fangxin:
    welcome to the list.
    As the user-written programme -oaxaca- (as per FAQ you should have specified that -oaxaca- is not a built-in Stata command) dates back to 2008 (http://www.stata-journal.com/article...article=st0151), it does not support -fvvarlist- notation.
    The usual fix is to prefix your code with -xi-:
    Code:
    xi: oaxaca logtime age age2 i.i301 i.i18 i.i14 i.sni, by(i10)
    As an aside, you should avoid crating interactions yourself, as -fvvarlist- can handle them, too.
    Code:
    xi: oaxaca logtime c.age##c.age i.i301 i.i18 i.i14 i.sni, by(i10)
    .

    More than this, -fvvarlist- can introduce you to two wonderful Stata commands, such as -margins- and marginsplot-.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Dear Fangxin,

      Yes you can use dummy variables with oaxaca.

      Your code can be represented:
      Code:
      oaxaca y i.x1 i.x2, by(group)
      we assume that xi and x2 are three-level categorical variables.
      This would not work with oaxaca.

      First you need to create dummy variables.
      Code:
      tab x1, gen(x1_)
      Code:
      tab x2, gen(x2_)
      You now have dummy variables x1_1 x1_2 x1_3. x2_1 x2_2 x2_3.

      Then run oaxaca
      Code:
      oaxaca y normalize(x1_1 b.x1_2 x1_3 ) normalize(x2_1 x2_2 b.x2_3) , by(group)
      Please note that no space between normalize and brackets.
      Prefix b. indicates the base category.

      Also note the oaxaca version.
      Code:
      which oaxaca
      c:\ado\plus\o\oaxaca.ado
      *! version 4.0.5  24aug2011  Ben Jann
      I suggest Ben Jann's oaxaca paper. Or you may want to check the oaxaca help file "Normalization of categorical variables".

      Hope it helps.


      Regards,
      Min
      Last edited by Min Zhang; 31 Aug 2017, 11:50.

      Comment

      Working...
      X