Announcement

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

  • Stata- margins and rifreg command

    Hi,
    We have a problem with margins after rifreg command: it works without writting xi in front of rifreg, but not with xi. Anyone know if there is an instruction to estimante rifreg without writting xi in front?
    Thank you in advance
    The instruction:
    global ylist LNSALHORA
    global xlist_x "i.cnaceagr i.mujer_sector i.anos2 i.estu"

    *unconditional quantile regression
    local quartile 20 50 80
    qui foreach q of local quartile {
    noisily display "quartile" `q'
    xi: rifreg $ylist $xlist_x [fw=factor], quantile(`q') w(0.0)
    est sto uqr`q'
    noisily margins cnaceagr
    }

  • #2
    Hi Maria
    May I suggest to install the command "oaxaca_rif". In there, i included a command named "rifhdreg" which does everything rifreg does, allowing for the use of factor variables. It would allow you to do the following:
    Code:
    ssc install oaxaca_rif
    sysuse auto, clear
    rifhdreg mpg price i.foreign, rif(q(25))
    margins foreign
    tabstat mpg, stats(p25) by(foreign)
    Nevertheless, one clarification is needed. In the framework of RIF-regressions the coefficients, or marginal effects, are valid as approximations for small changes in the distribution of characteristics on the unconditional statistic of interest. Using margins in the fashion you suggest assumes that you are trying to test the change of the whole distribution. In my example, moving the distribution from domestic to foreign. In this case, the result may be valid if and only If the model is well specified to capture the nonlinearities between the explanatory variable and the outcomes, and the outcomes and the statitistic of interest (in your case the quantile)
    Hope this helps.
    Fernando
    ps. WHen using RIF's for unconditional quantile regressions, OLS standard errors are incorrect. rifhdreg provides the OLS standard errors by default, but you should at the least use the robust option (this is what rifreg does). The best option is to use Bootstrap standard errors, but other steps need to be consider to use Bootstrap methods with survey design within this method.
    Last edited by FernandoRios; 26 Mar 2019, 06:58.

    Comment


    • #3
      Thank you Fernando, I will try with the command you suggest.

      Comment


      • #4
        Hi Fernando,
        It works. Thank you. Now we have a doubt. The estimated parameters with the instruction rifreg differ in the same % (-0.35%) of those estimated with the "oaxaca_rif" command. Any suggestion??? Any recommendation to read to know the cause?

        Instruction with "rifreg"command
        local quartile 20 50 80
        qui foreach q of local quartile {
        noisily display "quartile" `q'
        xi: rifreg $ylist $xlist1 [fw=factor], quantile(`q') w(0.0)
        est sto uqr`q'

        Instruction with "oaxaca_rif"command
        qui foreach q of local quartile {
        noisily display "quartile" `q'
        rifhdreg $ylist $xlist1 [fw=factor], rif(q(`q'))
        est sto uqr`q'

        Comment


        • #5
          Hi Maria
          Im glad the command is working for your purposes. Regarding the differences in the coefficients, the difference comes from the way RIFREG and RIFHDREG estimate the Quantile RIF, in specific, the density function at the qth quantile. RIFREG uses gaussian kernel, using the kdensity plugin bandwidth as default.
          RIFHDREG also uses the normal/gaussian kernel as default but applies the silvermans plugin BW as default. This has a small impact on the estimated RIF, which translates in the differences of the RIFREG command.
          Below i provide an example where i replicate rifreg results with the rifhdreg command:
          Code:
           webuse womenwk, clear
          rifreg wage children married education age, q(25) norobust
          kdensity wage, nograph
          local bw=r(bwidth)
          rifhdreg wage children married education age, rif(q(25) bw(`bw')
          Hope this helps.
          Best
          Fernando

          Comment


          • #6
            Hi Fernando,
            This helps a lot.
            Thank you,
            Maria

            Comment

            Working...
            X