Announcement

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

  • Shading AUC on ROC curve?

    Is it possible to shade with color the area under the curve on an ROC curve in stata? I can't find any resources documenting this. If it is possible, could you please help me out with some code? I'm currently just running a basic roctab.

    Much appreciated!

  • #2
    There might be an easier way, but you could modify the source code for roctab to accomplish what you want (just save it under a different name of course). For example, changing

    Code:
    connected `sens' `spec'
    to

    Code:
    rarea `sens' `spec' `spec'
    Example

    Code:
    webuse hanley, clear
    my_roctab disease rating, graph

    Attached Files
    Last edited by Justin Niakamal; 11 Mar 2021, 22:55.

    Comment


    • #3
      Thank you!

      Comment


      • #4
        Hey Justin, I am little bit confused. Can you explain further how to change the codes and generate my_roctab. Thanks

        Comment


        • #5
          Code:
          findfile roctab.ado
          doedit "`r(fn)'"
          edit and save as "my_roctab.ado".

          Comment


          • #6
            @ Andrew : Is there a simple code I can just run

            Comment


            • #7
              As it is an official command, it accepts twoway options:

              Code:
              webuse hanley, clear
              roctab disease rating, graph plotopts(recast(area))
              Click image for larger version

Name:	Graph.png
Views:	1
Size:	39.9 KB
ID:	1661101

              Comment


              • #8
                Thank you Andrew. This is really helpful. Do you know how I can remove the shade underneath the reference line that runs through the middle? Thanks again.

                Comment


                • #9
                  You can try specifying options for the reference line. But that will require that you turn off the grid lines.

                  Code:
                  webuse hanley, clear
                  roctab disease rating, graph plotopts(recast(area) ///
                  xlab(,nogrid) ylab(,nogrid) lc(white))  ///
                  rlopts(recast(area) color(white) lc(white))
                  Click image for larger version

Name:	Graph.png
Views:	1
Size:	38.0 KB
ID:	1661116

                  Comment


                  • #10
                    Thank you so so much Andrew. One more last time. What if I want to plot more than on graph on the curve using the above information. I tried it but it was saying the plot option not allowed.
                    Thanks again Andrew.

                    Comment


                    • #11
                      I mean comparing several AUC

                      Comment


                      • #12
                        Nice example in #9, Andrew Musau. It took me a while to find how to do it, but I would add fintens(inten30) to lighten up that shaded area a bit. ;-)

                        Code:
                        roctab disease rating, graph plotopts(recast(area) fintens(inten30) ///
                        xlab(,nogrid) ylab(,nogrid) lc(white))  ///
                        rlopts(recast(area) color(white) lc(white))
                        --
                        Bruce Weaver
                        Email: [email protected]
                        Version: Stata/MP 18.5 (Windows)

                        Comment


                        • #13
                          Hey Bruce. Do you know how I can add more variables to compare more than one AUC on the same graph with different shades of color? Thanks

                          Comment


                          • #14
                            Hi Senema. No, I don't know how to do that off the top of my head.
                            --
                            Bruce Weaver
                            Email: [email protected]
                            Version: Stata/MP 18.5 (Windows)

                            Comment


                            • #15
                              Originally posted by Bruce Weaver View Post
                              Nice example in #9, Andrew Musau. It took me a while to find how to do it, but I would add fintens(inten30) to lighten up that shaded area a bit. ;-)
                              Thanks Bruce, it looks much nicer that way.


                              Thank you so so much Andrew. One more last time. What if I want to plot more than one graph on the curve using the above information. I tried it but it was saying the plot option not allowed.
                              Thanks again Andrew.
                              You can include an additional twoway graph using -addplot()-, but roctab does not allow you to plot multiple overlaid ROC curves. If you need to do that, you are probably better off extracting the data and switching to twoway. Instead of asking one thing after another, I would suggest that you start a new thread and ask a question relating to your exact problem.

                              Comment

                              Working...
                              X