Consider a screening test for a certain disease or condition, applied to a person who has a certain prior, pre-test probability of having the disease. For such a person this function calculates the probabilities that: the person has the disease given that they test positive; the person does not have the disease given that they test negative.

screening_test(prior, sensitivity, specificity)

Arguments

prior

A numeric scalar. The pre-test probability \(P(D)\) that the person has the disease. In the absence of specific information this could be the prevalence of the disease in the population, that is, the proportion of people who have the disease in the general population of interest.

sensitivity

A numeric scalar. The conditional probability that a person who has the disease tests positive. If \(+\) is the event that the randomly chosen person tests positive then the sensitivity is \(P(+ \mid D)\).

specificity

A numeric scalar. The conditional probability that a person who does not have the disease tests negative. If \(-\) is the event that the randomly chosen person test negative then the sensitivity is \(P(- \mid {\rm not}D)\).

Value

A list containing the following components

  • pp The probability \(P(+)\) that the person will test positive.

  • ppv The positive predictive value. The conditional probability \(P(D \mid +)\) if the person tests positive then they has the disease.

  • npv The negative predictive value. The conditional probability \(P({\rm not}D \mid -)\) if the person tests negative then they do not have the disease.

  • prior,sensitivity,specificity The input values of prior, sensitivity and specificity.

Details

The required probabilities are calculated using the law of total probability $$P(+) = P(+ \mid D) P(D) + P(+ \mid {\rm not}D) P({\rm not}D)$$ and Bayes' theorem $$P(D \mid +) = \frac{P(+ \mid D) P(D)}{P(+)}$$ $$P({\rm not}D \mid -) = \frac{P(- \mid {\rm not}D) P({\rm not}D)}{P(-)}.$$

Examples

screening_test(prior = 0.1, sensitivity = 0.9, specificity = 0.9)
#> Prevalence, sensitivity, specificity:
#>        P(D)     P(+ | D)  P(- | notD)  
#>         0.1          0.9          0.9  
#> P(positive test), positive and negative predictive values:
#>        P(+)     P(D | +)  P(notD | -)  
#>      0.1800       0.5000       0.9878