A calculator for Bayes theorem. This calculator works off-line. (IE4)
Enter data into the boxes
TP
(True positive),
FP
(False positive),
FN
(False negative),
TN
(True negative),
Test condition
Present
Absent
Total test positive=
TP =
FP =
Total test negative=
FN =
TN =
Total
Sensitivity =
Specificity =
Liklihood ratio =
Prevalence of test condition =
Calculated post test odds =
(Pre-test odds x liklihood ratio)
Actual post test odds =
(True pos / false pos)
Actual post test
risk
(True pos / test positive) =
risk = 1 in
This shows the effect of applying a LR which has been generated in a population with a different prevalence from the one under test. The currently generated LR will be used in the calculations below.
Enter pretest risk (prevalence) 1 in
Pretest odds = 1:
Post test odds = 1:
Post test risk= 1 in
A calculator to confirm the validity of Bayes theorem using odds. There has been some debate about the correct application of Bayes theorem and whether it is appropriate to apply liklihood ratios to risk rather than odds. This calculator shows the results using odds and compares with the results using risk. The calculator clearly shows that using risk give incorrect results.
When we reach a diagnosis clincally we are essentially applying a diagnostic test. For example someone goes to the doctor. Since the doctor does not expect to see completely healthy people at the clinic (although no doubt frequently does), there is a background chance of perhaps 50% that the individual has a disease. The liklihood ratio (LR) of any subsequent test must therefore be applied to this backgoriund risk.The patient says they have a crushing chest pain radiatong down their left arm. A positive history such as this immediately acts as a diagnostic test for heart disease in the mind of the doctor. The LR for "crushing chest pain radiating down the left arm" is then applied to the current background risk for a myocardial infarction. The doctor now orders an ECG which shows an elevated ST segment. The LR for an elevated ST segment is now applied to the new risk. A blood test is ordered for cardiac enzymes. These are raised and this generates another LR for myocardial infarction which is applied to the current risk of this disease.
It is sometimes explained that the validitiy of a test depends on the prevalence of the disease. I show here how this problem arises.
Now it should be noted that if the LR for a particular test is generated in a population with a high prevalence of a disease and then applied to an individual within a population of low prevalence the results and not the same. Strictly speaking the test must be applied within the same population within which the LR has been generated. Of course in practice we do not have LR for things such as an elevated ST segment and elevated cardiac enzymes for for a myocardial infarction. All we know is that they are usually diagnostic (say 90%) but there are exceptions. We are essentially however applying an approximate LR in our own minds. If the LR of a test is applied in a high risk population the final risk is completely differenct from that applied to a low risk population. Ideally the LR should be generated in the same population in which it is applied. For example if a medical student is trained in a part of the world in which TB is endemic they will learn that that the test for TB has an LR of a a certain value. If they then move to a new area in which TB is rare and apply the same LR this would not give an appropriate result. If the LR for the test is generated in the same population as it is applied this problem does not arise.
This shows the results if the above LR is applied to risk rather than odds
Calculated post test
risk
using liklihood ratio applied to pretest
risk
=
risk 1 in
What do we mean by the "accuracy of a test"? If a test is said to be 90% accurate, does this mean that 90% of patients with a positive result will actually have the disease? Programme written by DJR Hutchon copyright Requires Internet Explorer 4.0 or above (or eqivalent) for calculator to work. This calculator is for educational use. It is believed accurate but no responsibility for accuracy of the results is accepted by the author. David J R Hutchon BSc, MB, ChB, FRCOG Consultant Obstetrician, Memorial Hospital, Darlington, England.