Write scripts to convert between odds and probability and to calculate post-test odds.
probability
Odds = ---------------
1 - probability
odds
Probability = --------
1 + odds
For instance, if the probability of an event occurring is 25% (or 1/4) the
odds will be 1:3. Likewise, if the odds of an event occurring are 2:3 the
probability will be 40% (or 2/5).
Bayes' Equation
The Bayes' equation adapted for clinical diagnosis looks like this:
sensitivity
Post-test odds = pretest odds * ---------------
1 - specificity
The post-test odds are the odds that a patient has the disease, taking into
account both the test results and your prior knowledge about the patient.
The pretest odds are the odds that the patient has the disease determined
from information you know before running the test. The ratio sensitivity /
(1 - specificity) is called the likelihood ratio. It is the probability of
obtaining the positive test result in a patient with the disease
(sensitivity) divided by the probability of obtaining a positive test result
in a patient without the disease (1 - specificity). So, Bayes' equation can
be written in a simpler (and more general) form:
Post-test odds = pretest odds * likelihood ratio
As you will recall from a prior lesson:
Sensitivity - the fraction of all those with the disease who get a positive
test result.
Specificity - the fraction of those without the disease who get a negative
test result.
These concepts can be represented as:
TP TN
Sensitivity = ------- Specificity = -------
TP + FN TN + FP
TP - true positive
FP - false positive
TN - true negative
FN - false negative
Genetic Diseases and Penetrance
For some genetic diseases you need to distinguish the sensitivity to detect the genetic defect from the sensitivity to detect clinical disease. Some genetic diseases have poor penetrance, meaning that some people with the abnormal gene do not get the disease. A test that detects the gene with few false positives would produce a lot of false positives when assessed for its ability to detect the clinical disease.
Nested Subroutines and Recursion
Take a look at this nested subroutine call. It's just an example showing a subroutine being called from within another subroutine.
ASSIGNMENT: