March 18, 2018

Why inferDtest app?

A diagnostic test has inherent error rates:

  • can detect conditions that are actually absent (false positive)
  • can miss conditions that are actually present (false negative)

The prevalence of the condition and the test error rates are interrelated:

  • the relationship is nonlinear; its computation is nontrivial

Applying the test results directly without considering the test error rates can have grave consequences.

The inferDtest app provides interactive aid to diagnosticians. It automates correct inference from test results.

Diagnostic test parameters

# prev = prevalence; sens = sensitivity; spec = specificity
# ppv  = positive predictive value
# npv  = negative predictive value
# dlrp = diagnostic likelihood ratio of a positive test
# dlrn = diagnostic likelihood ratio of a negative test

## Imput to the inferDtest app
prev <- .1  
sens <- .80  
spec <- .90

## inferDtest app applies the Bayes' rule to test parameters
ppv <- round(sens*prev/(sens*prev+(1-spec)*(1-prev)),3)
npv <- round(((1-prev)*spec)/( (prev*(1-spec))+(spec*(1-prev))),3)
dlrp <- round(sens/(1-spec),3)
dlrn <- round((1-sens)/spec,3)

inferDtest app: codes for plotting

p1 <- plot_ly() %>% # Predictive Values barplot
add_bars(x = "Predictive Values", y = npv*100, base = -npv*100,
        marker = list(color = 'green'), name = 'Negative test', 
        text = paste("Chance of not having the condition given 
        a negative test is", npv*100, "%", sep = " ")) %>%
add_bars(x = "Predictive Values", y = ppv*100, base = 0, 
         marker = list(color = 'red'), name = 'Positive test', 
         text =paste("Chance of having the condition given a 
        positive test is", ppv*100, "%", sep = " "))
p2 <-  plot_ly() %>% # Diagnostic Likelihood Ratios barplot
add_bars(x = "Diagnostic Likelihood Ratios", y = dlrn*100, base = -dlrn*100,marker = list(color = 'green'), name = 'Negative test', 
text = paste("The post-test odds of the condition is lower at", 
         dlrn*100, "% of the pre-test odds", sep = " ")) %>%
add_bars(x = "Diagnostic Likelihood Ratios", y = dlrp, base = 0, 
         marker = list(color = 'red'), name = 'Positive test', 
         text = paste("The post-test odds of the condition is 
        higher by", dlrp, "times the pre-test odds", sep = " "))
p <- subplot(p1, p2, nrows = 1) %>% 
        layout(title = "Interpreting the Test Result")

inferDtest app: Plotly ouput