Announcement

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

  • Figure for panel quantile regression

    Dear All, I know that we can obtain figures of coefficients estimates of quantile regression by using -grqreg- (please ssc install grqreg) after the -qreg- command. An example is
    Code:
    webuse grunfeld, clear
    
    // please ssc install grqreg
    // without fixed effects
    qreg invest mvalue kstock
    grqreg, ci ols olsci
    Click image for larger version

Name:	grqreg-quantile.png
Views:	3
Size:	98.9 KB
ID:	1464702 Click image for larger version

Name:	grqreg-quantile.png
Views:	3
Size:	98.9 KB
ID:	1464703
    Thanks to Machado, J.A.F. and Santos Silva, J.M.C. (2018), Quantiles via Moments, Journal of Econometrics, forthcoming, now we can use -xtqreg- (please ssc install xtqreg) command to estimate quantile regressions with fixed effects. An example is
    Code:
    xtset company year
    
    // please ssc install xtqreg
    // with fixed effects
    forvalues q = 10(10)90 {
        xtqreg invest mvalue kstock, q(0.`q')
    }
    with results as
    Code:
    . // please ssc install xtqreg
    . // with fixed effects
    . forvalues q = 10(10)90 {
      2.     xtqreg invest mvalue kstock, q(0.`q')
      3. }      
    
    
    
                                  MM-QR regression results
    Number of obs = 200
    .1 Quantile regression
    ------------------------------------------------------------------------------
                 |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
          mvalue |    .084099    .029583     2.84   0.004     .0261174    .1420805
          kstock |   .2646024   .0552066     4.79   0.000     .1563994    .3728054
    ------------------------------------------------------------------------------
    
    
    
    
                                  MM-QR regression results
    Number of obs = 200
    .2 Quantile regression
    ------------------------------------------------------------------------------
                 |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
          mvalue |   .0915338   .0237915     3.85   0.000     .0449033    .1381644
          kstock |   .2775904   .0444176     6.25   0.000     .1905334    .3646474
    ------------------------------------------------------------------------------
    
    
    
    
                                  MM-QR regression results
    Number of obs = 200
    .3 Quantile regression
    ------------------------------------------------------------------------------
                 |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
          mvalue |   .0978504   .0224984     4.35   0.000     .0537543    .1419465
          kstock |   .2886248     .04201     6.87   0.000     .2062867    .3709629
    ------------------------------------------------------------------------------
    
    
    
    
                                  MM-QR regression results
    Number of obs = 200
    .4 Quantile regression
    ------------------------------------------------------------------------------
                 |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
          mvalue |   .1031741   .0244971     4.21   0.000     .0551607    .1511875
          kstock |   .2979249   .0457377     6.51   0.000     .2082807    .3875691
    ------------------------------------------------------------------------------
    
    
    
    
                                  MM-QR regression results
    Number of obs = 200
    .5 Quantile regression
    ------------------------------------------------------------------------------
                 |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
          mvalue |    .112539   .0329018     3.42   0.001     .0480526    .1770254
          kstock |   .3142844   .0614081     5.12   0.000     .1939268     .434642
    ------------------------------------------------------------------------------
    
    
    
    
                                  MM-QR regression results
    Number of obs = 200
    .6 Quantile regression
    ------------------------------------------------------------------------------
                 |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
          mvalue |   .1164492   .0373915     3.11   0.002     .0431631    .1897353
          kstock |   .3211153   .0697806     4.60   0.000     .1843478    .4578827
    ------------------------------------------------------------------------------
    
    
    
    
                                  MM-QR regression results
    Number of obs = 200
    .7 Quantile regression
    ------------------------------------------------------------------------------
                 |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
          mvalue |   .1249394   .0484885     2.58   0.010     .0299037    .2199751
          kstock |   .3359468   .0904895     3.71   0.000     .1585906    .5133029
    ------------------------------------------------------------------------------
    
    
    
    
                                  MM-QR regression results
    Number of obs = 200
    .8 Quantile regression
    ------------------------------------------------------------------------------
                 |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
          mvalue |   .1335321   .0603947     2.21   0.027     .0151606    .2519036
          kstock |   .3509575   .1127063     3.11   0.002     .1300572    .5718578
    ------------------------------------------------------------------------------
    
    
    
    
                                  MM-QR regression results
    Number of obs = 200
    .9 Quantile regression
    ------------------------------------------------------------------------------
                 |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
          mvalue |    .149272   .0832815     1.79   0.073    -.0139567    .3125008
          kstock |   .3784536   .1554208     2.44   0.015     .0738345    .6830727
    ------------------------------------------------------------------------------
    My question is: How can I draw a figure (like the one above) in this situation? Thanks.
    Ho-Chuan (River) Huang
    Stata 17.0, MP(4)

  • #2
    Any update on this?

    Comment


    • #3
      For the moment, this has to be done manually. That is, we need to save the estimates and standard errors for the different quantiles and then use them to construct the plot.

      Best wishes,

      Joao

      Comment


      • #4
        Okay too bad. But will give it a try

        Thanks João!

        Comment


        • #5
          Originally posted by Joao Santos Silva View Post
          For the moment, this has to be done manually. That is, we need to save the estimates and standard errors for the different quantiles and then use them to construct the plot.

          Best wishes,

          Joao
          hi,
          is there any code to plot a graph for quantile panel regression due to compare with ols?

          Comment


          • #6
            I believe FernandoRios created a command for that.

            Comment


            • #7
              Thanks for the tag Joao,
              and yes, you could do it using qregplot command:
              Here an example:
              Code:
              webuse nlswork , clear
              xtqreg ln_wage age nev_mar union wks_ue ttl_exp, i(idcode)
              qregplot, ols olsopt(abs(idcode) robust)

              Comment


              • #8
                Originally posted by FernandoRios View Post
                Thanks for the tag Joao,
                and yes, you could do it using qregplot command:
                Here an example:
                Code:
                webuse nlswork , clear
                xtqreg ln_wage age nev_mar union wks_ue ttl_exp, i(idcode)
                qregplot, ols olsopt(abs(idcode) robust)
                hi,
                i really appreciate you.
                how can i define time in quantile panel and is there any code for 9 decile?

                Comment


                • #9

                  Not really sure what you are asking. For the time component, you can add it as a dummy variable:
                  Code:
                  webuse nlswork , clear
                  xtqreg ln_wage age nev_mar union wks_ue ttl_exp i.time, i(idcode)
                  qregplot, ols olsopt(abs(idcode) robust)
                  ** and if you want to plot specific quantiles , you can do:
                  qregplot, ols olsopt(abs(idcode) robust) q( 10 15 20 (10) 90)
                  Last edited by FernandoRios; 23 Jul 2021, 12:06.

                  Comment


                  • #10
                    Originally posted by FernandoRios View Post
                    Not really sure what you are asking. For the time component, you can add it as a dummy variable:
                    Code:
                    webuse nlswork , clear
                    xtqreg ln_wage age nev_mar union wks_ue ttl_exp i.time, i(idcode)
                    qregplot, ols olsopt(abs(idcode) robust)
                    ** and if you want to plot specific quantiles , you can do:
                    qregplot, ols olsopt(abs(idcode) robust) q( 10 15 20 (10) 90)
                    thank you, how can i specify time here? for example time is year and id is code
                    and i have error that should use quantile between 0 and 1

                    Comment


                    • #11
                      FernandoRios

                      thank you, how can i specify time here? for example time is year and id is code
                      and i have error that should use quantile between 0 and 1

                      Comment


                      • #12
                        FernandoRios @Joao Santos Silva


                        Hello,

                        I want to regress a quantile panel data which section is code and time is year, with also 9 deciles from 10 to 90.

                        Would you help me with the syntax?

                        I also want to plot the panel data quantile and compare it with ols.

                        I really appreciate that.



                        Comment


                        • #13
                          Originally posted by Joao Santos Silva View Post
                          For the moment, this has to be done manually. That is, we need to save the estimates and standard errors for the different quantiles and then use them to construct the plot.

                          Best wishes,

                          Joao
                          Hello,

                          I want to regress a quantile panel data which section is code and time is year, with also 9 deciles from 10 to 90.

                          Would you help me with the syntax?

                          I also want to plot the panel data quantile and compare it with ols.

                          I really appreciate that.

                          Comment


                          • #14
                            Is this waht you wanted?
                            Code:
                            webuse nlswork , clear
                            xtqreg ln_wage age nev_mar union wks_ue ttl_exp i.year, i(idcode)
                            qregplot age nev_mar union wks_ue ttl_exp, ols olsopt(abs(idcode) robust) q(10(10)90) raopt(color(gs14))
                            Click image for larger version

Name:	Graph.png
Views:	1
Size:	98.6 KB
ID:	1620434
                            Last edited by River Huang; 24 Jul 2021, 04:58.
                            Ho-Chuan (River) Huang
                            Stata 17.0, MP(4)

                            Comment


                            • #15
                              Originally posted by River Huang View Post
                              Is this waht you wanted?
                              Code:
                              webuse nlswork , clear
                              xtqreg ln_wage age nev_mar union wks_ue ttl_exp i.year, i(idcode)
                              qregplot age nev_mar union wks_ue ttl_exp, ols olsopt(abs(idcode) robust) q(10(10)90) raopt(color(gs14))
                              [ATTACH=CONFIG]n1620434[/ATTACH]
                              hello,
                              thank you. Is my regression correct?
                              it has shown the years seperately. i want specify years from 1386 to 1396
                              Attached Files

                              Comment

                              Working...
                              X