Announcement

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

  • New to SSC mmqreg - Quantile regressions via Method of Moments

    Dear all,
    Thanks to Prof Baum, a new command is now available on ssc. This new command, named mmqreg, allows for the estimation of quantile regressions using the method proposed in :
    Machado, J.A.F. and Santos Silva, J.M.C. (2019), Quantiles via Moments, Journal of Econometrics, 213(1), pp. 145-173.
    In contrast with -xtqreg- (also from ssc), this new command allows :
    1. Implement this methodology when no fixed effects are specified, so you can directly compare them with the output of -qreg-.
    2. Automatically reports the Scale, location and quantile regression in a single regression output. This may be useful for testing simultaneous quantile regressions (using bootstrap).
    3. It allows for the estimation of quantile regressions with multiple fixed effects, based on the demeaning strategy used in commands like -regxfe-, -reghdfe-, -ppmlhdfe-.
    This command requires -hdfe- and -ftools-. So make sure they are installed before trying the examples in the helpfile or the do file that comes with the command.
    Thank you
    Fernando

  • #2
    Hi FernandoRios

    Thank you for advertising this new command. It is very interesting and intuitive in its use.

    I have a few questions:
    • how does the underlying estimator behave in presence of a large number of null values in the dependent variable? I run the sample code and dataset, where the number of null values in the dependent variable is barely 2 out of 28500+ observation. I would like to use a HDFE-friendly estimator, but my data are heavily zero-inflated. I think that a censored quantile estimator would work, but as far as I know, no censored quantile command supports HDFE yet.
    If this command is not suited for settings with many null values at the dependent variable:
    • what would be the bias in using this command?
    • are you aware of commands that deal with such issue?
    I am sorry if some of the questions might have been answered simply reading the original paper from Professor Joao Santos Silva but I have no access to it, nor to your mimeo paper.

    Best,

    Filippo

    Comment


    • #3
      Dear Filippo Santi,

      If you send me an email, I'll be pleases to send you the paper. Anyway, like most quantile regression estimators, this method assumes that the dependent variable is continuous. If you tell us more about your dependent variable, we may be able to provide further help.

      Best wishes,

      Joao

      Comment


      • #4
        Hi Filippo
        Unfortunately, I dont have answer for your questions.
        The way this estimator works is that you first estimate an OLS to obtain the location coefficients, and an auxialiry regression to estimate the scale coefficients (effectively modeling heteroskedasticity)
        Neither of these steps would handle censored data.
        So, for your first question:
        - what would be the bias in using this command?
        I would expect the same kind of bias you would find when comparing OLS with Tobit models (or other type of censored regressions models)
        - are you aware of commands that deal with such issue?
        No, I know there are afew that deal with censored quantile regression, but i dont think they deal with Multiple Fixed effects.

        Something I did read, at least for the case of a single HDFE, is to use a Mundlack estimation device. But I do not know if there are papers already working with this strategy.

        HTH
        Fernando

        Comment


        • #5
          Thank you both.

          To reply (in order):

          Prof Joao Santos Silva : I am fitting a gravity model of FDI. So far, i used PPML with HDFE. I have been suggested to look for more robust estimators (I know how this thing might sound to you...) such as quantile regression. However, I have two problems in doing this: on the one side, I cannot give up on fixed effects, as they control for multilateral resistance; on the other side, I am dealing with a substantial share of null flows, which makes standard quantile regression unfeasible. I'm sorry for asking this, but: what is your take on this? I will also catch the opportunity you are offering me, and I will send you an email for the paper. Thank you very much!


          Prof FernandoRios : thank you, you have been very clear. Unfortunately, I have three-way HDFE, so even the Mundlak approach you mentioned would not fit.

          Comment


          • #6
            Dear Filippo Santi,

            Thanks for the clarification. As you suspected, I do not see any reason to try other estimators, but certainly standard quantile regression will not work in your case because you have a mass-point at zero and because of the fixed effects. Have a look at the command fqreg and at the reference in the help file. That method may deal with the zeros, but the fixed effects are still a potential problem.

            Best wishes,

            Joao

            Comment


            • #7
              @FernandoRios Dear FernandoRios, Can you show me how to explain the scale and location coefficients in my model?

              Best
              Raymond
              Best regards.

              Raymond Zhang
              Stata 17.0,MP

              Comment


              • #8
                Hi Raymond,
                Not really sure what your question is. I suggest you to start by reading the original paper that introduces xtqreg or at least the presentation that Prof. Santos Silva did couple of years ago at the Stata conference:
                https://www.stata.com/meeting/uk19/s...k19_santos.pdf

                The bottom line:
                When using quantile regression via the method of moments, you are basically estimating the following model:
                \[ y = \beta X + \theta X \times \varepsilon \]
                The location effect is given by "beta", because that is how much the "conditional mean of y (E(y|X)" will change when X changes.
                The scale effect is given by "theta", because that measures how much distribution will expand away or contract closer to the conditional mean. If Theta is positive, then an increase in X will increase the variance of the error.

                Finally, when you combine both the location and scale effect is that you can obtain an estimate for the conditional quantile coefficient:
                \[ q_\tau(y|X) = (\beta+\theta*F_\varepsilon^{-1} (\tau))*x \]

                Where F^-1(\tau) is the qth quantile of the error "varepsilon".

                Hope this helps
                F
                Last edited by FernandoRios; 09 Feb 2021, 06:52.

                Comment


                • #9
                  @FernandoRios Thank you four you detailed reply.I have learned a lot.

                  Best
                  Raymond
                  Last edited by Raymond Zhang; 09 Feb 2021, 09:14.
                  Best regards.

                  Raymond Zhang
                  Stata 17.0,MP

                  Comment


                  • #10
                    @FernandoRios
                    Dear FernandoRios,Thank you for your kind help.Many thanks again.


                    Best
                    Raymond
                    Last edited by Raymond Zhang; 09 Feb 2021, 09:13.
                    Best regards.

                    Raymond Zhang
                    Stata 17.0,MP

                    Comment


                    • #11
                      That does sound like a typo.

                      Comment


                      • #12
                        @FernandoRios Dear Pro FernandoRios,How can I get cluster robust standard error from --xtqreg--?

                        Many thanks in advance.

                        Best
                        Raymond
                        Best regards.

                        Raymond Zhang
                        Stata 17.0,MP

                        Comment


                        • #13
                          you cant,
                          you could do bootstrap. mmqreg does include an experimental "robust" option too.

                          Comment


                          • #14
                            FernandoRios Dear FernandoRios,I run both --xtqreg--and --mmqreg--,but why are the standard errors so different?
                            Code:
                            webuse nlswork, clear        
                             mmqreg ln_w age c.age#c.age ttl_exp c.ttl_exp#c.ttl_exp tenure c.tenure#c.tenure not_smsa
                            > south, abs(idcode)
                            WARNING: some fitted values of the scale function are negative
                            Consider using a different model specification
                            The command will proceed using the Absolute value of these observations
                            MM-qreg Estimator
                            Quantile:  50
                            -------------------------------------------------------------------------------------
                                        ln_wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
                            --------------------+----------------------------------------------------------------
                            location            |
                                            age |      0.036      0.017     2.07   0.039        0.002       0.070
                                                |
                                    c.age#c.age |     -0.001      0.000    -2.64   0.008       -0.001      -0.000
                                                |
                                        ttl_exp |      0.033      0.015     2.25   0.024        0.004       0.063
                                                |
                            c.ttl_exp#c.ttl_exp |      0.000      0.001     0.34   0.736       -0.001       0.001
                                                |
                                         tenure |      0.036      0.009     4.03   0.000        0.018       0.053
                                                |
                              c.tenure#c.tenure |     -0.002      0.001    -3.36   0.001       -0.003      -0.001
                                                |
                                       not_smsa |     -0.089      0.048    -1.84   0.065       -0.184       0.006
                                          south |     -0.061      0.057    -1.07   0.283       -0.171       0.050
                                          _cons |      1.037      0.249     4.17   0.000        0.550       1.525
                            --------------------+----------------------------------------------------------------
                            scale               |
                                            age |     -0.010      0.017    -0.61   0.541       -0.043       0.022
                                                |
                                    c.age#c.age |      0.000      0.000     0.83   0.405       -0.000       0.001
                                                |
                                        ttl_exp |     -0.008      0.014    -0.57   0.571       -0.036       0.020
                                                |
                            c.ttl_exp#c.ttl_exp |      0.000      0.001     0.67   0.504       -0.001       0.002
                                                |
                                         tenure |     -0.010      0.008    -1.19   0.234       -0.027       0.007
                                                |
                              c.tenure#c.tenure |      0.000      0.001     0.65   0.515       -0.001       0.001
                                                |
                                       not_smsa |     -0.005      0.046    -0.12   0.908       -0.096       0.085
                                          south |     -0.007      0.054    -0.13   0.899       -0.112       0.099
                                          _cons |      0.337      0.237     1.42   0.155       -0.128       0.802
                            --------------------+----------------------------------------------------------------
                            qtile               |
                                            age |      0.035      0.018     1.92   0.055       -0.001       0.071
                                                |
                                    c.age#c.age |     -0.001      0.000    -2.45   0.014       -0.001      -0.000
                                                |
                                        ttl_exp |      0.033      0.016     2.10   0.036        0.002       0.064
                                                |
                            c.ttl_exp#c.ttl_exp |      0.000      0.001     0.36   0.719       -0.001       0.002
                                                |
                                         tenure |      0.035      0.009     3.75   0.000        0.017       0.053
                                                |
                              c.tenure#c.tenure |     -0.002      0.001    -3.14   0.002       -0.003      -0.001
                                                |
                                       not_smsa |     -0.089      0.051    -1.75   0.080       -0.189       0.011
                                          south |     -0.061      0.060    -1.02   0.307       -0.178       0.056
                                          _cons |      1.060      0.263     4.04   0.000        0.546       1.575
                            -------------------------------------------------------------------------------------
                            
                            .   xtqreg ln_w age c.age#c.age ttl_exp c.ttl_exp#c.ttl_exp tenure  ///
                            >             c.tenure#c.tenure not_smsa south, i(idcode) ls
                            
                            
                            
                                                          MM-QR regression results
                            Number of obs = 28093
                            
                                                                                       Location parameters
                                                                (Std. Err. adjusted for 4,699 clusters in idcode)
                            -------------------------------------------------------------------------------------
                                                |               Robust
                                        ln_wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
                            --------------------+----------------------------------------------------------------
                                            age |      0.036      0.005     6.87   0.000        0.026       0.046
                                                |
                                    c.age#c.age |     -0.001      0.000    -8.56   0.000       -0.001      -0.001
                                                |
                                        ttl_exp |      0.033      0.004     8.22   0.000        0.025       0.041
                                                |
                            c.ttl_exp#c.ttl_exp |      0.000      0.000     1.23   0.220       -0.000       0.001
                                                |
                                         tenure |      0.036      0.002    14.49   0.000        0.031       0.041
                                                |
                              c.tenure#c.tenure |     -0.002      0.000   -11.62   0.000       -0.002      -0.002
                                                |
                                       not_smsa |     -0.089      0.014    -6.47   0.000       -0.116      -0.062
                                          south |     -0.061      0.016    -3.71   0.000       -0.093      -0.029
                                          _cons |      1.037      0.074    14.02   0.000        0.892       1.182
                            -------------------------------------------------------------------------------------
                                                                                          Scale parameters
                                                                (Std. Err. adjusted for 4,699 clusters in idcode)
                            -------------------------------------------------------------------------------------
                                                |               Robust
                                                |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
                            --------------------+----------------------------------------------------------------
                                            age |     -0.010      0.003    -3.99   0.000       -0.015      -0.005
                                                |
                                    c.age#c.age |      0.000      0.000     5.30   0.000        0.000       0.000
                                                |
                                        ttl_exp |     -0.008      0.002    -3.97   0.000       -0.012      -0.004
                                                |
                            c.ttl_exp#c.ttl_exp |      0.000      0.000     4.43   0.000        0.000       0.001
                                                |
                                         tenure |     -0.010      0.001    -8.22   0.000       -0.012      -0.008
                                                |
                              c.tenure#c.tenure |      0.000      0.000     4.19   0.000        0.000       0.001
                                                |
                                       not_smsa |     -0.005      0.007    -0.75   0.451       -0.019       0.009
                                          south |     -0.007      0.008    -0.86   0.392       -0.022       0.009
                                          _cons |      0.333      0.036     9.34   0.000        0.263       0.403
                            -------------------------------------------------------------------------------------
                            
                            WARNING: some fitted values of the scale function are negative
                            .5 Quantile regression
                            -------------------------------------------------------------------------------------
                                                |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
                            --------------------+----------------------------------------------------------------
                                            age |      0.035      0.016     2.17   0.030        0.003       0.067
                                                |
                                    c.age#c.age |     -0.001      0.000    -2.77   0.006       -0.001      -0.000
                                                |
                                        ttl_exp |      0.033      0.014     2.38   0.017        0.006       0.060
                                                |
                            c.ttl_exp#c.ttl_exp |      0.000      0.001     0.41   0.681       -0.001       0.001
                                                |
                                         tenure |      0.035      0.008     4.25   0.000        0.019       0.051
                                                |
                              c.tenure#c.tenure |     -0.002      0.001    -3.56   0.000       -0.003      -0.001
                                                |
                                       not_smsa |     -0.089      0.045    -1.99   0.047       -0.178      -0.001
                                          south |     -0.061      0.053    -1.16   0.246       -0.164       0.042
                            -------------------------------------------------------------------------------------
                            Last edited by Raymond Zhang; 11 Feb 2021, 10:24.
                            Best regards.

                            Raymond Zhang
                            Stata 17.0,MP

                            Comment


                            • #15
                              I ll check what is going on with the standard errors for the last component (the quantile regression), however, the difference with the other two (location and scale regressions) is because im estimating their standard errors jointly. whereas in xtqreg standard errors are obtained using xtreg.
                              for example:

                              Code:
                              webuse nlswork, clear        
                              bysort id:gen n=_N
                              drop if n<=2
                              *compare this
                               mmqreg ln_w age c.age#c.age ttl_exp c.ttl_exp#c.ttl_exp tenure c.tenure#c.tenure not_smsa south, abs(idcode) robust dfadj
                               reghdfe ln_w age c.age#c.age ttl_exp c.ttl_exp#c.ttl_exp tenure c.tenure#c.tenure not_smsa south,abs(idcode) vce(robust)
                              *to what xtqreg does: 
                               xtqreg ln_w age c.age#c.age ttl_exp c.ttl_exp#c.ttl_exp tenure c.tenure#c.tenure not_smsa south, i(idcode) ls
                               xtreg ln_w age c.age#c.age ttl_exp c.ttl_exp#c.ttl_exp tenure c.tenure#c.tenure not_smsa south, fe vce(robust)

                              Comment

                              Working...
                              X