Announcement

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

  • ROC-Sensitivity & Specificity for a given variable value

    Dear All,

    Would appreciate any help with this question please: Is there a way to get the sensitivity, specificity or even LR+ LR- for a specific variable cutoff of interest?

    I know the command "roctab outcome variable, detail " gives you the sensitivity & specificity for different variable cutoffs, but the cutoff may not be the exact one I need.

    Is it possible to specify the cutoff, and do it the other way round?

    Thank you very much.
    Michelle

  • #2
    There are at least two ways you can do this.

    1) Assuming that you have already fit a logistic regression model, -logit y x1 x2-, you can use the postestimation command -estat class, cut(<threshold value>)- where the default threshold value is 0.5.

    Example output looks like:

    Code:
                  -------- True --------
    Classified |         D            ~D  |      Total
    -----------+--------------------------+-----------
         +     |       338           171  |        509
         -     |       150           341  |        491
    -----------+--------------------------+-----------
       Total   |       488           512  |       1000
    
    Classified + if predicted Pr(D) >= .5
    True D defined as y1 != 0
    --------------------------------------------------
    Sensitivity                     Pr( +| D)   69.26%
    Specificity                     Pr( -|~D)   66.60%
    Positive predictive value       Pr( D| +)   66.40%
    Negative predictive value       Pr(~D| -)   69.45%
    --------------------------------------------------
    False + rate for true ~D        Pr( +|~D)   33.40%
    False - rate for true D         Pr( -| D)   30.74%
    False + rate for classified +   Pr(~D| +)   33.60%
    False - rate for classified -   Pr( D| -)   30.55%
    --------------------------------------------------
    Correctly classified                        67.90%
    --------------------------------------------------
    2) If you were to manually compute the number of true and false positives and true and false negatives for a given threshold, then you can achieve a similar output table using a user-contributed command -classtabi- where you must specify -classtabi #TN #FP #FN #TP- such as -classtabi 1231 397 50 324-

    Comment


    • #3
      Dear Leonardo,

      Thanks for your reply.

      I have used the estat classification command as you mentioned before,
      However, the cutoff is NOT the actual value of the variable (eg blood pressure of 140mmHg). Stata only allows a cutoff value between 0 to 1. The cutoff is what you define as a positive outcome, and the default is 0.5.

      Best wishes
      Michelle

      Comment


      • #4
        My apologies, your original question was ambiguous. Perhaps you can describe exactly what you are trying to do.

        Comment


        • #5
          Try this:
          Code:
          gen byte bp_dichotomy = (blood_pressure < 140) if !missing(blood_presure)
          tab outcome bp_dichotomy, col
          The column percentages will show you the sensitivity and specificity of outcome at that value of the blood pressure cutoff.

          Comment


          • #6
            Thanks Mr Schechter - a very effective and simple solution!

            BW
            Michellle

            Comment

            Working...
            X