Harvard Medical School Test

Introduction

“We developed a test for a disease. The false negative rate is zero (“sensivity”), the false positive rate is Probability-Disease-Test-Positive_1.gif (“specifity”) and the incidence of the disease in the population is Probability-Disease-Test-Positive_2.gif

“What is the probability that a randomly selected person has the disease?”

This question was posed at the Harvard Medical School to staff and students alike (see Probability-Disease-Test-Positive_3.gif), but similar questions are surely part of many Statistics introductory courses as well.

Sampling

We solve the problem by sampling.

We denote with “0” a person in the population which does not have the disease under question. We denote with “1” a person which does have the diesease.

Define the size of the population, the prevalence of the disease in the population and the false positive rate of the test:

Probability-Disease-Test-Positive_4.gif

Generate the population to draw from:

Probability-Disease-Test-Positive_5.gif

Define a predicate for the result of the test, person ∈{0,1}, ‘True’ if the test(!) delivers a positive test result, ‘False’ otherwise:

Probability-Disease-Test-Positive_6.gif

Define a predicate whether a person really has the disease:

Probability-Disease-Test-Positive_7.gif

Do a Monte Carlo simulation to find an estimate of the probability.

Probability-Disease-Test-Positive_8.gif

Probability-Disease-Test-Positive_9.gif

Probability-Disease-Test-Positive_10.gif

Probability-Disease-Test-Positive_11.gif

Probability-Disease-Test-Positive_12.gif

Bayes’ Rule

It is instructive to solve for this conditional probability analytically.

To do this, we need to apply Bayes’ rule:

Probability-Disease-Test-Positive_13.gif

H denotes the hypothesis and E the corresponding evidence. Note that this is the form as derived by Thomas Bayes himself.

First Implementation

Let’s write a function which implements this rule.

Probability-Disease-Test-Positive_14.gif

What are the arguments for our problem?
H = “The person has the disease.”,
E = “The test for the person is positive.”,
P(H) = Probability-Disease-Test-Positive_15.gif,
P(¬H) = Probability-Disease-Test-Positive_16.gif,
P(EH) = 1 [because the test finds the disease always (= 1- false neg. rate)],
P(E¬H) = Probability-Disease-Test-Positive_17.gif ( = false positive rate),
P(E) = P(EH) *P(H) + P(E¬H)*P(¬H) = 1*Probability-Disease-Test-Positive_18.gifProbability-Disease-Test-Positive_19.gif.

Probability-Disease-Test-Positive_20.gif

Probability-Disease-Test-Positive_21.gif

Probability-Disease-Test-Positive_22.gif

Probability-Disease-Test-Positive_23.gif

Probability-Disease-Test-Positive_24.gif

Second Implementation

We follow the approach as given in stackoverflow:

Probability-Disease-Test-Positive_25.gif

Probability-Disease-Test-Positive_26.gif

Probability-Disease-Test-Positive_27.gif

Third Implementation

We follow the second approach as given in stackoverflow:

Probability-Disease-Test-Positive_28.gif

Probability-Disease-Test-Positive_29.gif

Probability-Disease-Test-Positive_30.gif

Probability-Disease-Test-Positive_31.gif

Probability-Disease-Test-Positive_32.gif

Probability-Disease-Test-Positive_33.gif

Probability-Disease-Test-Positive_34.gif

Probability-Disease-Test-Positive_35.gif

Probability-Disease-Test-Positive_36.gif

Probability-Disease-Test-Positive_37.gif

Probability-Disease-Test-Positive_38.gif

Bibliography

1. Casscells, Ward and Schoenberger, Arno and Graboys, Thomas B., Interpretation by Physicians of Clinical Laboratory Results. New England Journal of Medicine, 1978.

Spikey Created with Wolfram Mathematica 9.0

Winfried@sunkiddance.de (PGP-Schlüssel)

Home

Impressum

Letzte Änderung: 19.05.2013