Skip to main content

R: Sensitivity, specificity and predictive value of a diagnostic...

R: Sensitivity, specificity and predictive value of a diagnostic...: "Sensitivity, specificity and predictive value of a diagnostic test"
'via Blog this'

Sometimes we need to evaluate the diagnostic accuracy of a new diagnostic test or score or index, in comparison to an existing gold standard. It is very simple to evaluate a diagnostic test in R (1).


If you have the preliminary summary 2X2 table as shown below, we can easily calculate the sensitivity (se), specificity (sp), positive predictive value (ppv) and negative predictive value (npv).

Prerequisite
First install the package "epiR" (2), if you have not already done. Select the mirror of your choice and you are done with installing epiR and it's dependencies.
> install.packages("epiR")

Step 1
Then load the package by the following command

> library(epiR)

Step 2
We need to create the summary table that can be read by R. The function "epi.tests" is used to evaluate the diagnostic test, and it works on an object of class table, which is 2X2 matrix. So we need to first define the object as a matrix or table. You can assign the table to any name, here I named it as "table1".

> table1 <- as.table(matrix(c(a,b,c,d), nrow = 2, byrow = TRUE))

where a,b,c,d are the respective values from the classic 2 X 2 table for that particular test.

Gold Standard
+ve
-ve
Test under
evaluation
+ve
a
b
-ve
c
d

Step 3
You can obtain the results 95% confidence level using the above function, the resulting output looks like that given in the example below.

> epi.tests(table1)

You can find help about the said function using this command
>?epi.tests

Example:
An example in the help you found, you can test it:

Gold Standard
+ve
-ve
Test under
evaluation
+ve
670
202
-ve
74
640

Substitute a=670, b= 202, c=74, d=640 and follow the above steps. Check if you get the same results as below.
> table1 <- as.table(matrix(c(670,202,74,640), nrow = 2, byrow = TRUE))
> epi.tests(table1)
 
          Disease +    Disease -      Total
Test +          670          202        872
Test -           74          640        714
Total           744          842       1586

Point estimates and 95 % CIs:
---------------------------------------------------------
Apparent prevalence                    0.55 (0.52, 0.57)
True prevalence                        0.47 (0.44, 0.49)
Sensitivity                            0.90 (0.88, 0.92)
Specificity                            0.76 (0.73, 0.79)
Positive predictive value              0.77 (0.74, 0.80)
Negative predictive value              0.90 (0.87, 0.92)
Positive likelihood ratio              3.75 (3.32, 4.24)
Negative likelihood ratio              0.13 (0.11, 0.16)
---------------------------------------------------------
R packages used for creating this article are - Rcmdr (3), knitr (4)
References:
1. R Core Team (2015). R: A language and environment for statistical computing. R Foundation for Statistical Computing, Vienna, Austria. URL https://www.R-project.org/. First published: 19 Sep 2011. Last updated: 9th Oct 2015
2. Mark Stevenson with contributions from Telmo Nunes, Cord Heuer, Jonathon Marshall, Javier Sanchez, Ron Thornton, Jeno Reiczigel, Jim Robison-Cox, Paola Sebastiani, Peter Solymos, Kazuki Yoshida, Geoff Jones, Sarah Pirikahu and Simon Firestone (2015). epiR: Tools for the Analysis of Epidemiological Data. R package version 0.9-69. http://CRAN.R-project.org/package=epiR
3. Fox, J. (2005). The R Commander: A Basic Statistics Graphical User Interface to R. Journal of Statistical Software, 14(9): 1--42.
4. Yihui Xie (2014) knitr: A Comprehensive Tool for Reproducible Research in R. In Victoria Stodden, Friedrich Leisch and Roger D. Peng, editors, Implementing Reproducible Computational Research. Chapman and Hall/CRC. ISBN 978-1466561595


Updated on 9th October 2015

Comments

  1. A £200 loan from us could help you between paydays. Here, we've broken down what this loan involves and why you might need one.

    Visit - https://www.bloglovin.com/@leenalegants/200-pound-loans-stabilize-financial-free

    ReplyDelete
  2. 300 loans from us here have been designed to provide you with assistance should a financial emergency occur. More details on 300 pound loan is available on my blog.

    Visit - https://penzu.com/public/d0bff318

    ReplyDelete
  3. There just isn't a worthwhile profit for them to open the doors to the entire populace that would love to get some payday loans UK at affordable rates of interest.

    Visit - https://yarabook.com/read-blog/53628

    ReplyDelete

Post a Comment

Popular posts from this blog

New Drug Regimen for PMTCT in India - Launched in Andhra Pradesh

Today (14th Sep 2012) marked an important milestone in HIV care for the pregnant mothers and infants, with the launching of a new drug regimen for prevention of parent to child transmission of HIV initially in two states, one being Andhra Pradesh. The formal launch by National AIDS Control Organization (NACO), took place at Ravindra Bharathi, Hyderabad amid packed audiences and enthusiastic functionaries representing various levels of health care planning and delivery.