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")