Announcement

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

  • Estimated sensitivity values using diagti command

    Hi there, I am developing some in-class exercises for my MPH epidemiology students. I am having them work in R, but I always like to provide Stata equivalents where possible. We are working on estimating sensitivity and specificity values this week. We're using published aggregate estimates to calculate sensitivity and specificity values in R and Stata; I'm using the epiR package to do this in R. I thought the best command to do this in Stata was diagti; however, the results differ from what I get in R even though the 2 x 2 table are the same. Note, the R output aligns with the published Se + Sp estimates. Am I missing something?


    Here are the results from diagti:

    . diagti 552 308 249 303 /*TP,FP,FN,TN*/

    True |
    disease | Test result
    status | Pos. Neg. | Total
    -----------+----------------------+----------
    Abnormal | 552 308 | 860
    Normal | 249 303 | 552
    -----------+----------------------+----------
    Total | 801 611 | 1,412


    -------------------------------------------------------------------------
    Sensitivity Pr( +| D) 64.19% 60.88% 67.40%
    Specificity Pr( -|~D) 54.89% 50.63% 59.10%
    Positive predictive value Pr( D| +) 68.91% 65.58% 72.11%
    Negative predictive value Pr(~D| -) 49.59% 45.55% 53.63%
    -------------------------------------------------------------------------
    Prevalence Pr(D) 60.91% 58.31% 63.46%
    -------------------------------------------------------------------------


    And the results from using epi.tests() in R:

    Outcome + Outcome - Total
    Test + 552 308 860
    Test - 249 303 552
    Total 801 611 1412

    Point estimates and 95 % CIs:
    ---------------------------------------------------------
    Apparent prevalence 0.61 (0.58, 0.63)
    True prevalence 0.57 (0.54, 0.59)
    Sensitivity 0.69 (0.66, 0.72)
    Specificity 0.50 (0.46, 0.54)
    Positive predictive value 0.64 (0.61, 0.67)
    Negative predictive value 0.55 (0.51, 0.59)
    Positive likelihood ratio 1.37 (1.25, 1.50)
    Negative likelihood ratio 0.63 (0.55, 0.71)
    ---------------------------------------------------------

    Thank you in advance for your help.

  • #2
    There are two problems: First, you seem to be using a fairly outdated version of diagti. I use

    Code:
    . which diagti
    c:\ado\plus\d\diagti.ado
    *! diagti 2.053, 7 April 2004
    *! by PT Seed ([email protected])
    *! Immediate version of diagt,
    *! based on diagtest.ado (Aurelio Tobias, STB-56: sbe36)
    from SSC.

    The second problem with sensitivity and specificity (and related stats) is that the orientation of the table is crucial. Unfortunately, the notation differs among authors and so does the orientation of the table. You want

    Code:
    . diagti 552 249 308 303
    
          True |
       disease |      Test result
        status |      Neg.       Pos. |     Total
    -----------+----------------------+----------
        Normal |       303        308 |       611
      Abnormal |       249        552 |       801
    -----------+----------------------+----------
         Total |       552        860 |     1,412
    
                                                      [95% Confidence Interval]
    ---------------------------------------------------------------------------
    Prevalence                         Pr(A)     56.7%     54.1%      59.3%
    ---------------------------------------------------------------------------
    Sensitivity                      Pr(+|A)     68.9%     65.6%     72.1%
    Specificity                      Pr(-|N)     49.6%     45.6%     53.6%
    ROC area               (Sens. + Spec.)/2      0.59      0.57      0.62
    ---------------------------------------------------------------------------
    Likelihood ratio (+)     Pr(+|A)/Pr(+|N)      1.37      1.25      1.50
    Likelihood ratio (-)     Pr(-|A)/Pr(-|N)      0.63      0.55      0.71
    Odds ratio                   LR(+)/LR(-)      2.18      1.75      2.71
    Positive predictive value        Pr(A|+)     64.2%     60.9%     67.4%
    Negative predictive value        Pr(N|-)     54.9%     50.6%     59.1%
    ---------------------------------------------------------------------------
    to match the results you get from R.

    I do not know what "apparent prevalence" refers to in the R output.


    btw. If I were teaching this stuff, I think I might confront the students with the "wrong" table and have them "fix" it; that way, I imagine they get a better understanding of why the table orientation matters.
    Last edited by daniel klein; 11 Feb 2021, 02:40.

    Comment

    Working...
    X