Announcement

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

  • Sensitivity and specificity using roctab

    Hi everybody,

    I am using Stata to calculate the sensitivity and specificity of a diagnostic test (Amsel score) compared to the golden standard test Nugent score.

    Code:
    tab BVbyAmsel highnugent, chi2
    roctab BVbyAmsel highnugent, detail
    The resulting table is
    Code:
               |      highnugent
     BVbyAmsel |         0          1 |     Total
    -----------+----------------------+----------
             0 |       192         66 |       258 
             1 |         6        137 |       143 
    -----------+----------------------+----------
         Total |       198        203 |       401
    If I use roctab, the results given are:
    Code:
                                                Correctly
    Cutpoint      Sensitivity   Specificity   Classified          LR+          LR-
    ------------------------------------------------------------------------------
    ( >= 0 )          100.00%         0.00%       35.66%       1.0000     
    ( >= 1 )           95.80%        74.42%       82.04%       3.7451       0.0564
    ( >  1 )            0.00%       100.00%       64.34%                    1.0000
    So, a sensitivity of 95.80% and a specificity of 74.42%. But if I calculate by hand, I get the following results:

    True positive: 137
    False positive: 6
    True negative: 192
    False negative: 66

    Sensitivity: TP / (TP + FN) = 137 / (137 + 66) = 67.49%
    Specificity: TN / (TN + FP) = 192 / (192 + 6) = 96.97%
    Positive predictive value: TP / (TP + FP) = 137 / (137 + 6) = 95.80%
    Negative predictive value: TN / (TN + FN) = 192 / (192 + 66) = 74.42%

    I have the impression I must have made a mistake somewhere, but I cannot find out how and why. Thank you for your help! I am using Stata 13.0.

    Kindly, Marijn
    Last edited by Marijn Verwijs; 26 Oct 2016, 05:24.

  • #2
    The -roctab- command requires the reference variable ("golden standard") be listed first. You have it reversed.

    By the way, you don't have to hand-calculate the sensitivity and specificity that way. When you run -tabulate- specify the -col- option. For positive and negative predictive values, specify the -row- option.

    Comment


    • #3
      Thank you so much! That is very useful.

      Comment


      • #4
        Originally posted by Clyde Schechter View Post
        The -roctab- command requires the reference variable ("golden standard") be listed first. You have it reversed.

        By the way, you don't have to hand-calculate the sensitivity and specificity that way. When you run -tabulate- specify the -col- option. For positive and negative predictive values, specify the -row- option.
        Can you please tell us how we can get the 95% CI for Positive and negative predictive values and the LR in STATA?

        Comment


        • #5
          So, first you have to compute the total number of true positives, false positives, true negatives, and false negatives. Then you need two denominators: ppv_denominator = true_positives + false_positives, and npv_denominator = true_negatives + false_negatives. Then for the predictive values and confidence intervals you run
          Code:
          cii proportions ppv_denominator true_positives
          cii proportions npv_denominator true_negatives
          Read -help cii-. There are a number of different approaches to calculating confidence intervals for proportions, and you can chose the one you prefer by specifying it as an option to the -cii- command.

          The positive likelihood ratio is just sensitivity/(1-specificity). The likelihood ratio negative is just specificity/(1-sensitivity).

          The details of how you would calculate these various totals, etc. depends on the data you are starting with, and as you don't show any example data I can't provide them.

          Comment

          Working...
          X