Announcement

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

  • new packages on ssc: genqreg and qregpd - generalized quantile regression and quantile regression with panel data

    Dear fellow Stata enthusiasts –

    With thanks to Kit Baum, and on behalf of David Powell and Travis Smith, I am happy to announce two new Stata Packages: genqreg and qregpd. These packages implement the generalized quantile estimator developed by Powell (2016), and the panel quantile estimator developed by Powell (2015). A detailed description of each estimator follows.

    genqreg – generalized quantile regression in Stata:

    genqreg
    implements the generalized quantile estimator developed in Powell (2016). The generalized quantile estimator addresses a fundamental problem posed by traditional quantile estimators: inclusion of additional covariates alters the interpretation of the estimated coefficient on the treatment variable. The generalized quantile estimator implemented by genqreg addresses this problem and produces unconditional quantile treatment effects even in the presence of additional control variables. genqreg also allows for endogeneity and inclusion of additional instruments, and inclusion of additional “proneness” variables.

    As estimation can be numerically challenging, and recovering standard errors difficult, genqreg provides a number of alternative estimation methods. One can estimate via grid search, Markov chain Monte Carlo (MCMC), or Nelder-Mead numerical optimization. To use MCMC, the user must first install the AMCMC package (ssc install amcmc) .

    Examples, following Chernozhukov and Hansen (2008):

    Robust quantile regression with qreg:

    Code:
    . use http://fmwww.bc.edu/repec/bocode/j/jtpa.dta, clear
    . keep if sex == 1
    . qreg earnings training hsorged black hispanic married wkless13 class_tr ojt_jsa age2225 age2629 age3035 age3644 age4554 f2sms, q(85) vce(robust)
    Same as above, with genqreg:
    Code:
    . genqreg earnings training hsorged black hispanic married wkless13 class_tr ojt_jsa age2225 age2629 age3035 age3644 age4554 f2sms, q(85)
    Same, estimation via MCMC:
    Code:
    . genqreg earnings training hsorged black hispanic married wkless13 class_tr ojt_jsa age2225 age2629 age3035 age3644 age4554 f2sms, ///
                  q(85) optimize(mcmc) noisy draws(10000) burn(3000) arate(.5)
    Specifying control variables as proness variables, with an instrument, estimation using grid-search:
    Code:
    genqreg earnings training, q(85) instrument(assignmt) proneness(hsorged black hispanic married wkless13 class_tr ojt_jsa age2225 age2629 age3035 age3644 age4554 f2sms) ///
                  optimize(grid) min1(1000) max1(3500) intvl1(50)
    Additional examples can be found in the genqreg help file. genqreg can be installed via ssc (ssc install genqreg)

    qregpd – quantile regression with panel data in Stata

    qregpd implements the quantile estimator for panel data developed by Powell (2015). As detailed in Powell (2016) – an awesome paper - this estimator is a special case of the generalized quantile estimator implemented by genqreg. The estimator addresses a fundamental problem posed by alternative fixed-effect quantile estimators: inclusion of fixed effects alters the interpretation of the estimated coefficient on the treatment variable.

    As is the case for genqreg, estimation of parameters and standard errors can be difficult, so a variety of different options, including MCMC estimation and grid search, are provided with qregpd.

    Examples:

    Robust quantile regression for panel data:
    Code:
    . webuse nlswork
    . qregpd ln_wage tenure union, id(idcode) fix(year)
    Same as above, MCMC:
    Code:
    .  qregpd ln_wage tenure union, id(idcode) fix(year) optimize(mcmc) noisy draws(1000) burn(100) arate(.5)
    Robust instrumental variable quantile regression for panel data, grid-search optimization:

    Code:
    .  qregpd ln_wage tenure union, id(idcode) fix(year) optimize(grid) min1(0) max1(0.06) intvl1(0.005) min2(0.05)  max2(0.1) intvl2(0.005) instruments(ttl_exp wks_work union)
    Further examples and options can be found in the help file. qregpd can be install via ssc (ssc install qregpd).

    Enjoy! And of course, comments, criticisms, and suggestions are welcome...

    Matt Baker (on behalf of David Powell and Travis Smith)

  • #2
    Dear Mr Matthew,
    I run the command as you wrote above, but there is error: <istmt>: 3499 mm_panels() not found
    What should i do to fix it?

    Comment


    • #3
      Tina --

      Sorry about that - there is in fact a dependency that I did not mention: you need to have the moremata package installed. I believe you can just get this up and running by typing in the command ssc install moremata.

      Hope that helps!

      Matt

      Comment


      • #4
        Dear Mr. Matthew,

        Thank you so so so... much for your help. I solved my problem.

        Best wishes for you!!!

        Tina

        Comment


        • #5
          Dear Mr. Matthew,

          I have a question, hope you help me answer. If i want to run with different quantiles ( 0.1, 0.2, .....) what command I would write?

          Comment


          • #6
            i tried to run this command qregpd RETURN TRADEV BM BETA ME CPI RORR IIP if MV0==1 , id(ID) fix(TIME) quantile(0.5) and the result :
            Quantile Regression for Panel Data (QRPD)
            Number of obs: 1932
            Number of groups: 98
            Min obs per group: 1
            Max obs per group: 28
            ------------------------------------------------------------------------------
            RETURN | Coef. Std. Err. z P>|z| [95% Conf. Interval]
            -------------+----------------------------------------------------------------
            TRADEV | .003668 .0044054 0.83 0.405 -.0049665 .0123025
            BM | -.2104342 .044749 -4.70 0.000 -.2981406 -.1227278
            BETA | .0417297 .0512727 0.81 0.416 -.0587629 .1422223
            ME | -3.58e-15 6.23e-16 -5.74 0.000 -4.80e-15 -2.36e-15
            CPI | .0958528 . . . . .
            RORR | 9.399913 . . . . .
            IIP | -.0040694 . . . . .
            ------------------------------------------------------------------------------
            No excluded instruments - standard QRPD estimation.

            I think there was a problem with my command or my data
            What should i do now?

            Comment


            • #7
              Tina Nguyen are you able to get standard errors when you don't include the 'if MV0==1' condition in the estimation command?

              Comment


              • #8
                Originally posted by Matthew J. Baker View Post
                Tina --

                Sorry about that - there is in fact a dependency that I did not mention: you need to have the moremata package installed. I believe you can just get this up and running by typing in the command ssc install moremata.

                Hope that helps!

                Matt
                Hi, I installed moremata package, but I get the following message:
                <istmt>: 3499 objectiveFunGmm() not found

                Your help is highly appreciated.

                Comment


                • #9
                  Tina Nguyen --

                  Sorry for not responding sooner; were you able to get things working after testing out wbuchanan s good advice? What happens if you run the program without the if MVO==1 command?

                  Best,

                  Matthew J. Baker

                  Comment


                  • #10
                    syed.basher --

                    Could you elaborate just a bit about what is going on? What version of Stata are you running, and what command specifically are you running that produces the error?

                    Best,

                    Matthew J. Baker

                    Comment


                    • #11
                      Matthew J. Baker --

                      I am using Stata 14.1. I am estimating the same model that you posted above. I downloaded the "moremata" package. When I run the model using genqreg with MCMC option, I get the following error: <istmt>: 3499 amcmc() not found.
                      Thank you for your assistance.

                      Comment


                      • #12
                        syed.basher --

                        It looks as though you do not have the amcmc package installed, which is required for any of the Markov-chain-Monte Carlo estimations, as mentioned in the dependencies.

                        Try doing:

                        Code:
                        ssc install amcmc
                        and then run your command and see if that works!

                        Best,

                        Matt

                        Comment


                        • #13
                          Hello Matt,
                          It works now, thanks! Sorry I didn't realize that AMCMC is a required package.
                          Syed

                          Comment


                          • #14
                            Dear syed.basher --

                            Glad it all worked out - let me know if you have further questions or problems!

                            Best,

                            Matthew J. Baker

                            Comment


                            • #15
                              Dear Matthew,

                              Im very happen when received your reply, i changed my command, no problem with this command. But i dont understand why there are difference results when difference running with the same command.
                              You can test this problem with example bellow:
                              Setup
                              . webuse nlswork
                              . qregpd ln_wage tenure union, id(idcode) fix(year) optimize(mcmc) noisy draws(1000) burn(100) arate(.5)

                              Comment

                              Working...
                              X