Announcement

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

  • Questions regarding Quantile Regression combined with fixed effect using xtqreg and mmqreg

    Hi, everyone.

    I am recently curious about using quantile regression model to detect effects from extreme observations.

    So far, I have reviewed many posts and come up with the idea to do quantile regression with a fixed effect.

    However, it seems that the results do not present any information about the R^2 or Within R^2 while I find some packages used in R like rqpd may show the result as well but I am not sure whether it functions correctly because it shares totally different result with those I get using xtqreg and mmqreg in stata.

    First question: Whether my Stata code presented below is incorrect or not? I find that the coefficients are similar in both Stata codes but totally different from that in R.

    bootstrap, cluster(companyid) idcluster(_company) reps(100) seed(1234): xtqreg pb ///
    interest_dev lev_fin size liq_curr roa tangibility i.year if floating_exposure == 1, i(_company) ls q(0.25)



    while

    mmqreg qt ///
    interest_dev $xlist i.year if floating_exposure == 1, q(25) abs(_company)
    Click image for larger version

Name:	Quantile mmqreg.png
Views:	1
Size:	756.1 KB
ID:	1713064




    The R code is (if you are curious about):

    fit.rqpd <- rqpd(QT ~ Interest_DEV + Liq + Curr + Lev_fin + ROA + Size + Tangibility |
    Company, data = pdata, panel(lambda = 5, taus=c(0.1, 0.25, 0.5, 0.75, 0.9), tauw=rep(1/5, 5)), method = "pfe")
    Click image for larger version

Name:	image_31025.png
Views:	1
Size:	462.1 KB
ID:	1713059







    Second question: Whether it is possible to get R^2 or Within R^2 if I use xtqreg and mmqreg in Stata as my professor is curious about R^2 to see how well it fits.
    Last edited by Jun He; 10 May 2023, 02:12.

  • #2
    Dear Jun He

    First of all, please note that both xrqreg and mmqreg implement the estimator proposed by

    Machado, J.A.F. and Santos Silva, J.M.C. (2019), Quantiles via Moments, Journal of Econometrics, 213(1), pp. 145–173.

    and therefore their results should be essentially the same. In contrast, rqpd implements a different FE estimator, which was suggested by

    Koenker, R. (2004). Quantile Regression for Longitudinal Data, Journal of Multivariate Analysis. 91-1. p. 74--89.

    Please see the original papers to understand the difference between the two approaches, but in a nutshell Koenker's estimator imposes that the fixed effects have the same impact in all quantiles, while the estimator based on moments does not impose this restriction, but assumes a location-scale model.

    Finally, the R2 does not make much sense in the context of quantile regression that is why it is not reported in xrqreg and mmqreg. If you want to compute the R2, you can simply compute it as the square of the correlation between the fitted values and the dependent variable.

    Best wishes,

    Joao

    Comment


    • #3
      Dear Joao Santos Silva

      Thanks for your explicit explanation of the differences between the two types of codes and for your good references.

      I will read the papers thoroughly. However, it seems that the estimator proposed by Machado & Santos caters to my requirement more.

      I hope you have a nice day

      Regards.

      Comment


      • #4
        Dear Joao Santos Silva,

        I am new to quantile regression - I am using the following mmqreg command to estimate my quantile coefficients:

        mmqreg lnSPREAD ROA ICR GROWTH LEV ESG lnMKTCAP MATURITY_IN_YEARS RATING lnISSUESIZE i.t, abs(id) cluster(id) q(10 20 30 40 50 60 70 80 90)

        I have a few questions:

        1. I have data on 64 bonds for 6 years i.e. my N is larger than T. Is the mmqreg command suitable for data with large N and relatively small T?
        2. I have specified time dummies for time fixed effects - is that the correct way to control for time fixed effects? Alternatively, can specifying abs(id t) to absorb time FEs along with bond FEs control for year-specific effects? Which way is more appropriate?
        3. What are the advantages of using mmqreg over Koenker's (2004) method?

        Thank you in advance!

        Kind regards,
        Rupali

        Comment


        • #5
          Hi Rubali
          1. I think your panel is too short to use mmqreg or xtqreg. The coefficients may be very biased. One could apply the Jacknife correction suggested in Joao's paper, but that is a manual implementation. (not too difficult tho)
          2. you can "add" time fixed effects both ways. THey are equivalent. In fact, if for some reason they produce different estimates, let me know. It could be a sign of multicolinearity with your variables, or a bug on my end. (mmqreg)
          3. Koenker implementation is more flexible for control heterogeneity, but imposes homogeneity on the fixed effects. mmqreg/xtqreg imposes restrictions on the coefficients of controls but allows fixed effects to have an heterogenous effect on conditional quantile of the outcome.


          Best wishes
          Fernando

          Comment


          • #6
            Dear FernandoRios,

            Thank you very much for your response!

            I understand why the mmqreg method might yield biased estimates.

            I have a general question (not related to the mmqreg command) but it would be very helpful for me if you could guide me on this - I wanted to understand if dummy variables can be used to control for fixed effects in quantile regression in general? I ask this because effects are nonadditive in quantile regression. Also, are there any specific conditions that need to be met for dummy variables to successfully control for fixed effects?

            Kind regards,
            Rupali

            Comment


            • #7
              Roughly...when using Quantile regression via moments (mmqreg or xtqreg) you need around 20+ observations within each fixed effect. For example 20+ period in panel.
              This number is just a rule of thumb. Not a hard rule.

              If you use standard QREG you may need even more observations per Fixed effect. It could actually be an interesting exercise (if it has not been done before) to check how many observations one would really need to reduce the impact of the bias.

              Again, these are my observations, not hard rules.

              Comment


              • #8
                Dear FernandoRios,

                Thank you very much for your help!

                I tried implementing the jackknife technique mentioned in Joao's paper. Following is my code and the results:


                Code:
                 .bs, cluster(id) rep(20): xtqreg lnSPREAD ESG MATURITY_IN_YEARS RATING lnISSUESIZE ROA    ICR    GROWTH    LEV    lnMKTCAP    i.t
                (running xtqreg on estimation sample)
                WARNING: 1.9900498% of the fitted values of the scale function are not positive
                
                Bootstrap replications (20): .........10.........20 done
                
                Bootstrap results                                          Number of obs = 402
                Replications  =  20
                
                (Replications based on 67 clusters in id)
                
                  
                Observed Bootstrap Normal based
                lnSPREAD coefficient std. err. z P>z [95% conf. interval]
                ESG 0.1042956 0.0347165 3 0.003 0.0362525 0.1723386
                MATURITY_IN_YEARS 0 (omitted)
                RATING 0 (omitted)
                lnISSUESIZE 0 (omitted)
                ROA -0.0280936 0.0052645 -5.34 0 -0.0384119 -0.0177754
                ICR 0.0120381 0.0040686 2.96 0.003 0.0040639 0.0200123
                GROWTH -0.0037824 0.0029164 -1.3 0.195 -0.0094984 0.0019335
                LEV 0.0127927 0.0046965 2.72 0.006 0.0035877 0.0219976
                lnMKTCAP -0.0762047 0.0286668 -2.66 0.008 -0.1323905 -0.0200188
                t
                2 0.5513821 0.0278471 19.8 0 0.4968027 0.6059614
                3 0.0436829 0.055554 0.79 0.432 -0.0652009 0.1525667
                4 -0.0958948 0.0707094 -1.36 0.175 -0.2344827 0.0426932
                5 -0.1909287 0.075549 -2.53 0.011 -0.339002 -0.0428553
                6 0.1460688 0.0678321 2.15 0.031 0.0131204 0.2790172
                mat V=e(V) . matrix b=e(b_location) . matrix g=e(b_scale) . matrix Q50=e(q) . scalar N=e(N) . . xtqreg lnSPREAD ESG MATURITY_IN_YEARS RATING lnISSUESIZE ROA ICR GROWTH LEV lnMKTCAP i.t if s==0 MM-QR regression results Number of obs = 199 WARNING: 2.5125628% of the fitted values of the scale function are not positive .5 Quantile regression
                Coefficient Std. err. z P>z [95% conf. interval]
                ESG 0.2515409 0.0613034 4.1 0 0.1313885 0.3716933
                MATURITY_IN_YEARS 0 (omitted)
                RATING 0 (omitted)
                lnISSUESIZE 0 35103.32 0 1 -68801.24 68801.24
                ROA -0.0150663 0.0106696 -1.41 0.158 -0.0359782 0.0058457
                ICR 0.0153956 0.0057658 2.67 0.008 0.0040948 0.0266963
                GROWTH -0.0096028 0.0037398 -2.57 0.01 -0.0169328 -0.0022729
                LEV 0.0234749 0.0058527 4.01 0 0.0120038 0.0349461
                lnMKTCAP -0.1035034 0.0791106 -1.31 0.191 -0.2585574 0.0515505
                t
                2 0.5683364 0.0745813 7.62 0 0.4221596 0.7145131
                3 -0.1054839 0.0995585 -1.06 0.289 -0.3006149 0.0896472
                4 -0.2697122 0.120996 -2.23 0.026 -0.50686 -0.0325644
                5 -0.3852656 0.1376914 -2.8 0.005 -0.6551357 -0.1153954
                6 0.0487684 0.1160295 0.42 0.674 -0.1786452 0.2761819
                scalar N0=e(N) . matrix Q050=e(q) . matrix g0=e(b_scale) . . xtqreg lnSPREAD ESG MATURITY_IN_YEARS RATING lnISSUESIZE ROA ICR GROWTH LEV lnMKTCAP i.t if s==1 MM-QR regression results Number of obs = 203 WARNING: 5.4187192% of the fitted values of the scale function are not positive .5 Quantile regression
                Coefficient Std. err. z P>z [95% conf. interval]
                ESG 0.1105789 0.0730302 1.51 0.13 -0.0325577 0.2537156
                MATURITY_IN_YEARS 0 (omitted)
                RATING 0 (omitted)
                lnISSUESIZE 0 41616.34 0 1 -81566.53 81566.53
                ROA -0.0332894 0.012659 -2.63 0.009 -0.0581005 -0.0084782
                ICR 0.0057916 0.0102622 0.56 0.573 -0.0143219 0.0259051
                GROWTH 0.0003493 0.0021738 0.16 0.872 -0.0039112 0.0046098
                LEV 0.0030016 0.0069255 0.43 0.665 -0.010572 0.0165752
                lnMKTCAP -0.0505127 0.0810601 -0.62 0.533 -0.2093876 0.1083621
                t
                2 0.4245002 0.1167092 3.64 0 0.1957545 0.653246
                3 0.0396073 0.1040884 0.38 0.704 -0.1644022 0.2436168
                4 -0.0852346 0.1371361 -0.62 0.534 -0.3540164 0.1835471
                5 -0.21846 0.1430045 -1.53 0.127 -0.4987435 0.0618236
                6 0.0738827 0.1550519 0.48 0.634 -0.2300134 0.3777788
                scalar N1=e(N) . matrix Q150=e(q) . matrix g1=e(b_scale) . mat bjk=b+(2*g-g1*(N1/N)-g0*(N0/N))*(2*Q50-Q150*(N1/N)-Q050*(N0/N)) . ereturn post bjk V . ereturn display
                Coefficient Std. err. z P>z [95% conf. interval]
                ESG 0.097211 0.0347165 2.8 0.005 0.0291679 0.1652541
                MATURITY_IN_YEARS 0 (omitted)
                RATING 0 (omitted)
                lnISSUESIZE 0 (omitted)
                ROA -0.0281969 0.0052645 -5.36 0 -0.0385151 -0.0178786
                ICR 0.0127317 0.0040686 3.13 0.002 0.0047574 0.0207059
                GROWTH -0.004097 0.0029164 -1.4 0.16 -0.0098129 0.001619
                LEV 0.0134528 0.0046965 2.86 0.004 0.0042478 0.0226577
                lnMKTCAP -0.0741985 0.0286668 -2.59 0.01 -0.1303844 -0.0180127
                t
                2 0.5482974 0.0278471 19.69 0 0.493718 0.6028767
                3 0.0493426 0.055554 0.89 0.374 -0.0595412 0.1582265
                4 -0.0916401 0.0707094 -1.3 0.195 -0.230228 0.0469478
                5 -0.1892661 0.075549 -2.51 0.012 -0.3373394 -0.0411927
                6 0.1589342 0.0678321 2.34 0.019 0.0259857 0.2918826
                . end of do-file
                I have the following questions about the results:

                1. Does the warning 'WARNING: 1.9900498% of the fitted values of the scale function are not positive' indicate some problem with my data/suitability of the code?

                2. I have 3 time-invariant variables namely, MATURITY-IN-YEARS, RATING, and, lnISSUESIZE - the first 2 drop (as expected) in the first and the second table, but the 3rd one doesn't. However, all the 3 drop in the last table. Is there any explanation for this observation?

                3. In the code you provide (which I have modified according to my data), you mention 'xtset idcode' to specify that you are dealing with panel data - would specifying panel data as 'xtset idcode t' make a difference?

                4. Does using the Jackknife technique eliminate the bias caused by a small T completely?

                5. Finally, if I estimate the model for multiple quantiles, do you have a code handy that combines the final result?

                Looking forward to your response,

                Kind regards,
                ​​​​​​​Rupali

                Comment


                • #9
                  1. The warning refers to the assumtions of nonegative predicted Sigma. Not an issue perse, just something to be noticed
                  2. Exclude the time invariant variables by hand to avoid this
                  3. No, xtset idcode is sufficient. the time variable is not used for xtqreg (nor mmqreg)
                  4. JK does not eliminate the bias completely. (and does it only in multiple regression settings. With one case alone, may be better or worse than not using it)
                  5. No. usually built code like that as needed

                  Comment


                  • #10
                    Dear FernandoRios,

                    Thanks a lot for clearing up all my doubts - your responses are very helpful!

                    Kind regards,
                    Rupali

                    Comment


                    • #11
                      Dear FernandoRios,

                      I have one final question - if I run the analysis for each quantile separately (using your code), the resulting matrices should be correct right? i.e. I do not need to do it all in one single code? I am asking because I am struggling to amend the final part of the command where you combine the results of the entire sample and the sub-samples.

                      Thank you again for taking the time to answer my queries!

                      Kind regards,
                      Rupali

                      Comment


                      • #12
                        Dear Joao Santos Silva,

                        I was reading your paper (Quantile via Moments, 2019) and I have the following query regarding the model:

                        I understand from the model specification in (3) that the heterogeneity in the quantile process is due to the existence of a scale function that depends on a vector of regressors (X or Z, according to the notation in the paper). In Stata, I just introduce our set of regressors X for the conditional quantile process so can I assert that these regressors also affect the scale process? I am saying this because I find heterogeneity in the slope coefficient beta across taus so according to your model, this heterogeneity is due to the presence of a scale function that depends on X. Otherwise, the beta(tau) function should be constant. Is our understanding correct?

                        Any insights or guidance you could offer on this matter would be very helpful!

                        Many thanks in advance.

                        Kind regards,
                        Rupali

                        Comment


                        • #13
                          Dear Rupali Vashisht,

                          Your understanding is correct. If you use the ls option, you will see the location and scale estimates.

                          Best wishes,

                          Joao

                          Comment


                          • #14
                            Dear Joao Santos Silva,

                            Thank you very much for your response.

                            I also wanted to clarify if the model is constructed in a way that it imposes monotonicity of betas? I am asking this because I am getting parameters that are stricty increasing/decreasing with successive quantiles.

                            Thank you again for taking the time to answer my queries!

                            Kind regards,
                            Rupali

                            Comment


                            • #15
                              Dear Rupali Vashisht,

                              Yes, that is the case and it ensures that the quantiles do not cross.

                              Best wishes,

                              Joao

                              Comment

                              Working...
                              X