Announcement

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

  • ROC curves line too thick to distinguish clearly

    Dear all,

    I am doing ROC curves with the following code in STATA 18. However, the lines are too thick to clearly distinguish the curves. I wanted to use something like vthin but I get a mismatch error. I imagine this is very simple. Could someone help me? thank you so much! appreciate your help!

    roccomp declineyesno p_basicmodel p_secondmodel, graph summary title("Courbes ROC : Basic model vs secondmodel") legend(order(1 "basic model" 2 "second model")) xlabel(0(0.2)1) ylabel(0(0.2)1) xtitle("1 - Spécificité (Faux positifs)") ytitle("Sensibilité (Vrais positifs)")

    Best,
    Pierre

  • #2
    You can access the rendition of each of the lines as such:

    Code:
    roccomp declineyesno p_basicmodel p_secondmodel, graph summary ///
        title("Courbes ROC : Basic model vs secondmodel") legend(order(1 "basic model" 2 "second model")) ///
        xlabel(0(0.2)1) ylabel(0(0.2)1) xtitle("1 - Spécificité (Faux positifs)") ytitle("Sensibilité (Vrais positifs)") ///
        plot1opts(lwidth(vthin)) plot2opts(lwidth(vthin))


    Best wishes

    (Stata 16.1 MP)

    Comment


    • #3
      Thank you so much, Felix!

      Can I automatically report AUC from the 2 models in the legend? If I do roccomp declineyesno p_basicmodel p_secondmodel, graph summary I get it but with other stuff p basic model roc area and the number and when I try to customize the legend I can't retrieve the AUC automatically estimated. Obviously, I can add it manually in the legend code but I would like to entirely automatize the process. Any idea? thank you agin so much.
      roccomp declineyesno p_basicmodel p_secondmodel, graph summary /// title("Courbes ROC : Basic model vs secondmodel") legend(order(1 "basic model" 2 "second model")) /// xlabel(0(0.2)1) ylabel(0(0.2)1) xtitle("1 - Spécificité (Faux positifs)") ytitle("Sensibilité (Vrais positifs)") /// plot1opts(lwidth(vthin)) plot2opts(lwidth(vthin)) best wishes, Pierre

      Comment


      • #4
        As far as I see, roccomp doe not store the AUC values. One option is to omit the legend(order(...)) option as this should then automatically display the AUC values there. Otherwise, you can compute the AUC values manually as such...


        Code:
        logit declineyesno p_basicmodel
        lroc
        local auc1 = round(r(area), 0.001)
        logit declineyesno p_secondmodel
        lroc
        local auc2 = round(r(area), 0.001)
        
        roccomp status p_basicmodel p_secondmodel, graph legend(order(1 "Name 1: `auc1'" 2 "Name 2: `auc2'"))
        Maybe someone else has a more elegant idea.

        Best wishes

        (Stata 16.1 MP)

        Comment


        • #5
          Rounding to say 3 decimal places may seem like a numeric operation, but it's better thought of as a string operation in which certain characters are ignored.


          Code:
          . sysuse auto, clear
          (1978 automobile data)
          
          . logit foreign mpg
          
          Iteration 0:  Log likelihood =  -45.03321  
          Iteration 1:  Log likelihood = -39.380959  
          Iteration 2:  Log likelihood = -39.288802  
          Iteration 3:  Log likelihood =  -39.28864  
          Iteration 4:  Log likelihood =  -39.28864  
          
          Logistic regression                                     Number of obs =     74
                                                                  LR chi2(1)    =  11.49
                                                                  Prob > chi2   = 0.0007
          Log likelihood = -39.28864                              Pseudo R2     = 0.1276
          
          ------------------------------------------------------------------------------
               foreign | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
          -------------+----------------------------------------------------------------
                   mpg |   .1597621   .0525876     3.04   0.002     .0566922     .262832
                 _cons |  -4.378866   1.211295    -3.62   0.000    -6.752961   -2.004771
          ------------------------------------------------------------------------------
          
          . lroc
          
          Logistic model for foreign
          
          Number of observations =       74
          Area under ROC curve   =   0.7286
          
          . ret li
          
          scalars:
                         r(area) =  .7285839097828353
                            r(N) =  74
          
          . di %4.3f r(area)
          0.729
          
          . local toshow : di %4.3f r(area)
          
          . di "`toshow'"
          0.729
          
          . local rounded = round(r(area), 0.001)
          
          . di `rounded'
          .729
          
          . di %15.12f  round(r(area), 0.001)
           0.729000000000
          
          . di %23.22f  round(r(area), 0.001)
          0.7289999999999999813483
          For most multiples of 0.001 Stata can only get very close using round() with second argument 0.001 because at machine level binary calculations are being used.

          If it seems that round() does exactly what you want, that's often because default formats are helping out.

          But pushing a result fhrough display with a desired format is a better solution.
          See the code above producing local macro rounded.

          Comment

          Working...
          X