Announcement

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

  • Graph like this!

    Dear All, How can I can draw a graph like this
    Click image for larger version

Name:	90-50.png
Views:	1
Size:	30.5 KB
ID:	1484392

    which can be found here https://stats.stackexchange.com/ques...ile-regression.
    The line passes A and B is the 90th quantile regression, and I'd like to add a 10th one. Any suggestions? You might want to use
    Code:
    sysuse nlsw88.dta, clear
    
    qreg wage tenure, q(0.1)
    qreg wage tenure, q(0.5)
    qreg wage tenure, q(0.9)
    I especially need the red density curve.
    Ho-Chuan (River) Huang
    Stata 19.0, MP(4)

  • #2
    here we have a similar graph:
    https://www.surveydesign.com.au/tipsgraphs.html
    Can this help?
    Code:
    clear
    sysuse auto
    version 9.2
    keep if foreign
    sort weight
    
    gen weight2 = weight^2
    regress mpg weight weight2
    predict fit
    predict se , stdp
    
    #delimit ;
    twoway sc mpg weight , pstyle(p3) ms(o) ||
    fn weight[3] - 1000 * normden(x, `=fit[3]' , `=se[3]') ,
    range(`=fit[3] -5' `=fit[3] +5') horiz pstyle(p1) ||
    fn `=fit[3]' , range(`=weight[3]' `=weight[3]-1000*normden(0, se[3])')
    pstyle(p1) ||
    fn weight[17] - 1000 * normden(x, `=fit[17]', `=se[17]') ,
    range(`=fit[17]-5' `=fit[17]+5') horiz pstyle(p1) ||
    fn `=fit[17]', range(`=weight[17]' `=weight[17]-1000*normden(0, se[17])')
    pstyle(p1) ||
    fn weight[21] - 1000 * normden(x, `=fit[21]' , `=se[21]') ,
    range(`=fit[21] -7' `=fit[21] +7') horiz pstyle(p1) ||
    fn `=fit[21]', range(`=weight[21]' `=weight[21]-1000*normden(0, se[21])')
    pstyle(p1) ||
    line fit weight
    ,clwidth(*2) legend(off) ytitle(Miles per gallon) xtitle(Weight)
    title("Scatter with Regression Line and Confidence Interval Densities"
    ,size(4.8) margin(t=0 b=1.5) span)
    caption("graph46", box size(vsmall)position(5) ring(10))
    ;
    #delimit cr
    Last edited by Liu Qiang; 18 Feb 2019, 21:23.
    2B or not 2B, that's a question!

    Comment


    • #3
      Dear Liu, Thank you so much for this wonderful graph. It really helps. Since my purpose is to show the quantile regression (fit) at different percentiles (say, at 90th percentile), I wonder if this can be done.
      Ho-Chuan (River) Huang
      Stata 19.0, MP(4)

      Comment


      • #4
        The red lines look like a normal distribution. The whole point of using quantile regression is to not force that distribution on the data. So that does not seem like a particularly sensible way of visualizing the results from a quantile regression. Can you tell us a bit more about the context, and maybe we can come up with a better graph.
        ---------------------------------
        Maarten L. Buis
        University of Konstanz
        Department of history and sociology
        box 40
        78457 Konstanz
        Germany
        http://www.maartenbuis.nl
        ---------------------------------

        Comment


        • #5
          Originally posted by Maarten Buis View Post
          The red lines look like a normal distribution. The whole point of using quantile regression is to not force that distribution on the data. So that does not seem like a particularly sensible way of visualizing the results from a quantile regression. Can you tell us a bit more about the context, and maybe we can come up with a better graph.
          The author mentioned he just randomly selected 200 observations as the sample(unlikely being a normal distribution) and this graph was just for simple explanation on how (un)conditional quantile regression works. I think you can just use another sample for simplicity and easy dissemination,for example nlsw88.dta. I am also eager to learn it but lacking the professional expertise.
          Last edited by Liu Qiang; 19 Feb 2019, 02:53.
          2B or not 2B, that's a question!

          Comment


          • #6
            Dear Maarten, Admittedly, whether it is a normal distribution (I should have mentioned earlier) is not my key concern (but it is probably the easy one). The purpose is to introduce quantile regression tos someone who is not familiar with this interesting econometric technique by visualizing it in a graph like the one above. Using normal distribution (or any other?), it may be easier to draw a OLS (mean) fitted line, along with say, 10th and 90th fitted line. I think this is helpful to novice. However, any other helpful suggestions are also welcome and appreciated. The following graphs are taken the SAS related manual:
            Click image for larger version

Name:	q-density.png
Views:	1
Size:	196.9 KB
ID:	1484444
            Click image for larger version

Name:	q-line.png
Views:	1
Size:	103.9 KB
ID:	1484445
            Ho-Chuan (River) Huang
            Stata 19.0, MP(4)

            Comment

            Working...
            X