lecture 5 brian ca o table of outline lecture 5 - …bcaffo/651/files/lecture5.pdf · lecture 5...

25
Lecture 5 Brian Caffo Table of contents Outline Conditional probability Conditional densities Bayes’ Rule Diagnostic tests DLRs Lecture 5 Brian Caffo Department of Biostatistics Johns Hopkins Bloomberg School of Public Health Johns Hopkins University October 21, 2007

Upload: lamtuong

Post on 03-Sep-2018

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lecture 5 Brian Ca o Table of Outline Lecture 5 - …bcaffo/651/files/lecture5.pdf · Lecture 5 Brian Ca o Table of contents ... Brian Ca o Table of contents Outline Conditional probability

Lecture 5

Brian Caffo

Table ofcontents

Outline

Conditionalprobability

Conditionaldensities

Bayes’ Rule

Diagnostictests

DLRs

Lecture 5

Brian Caffo

Department of BiostatisticsJohns Hopkins Bloomberg School of Public Health

Johns Hopkins University

October 21, 2007

Page 2: Lecture 5 Brian Ca o Table of Outline Lecture 5 - …bcaffo/651/files/lecture5.pdf · Lecture 5 Brian Ca o Table of contents ... Brian Ca o Table of contents Outline Conditional probability

Lecture 5

Brian Caffo

Table ofcontents

Outline

Conditionalprobability

Conditionaldensities

Bayes’ Rule

Diagnostictests

DLRs

Table of contents

1 Table of contents

2 Outline

3 Conditional probability

4 Conditional densities

5 Bayes’ Rule

6 Diagnostic tests

7 DLRs

Page 3: Lecture 5 Brian Ca o Table of Outline Lecture 5 - …bcaffo/651/files/lecture5.pdf · Lecture 5 Brian Ca o Table of contents ... Brian Ca o Table of contents Outline Conditional probability

Lecture 5

Brian Caffo

Table ofcontents

Outline

Conditionalprobability

Conditionaldensities

Bayes’ Rule

Diagnostictests

DLRs

Outline

1 Define conditional probabilities

2 Define conditional mass functions and densities

3 Motivate the conditional density

4 Bayes’ rule

5 Applications of Bayes’ rule to diagnostic testing

Page 4: Lecture 5 Brian Ca o Table of Outline Lecture 5 - …bcaffo/651/files/lecture5.pdf · Lecture 5 Brian Ca o Table of contents ... Brian Ca o Table of contents Outline Conditional probability

Lecture 5

Brian Caffo

Table ofcontents

Outline

Conditionalprobability

Conditionaldensities

Bayes’ Rule

Diagnostictests

DLRs

Conditional probability, motivation

• The probability of getting a one when rolling a (standard)die is usually assumed to be one sixth

• Suppose you were given the extra information that the dieroll was an odd number (hence 1, 3 or 5)

• conditional on this new information, the probability of aone is now one third

Page 5: Lecture 5 Brian Ca o Table of Outline Lecture 5 - …bcaffo/651/files/lecture5.pdf · Lecture 5 Brian Ca o Table of contents ... Brian Ca o Table of contents Outline Conditional probability

Lecture 5

Brian Caffo

Table ofcontents

Outline

Conditionalprobability

Conditionaldensities

Bayes’ Rule

Diagnostictests

DLRs

Conditional probability, definition

• Let B be an event so that P(B) > 0

• Then the conditional probability of an event A given thatB has occurred is

P(A | B) =P(A ∩ B)

P(B)

• Notice that if A and B are independent, then

P(A | B) =P(A)P(B)

P(B)= P(A)

Page 6: Lecture 5 Brian Ca o Table of Outline Lecture 5 - …bcaffo/651/files/lecture5.pdf · Lecture 5 Brian Ca o Table of contents ... Brian Ca o Table of contents Outline Conditional probability

Lecture 5

Brian Caffo

Table ofcontents

Outline

Conditionalprobability

Conditionaldensities

Bayes’ Rule

Diagnostictests

DLRs

Example

• Consider our die roll example

• B = {1, 3, 5}• A = {1}

P(one given that roll is odd) = P(A | B)

=P(A ∩ B)

P(B)

=P(A)

P(B)

=1/6

3/6=

1

3

Page 7: Lecture 5 Brian Ca o Table of Outline Lecture 5 - …bcaffo/651/files/lecture5.pdf · Lecture 5 Brian Ca o Table of contents ... Brian Ca o Table of contents Outline Conditional probability

Lecture 5

Brian Caffo

Table ofcontents

Outline

Conditionalprobability

Conditionaldensities

Bayes’ Rule

Diagnostictests

DLRs

Conditional densities and massfunctions

• Conditional densities or mass functions of one variableconditional on the value of another

• Let f (x , y) be a bivariate density or mass function forrandom variables X and Y

• Let f (x) and f (y) be the associated marginal massfunction or densities disregarding the other variables

f (y) =

∫f (x , y)dx or f (y) =

∑x

f (x , y)dx .

• Then the conditional density or mass function given thatY = y is given by

f (x | y) = f (x , y)/f (y)

Page 8: Lecture 5 Brian Ca o Table of Outline Lecture 5 - …bcaffo/651/files/lecture5.pdf · Lecture 5 Brian Ca o Table of contents ... Brian Ca o Table of contents Outline Conditional probability

Lecture 5

Brian Caffo

Table ofcontents

Outline

Conditionalprobability

Conditionaldensities

Bayes’ Rule

Diagnostictests

DLRs

Notes

• It is easy to see that, in the discrete case, the definition ofconditional probability is exactly as in the definition forconditional events where A = the event that X = x andB = the event that Y = y

• The continuous definition is a little harder to motivate,since the events X = x and Y = y each have probability 0

• However, a useful motivation can be performed by takingthe appropriate limits as follows

• Define A = {X ≤ x} while B = {Y ∈ [y , y + ε]}

Page 9: Lecture 5 Brian Ca o Table of Outline Lecture 5 - …bcaffo/651/files/lecture5.pdf · Lecture 5 Brian Ca o Table of contents ... Brian Ca o Table of contents Outline Conditional probability

Lecture 5

Brian Caffo

Table ofcontents

Outline

Conditionalprobability

Conditionaldensities

Bayes’ Rule

Diagnostictests

DLRs

Continued

P(X ≤ x | Y ∈ [y , y + ε]) = P(A | B) =P(A ∩ B)

P(B)

=P(X ≤ x ,Y ∈ [y , y + ε])

P(Y ∈ [y , y + ε])

=

∫ y+εy

∫ x−∞ f (x , y)dxdy∫ y+εy f (y)dy

=ε∫ y+εy

∫ x−∞ f (x , y)dxdy

ε∫ y+εy f (y)dy

Page 10: Lecture 5 Brian Ca o Table of Outline Lecture 5 - …bcaffo/651/files/lecture5.pdf · Lecture 5 Brian Ca o Table of contents ... Brian Ca o Table of contents Outline Conditional probability

Lecture 5

Brian Caffo

Table ofcontents

Outline

Conditionalprobability

Conditionaldensities

Bayes’ Rule

Diagnostictests

DLRs

Continued

=

∫ y+ε−∞

∫ x∞ f (x ,y)dxdy−

∫ y−∞

∫ x−∞ f (x ,y)dxdy

ε∫ y+ε−∞ f (y)dy−

∫ y−∞ f (y)dy

ε

=g1(y+ε)−g1(y)

εg2(y+ε)−g2(y)

ε

where

g1(y) =

∫ y

−∞

∫ x

−∞f (x , y)dxdy and g2(y) =

∫ y

−∞f (y)dy .

Page 11: Lecture 5 Brian Ca o Table of Outline Lecture 5 - …bcaffo/651/files/lecture5.pdf · Lecture 5 Brian Ca o Table of contents ... Brian Ca o Table of contents Outline Conditional probability

Lecture 5

Brian Caffo

Table ofcontents

Outline

Conditionalprobability

Conditionaldensities

Bayes’ Rule

Diagnostictests

DLRs

• Notice that the limit of the numerator and denominatortends to g ′1 and g ′2 as ε gets smaller and smaller

• Hence we have that the conditional distribution function is

P(X ≤ x | Y = y) =

∫ x−∞ f (x , y)dx

f (y).

• Now, taking the derivative with respect to x yields theconditional density

f (x | y) =f (x , y)

f (y)

Page 12: Lecture 5 Brian Ca o Table of Outline Lecture 5 - …bcaffo/651/files/lecture5.pdf · Lecture 5 Brian Ca o Table of contents ... Brian Ca o Table of contents Outline Conditional probability

Lecture 5

Brian Caffo

Table ofcontents

Outline

Conditionalprobability

Conditionaldensities

Bayes’ Rule

Diagnostictests

DLRs

Geometrically

• Geometrically, the conditional density is obtained bytaking the relevant slice of the joint density andappropriately renormalizing it

• This idea extends to any other line, or even non-linearfunctions

Page 13: Lecture 5 Brian Ca o Table of Outline Lecture 5 - …bcaffo/651/files/lecture5.pdf · Lecture 5 Brian Ca o Table of contents ... Brian Ca o Table of contents Outline Conditional probability

Lecture 5

Brian Caffo

Table ofcontents

Outline

Conditionalprobability

Conditionaldensities

Bayes’ Rule

Diagnostictests

DLRs

Example

• Let f (x , y) = ye−xy−y for 0 ≤ x and 0 ≤ y

• Then note

f (y) =

∫ ∞0

f (x , y)dx = e−y

∫ ∞0

ye−xy dx = e−y

• Therefore

f (x | y) = f (x , y)/f (y) =ye−xy−y

e−y= ye−xy

Page 14: Lecture 5 Brian Ca o Table of Outline Lecture 5 - …bcaffo/651/files/lecture5.pdf · Lecture 5 Brian Ca o Table of contents ... Brian Ca o Table of contents Outline Conditional probability

Lecture 5

Brian Caffo

Table ofcontents

Outline

Conditionalprobability

Conditionaldensities

Bayes’ Rule

Diagnostictests

DLRs

Example

• Let f (x , y) = 1/πr 2 for x2 + y 2 ≤ r 2

• X and Y are uniform on a circle with radius r

• What is the conditional density of X given that Y = 0?

• Probably easiest to think geometrically

f (x | y = 0) ∝ 1 for − r 2 ≤ x ≤ r 2

• Therefore

f (x | y = 0) =1

2r 2for − r 2 ≤ x ≤ r 2

Page 15: Lecture 5 Brian Ca o Table of Outline Lecture 5 - …bcaffo/651/files/lecture5.pdf · Lecture 5 Brian Ca o Table of contents ... Brian Ca o Table of contents Outline Conditional probability

Lecture 5

Brian Caffo

Table ofcontents

Outline

Conditionalprobability

Conditionaldensities

Bayes’ Rule

Diagnostictests

DLRs

Bayes’ rule

• Let f (x | y) be the conditional density or mass functionfor X given that Y = y

• Let f (y) be the marginal distribution for y

• Then if y is continuous

f (y | x) =f (x | y)f (y)∫f (x | t)f (t)dt

• If y is discrete

f (y | x) =f (x | y)f (y)∑y f (x | t)f (t)

Page 16: Lecture 5 Brian Ca o Table of Outline Lecture 5 - …bcaffo/651/files/lecture5.pdf · Lecture 5 Brian Ca o Table of contents ... Brian Ca o Table of contents Outline Conditional probability

Lecture 5

Brian Caffo

Table ofcontents

Outline

Conditionalprobability

Conditionaldensities

Bayes’ Rule

Diagnostictests

DLRs

Notes

• Bayes’ rule relates the conditional density of f (y | x) tothe f (x | y) and f (y)

• A special case of this kind relationship is for two sets Aand B, which yields that

P(B | A) =P(A | B)P(B)

P(A | B)P(B) + P(A | Bc)P(Bc).

Proof:• Let X be an indicator that event A has occurred• Let Y be an indicator that event B has occurred• Plug into the discrete version of Bayes’ rule

Page 17: Lecture 5 Brian Ca o Table of Outline Lecture 5 - …bcaffo/651/files/lecture5.pdf · Lecture 5 Brian Ca o Table of contents ... Brian Ca o Table of contents Outline Conditional probability

Lecture 5

Brian Caffo

Table ofcontents

Outline

Conditionalprobability

Conditionaldensities

Bayes’ Rule

Diagnostictests

DLRs

Example: diagnostic tests

• Let + and − be the events that the result of a diagnostictest is positive or negative respectively

• Let D and Dc be the event that the subject of the testhas or does not have the disease respectively

• The sensitivity is the probability that the test is positivegiven that the subject actually has the disease, P(+ | D)

• The specificity is the probability that the test is negativegiven that the subject does not have the disease,P(− | Dc)

Page 18: Lecture 5 Brian Ca o Table of Outline Lecture 5 - …bcaffo/651/files/lecture5.pdf · Lecture 5 Brian Ca o Table of contents ... Brian Ca o Table of contents Outline Conditional probability

Lecture 5

Brian Caffo

Table ofcontents

Outline

Conditionalprobability

Conditionaldensities

Bayes’ Rule

Diagnostictests

DLRs

More definitions

• The positive predictive value is the probability that thesubject has the disease given that the test is positive,P(D | +)

• The negative predictive value is the probability that thesubject does not have the disease given that the test isnegative, P(Dc | −)

• The prevalence of the disease is the marginal probabilityof disease, P(D)

Page 19: Lecture 5 Brian Ca o Table of Outline Lecture 5 - …bcaffo/651/files/lecture5.pdf · Lecture 5 Brian Ca o Table of contents ... Brian Ca o Table of contents Outline Conditional probability

Lecture 5

Brian Caffo

Table ofcontents

Outline

Conditionalprobability

Conditionaldensities

Bayes’ Rule

Diagnostictests

DLRs

More definitions

• The diagnostic likelihood ratio of a positive test,labeled DLR+, is P(+ | D)/P(+ | Dc), which is the

sensitivity/(1− specificity)

• The diagnostic likelihood ratio of a negative test,labeled DLR−, is P(− | D)/P(− | Dc), which is the

(1− sensitivity)/specificity

Page 20: Lecture 5 Brian Ca o Table of Outline Lecture 5 - …bcaffo/651/files/lecture5.pdf · Lecture 5 Brian Ca o Table of contents ... Brian Ca o Table of contents Outline Conditional probability

Lecture 5

Brian Caffo

Table ofcontents

Outline

Conditionalprobability

Conditionaldensities

Bayes’ Rule

Diagnostictests

DLRs

Example

• A study comparing the efficacy of HIV tests, reports on anexperiment which concluded that HIV antibody tests havea sensitivity of 99.7% and a specificity of 98.5%

• Suppose that a subject, from a population with a .1%prevalence of HIV, receives a positive test result. What isthe probability that this subject has HIV?

• Mathematically, we want P(D | +) given the sensitivity,P(+ | D) = .997, the specificity, P(− | Dc) = .985, andthe prevalence P(D) = .001

Page 21: Lecture 5 Brian Ca o Table of Outline Lecture 5 - …bcaffo/651/files/lecture5.pdf · Lecture 5 Brian Ca o Table of contents ... Brian Ca o Table of contents Outline Conditional probability

Lecture 5

Brian Caffo

Table ofcontents

Outline

Conditionalprobability

Conditionaldensities

Bayes’ Rule

Diagnostictests

DLRs

Using Bayes’ formula

P(D | +) =P(+ | D)P(D)

P(+ | D)P(D) + P(+ | Dc)P(Dc)

=P(+ | D)P(D)

P(+ | D)P(D) + {1− P(− | Dc)}{1− P(D)}

=.997× .001

.997× .001 + .015× .999

= .062

• In this population a positive test result only suggests a 6%probability that the subject has the disease

• (The positive predictive value is 6% for this test)

Page 22: Lecture 5 Brian Ca o Table of Outline Lecture 5 - …bcaffo/651/files/lecture5.pdf · Lecture 5 Brian Ca o Table of contents ... Brian Ca o Table of contents Outline Conditional probability

Lecture 5

Brian Caffo

Table ofcontents

Outline

Conditionalprobability

Conditionaldensities

Bayes’ Rule

Diagnostictests

DLRs

More on this example

• The low positive predictive value is due to low prevalenceof disease and the somewhat modest specificity

• Suppose it was known that the subject was an intravenousdrug user and routinely had intercourse with an HIVinfected partner

• Notice that the evidence implied by a positive test resultdoes not change because of the prevalence of disease inthe subject’s population, only our interpretation of thatevidence changes

Page 23: Lecture 5 Brian Ca o Table of Outline Lecture 5 - …bcaffo/651/files/lecture5.pdf · Lecture 5 Brian Ca o Table of contents ... Brian Ca o Table of contents Outline Conditional probability

Lecture 5

Brian Caffo

Table ofcontents

Outline

Conditionalprobability

Conditionaldensities

Bayes’ Rule

Diagnostictests

DLRs

Likelihood ratios• Using Bayes rule, we have

P(D | +) =P(+ | D)P(D)

P(+ | D)P(D) + P(+ | Dc)P(Dc)

and

P(Dc | +) =P(+ | Dc)P(Dc)

P(+ | D)P(D) + P(+ | Dc)P(Dc).

• Therefore

P(D | +)

P(Dc | +)=

P(+ | D)

P(+ | Dc)× P(D)

P(Dc)

ie

post-test odds of D = DLR+ × pre-test odds of D

• Similarly, DLR− relates the decrease in the odds of thedisease after a negative test result to the odds of diseaseprior to the test.

Page 24: Lecture 5 Brian Ca o Table of Outline Lecture 5 - …bcaffo/651/files/lecture5.pdf · Lecture 5 Brian Ca o Table of contents ... Brian Ca o Table of contents Outline Conditional probability

Lecture 5

Brian Caffo

Table ofcontents

Outline

Conditionalprobability

Conditionaldensities

Bayes’ Rule

Diagnostictests

DLRs

HIV example revisited

• Suppose a subject has a positive HIV test

• DLR+ = .997/(1− .985) ≈ 66

• The result of the positive test is that the odds of disease isnow 66 times the pretest odds

• Or, equivalently, the hypothesis of disease is 66 times moresupported by the data than the hypothesis of no disease

Page 25: Lecture 5 Brian Ca o Table of Outline Lecture 5 - …bcaffo/651/files/lecture5.pdf · Lecture 5 Brian Ca o Table of contents ... Brian Ca o Table of contents Outline Conditional probability

Lecture 5

Brian Caffo

Table ofcontents

Outline

Conditionalprobability

Conditionaldensities

Bayes’ Rule

Diagnostictests

DLRs

HIV example revisited

• Suppose that a subject has a negative test result

• DLR− = (1− .997)/.985 ≈ .003

• Therefore, the post-test odds of disease is now .3% of thepretest odds given the negative test.

• Or, the hypothesis of disease is supported .003 times thatof the hypothesis of absence of disease given the negativetest result