Docsity

Probability and Statistics: Introduction to Medical Statistics and Diagnostic Tests, Dispense di Medicina

Toggle sidebar
bg1
23/08/2018
Statistics course. S. Iacobelli 1
Introductory Course in
Medical Statistics
Probability calculus
Basics of probability calculus, with applications. Conditional
probability; Bayes formula. Random variables. Distributions:
Binomial, Poisson, Normal
Simona Iacobelli
Requisites: Main tools for descriptive statistics
With some exercises
Complementary Material: Exercises with Solutions
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c

Anteprima parziale del testo

Scarica Probability and Statistics: Introduction to Medical Statistics and Diagnostic Tests e più Dispense in PDF di Medicina solo su Docsity!

Introductory Course in

Medical Statistics

Probability calculus

Basics of probability calculus, with applications. Conditional

probability; Bayes formula. Random variables. Distributions:

Binomial, Poisson, Normal

Simona Iacobelli

Requisites: Main tools for descriptive statistics

With some exercises

Complementary Material: Exercises with Solutions

Probability calculus to link phenomena of interest

to observed data

  • Probability calculus allows to link the population to the sample
  • Knowing the (distribution of the) variable X in the population, we can compute

the probability of observing a certain (set of values in the) sample

  • Not knowing the population but knowing (the data in the sample, we can draw

information about the population

[deduction]

[induction, or

inference]

Phenomenon = Population = pot

containing all possible values of X

Data = Sample = n observations extracted

from the population like bullets from the

pot

Definitions of probability

  • There are different definitions of probability. In this course:

 We follow the mathematical setting and learn the rules to compute probabilities

starting from other probabilities

 We only refer to a purely intuitive notion of probability: as measure of the

degree of certainty that we feel about the occurrence of an event

  • In games ruled by chance (or randomness) we usually assess the probability in

terms of the ratio between the number of outcomes in which the event occurs

and the total number of possible outcomes  Classic def.

  • In situations that can be observed a number of times we usually assess the

probability in terms of the percentage of cases when the event occurred 

Frequentist def.

  • Even beyond games or repeated observations we do have an intuitive idea of the

probability of an event, based on both objective and subjective elements 

Subjective def.

  • The Mathematic def. is also called Axiomatic

Complementary event

A

Ω

A

A

Complement set , called

«not A» , «A negated»

= «non getting 2»

A

p( A) = 1 – p(A)

p(A) = 1 / 6

p( ) = 5/

A = «the patient responds to therapy»

A

The complementary event of A is the

event including al cases when A does not

occur (is FALSE)

A

A = «getting 2»

p(response) = 0.

p(no response) = 0.

Its probability is the complement to 1 of

p(A):

Event Intersection «A and B»

A

C

A, C disjoint sets

Not-compatible

events

C = «getting 3»

A B

A = «getting even»

B = «getting a number <=3»

A&B = «getting 2»

A  B

The intersection of A and B is the

event that includes all cases when

both event A and event B occur (are

TRUE)

A C 

A&C = Φ

A, B sets that

intersect

Empty set =

complementary of Ω =

impossible event

Conditional probability.

Dependence/Independence

p(A|B) = prob. of A conditional on B

The probability of an event A conditional on an event B measures the degree of

expectation about the occurrence of A when we have an information that the event

B occurs.

p(A|B) ≠ p(A)

p(A|B) = p(A)

Definition: The events A and B are dependent when:

Independence is reciprocal, thus also p(B|A) = p(B)

In this case we also have independence among all

complementary events

PA B P A

PAB P A

PA B P A

 “given B”

 “if B is true B”

 “knowing that B is true”

 “restricting to the cases when B is true”

Definition: The events A and B are independent when:

Conditional probability.

Dependence/Independence

Events A and B are dependent

Events A and D are independent

A = «getting even»

B = «getting a number <=3»

p(A)= 1 / 2

p(A|B)= 1 / 3

D = «getting a number <=2»

p(A|D)= 1 / 2

In the general population the probability of death due to stroke is 5%;

among obese it is 10%. These info correspond to:

p(“death due to stroke”) = 0.

p(“death due to stroke” | “obese”) = 0.10 [«among» = restriction, condition]

Event Union «A or B»

The union of A and B includes all cases

when A occurs or B occurs or both

occur (i.e. it includes also the

intersection)

At least one between A and B is TRUE

A B

(U)

A = «getting an even number»

B = «getting a number <=3»

A

B

A U B = «getting 1 or 2 or 3 or 4 or 6»

A, B disjoint sets

A, B sets that

intersect

Probability of the Union «A or B»

A B

p(A U B) = p(A) + p(B) – p(A & B)

(U)

p(A U B) = p(A) + p(B)

This formula is simplified when the

events are disjoint, since for them

p(A&B)=0:

A

B

A, B disjoint sets

A, B sets that

intersect

Bart goes to work by public transports. He computed that every day the probability of

arriving late is 15%. What is the probability that Bart arrives on time?

Bart knows also that when there is a strike the probability of being late increases to

40%. How do we write this information formally?

Today there’s a strike. What is the probability that Bart arrives on time?

Tomorrow there will be a strike with probability equal to 30%. What is the probability

that there will be a strike and Bart will arrive late?

Finally, what is the probability that there will be a strike or Bart will arrive late?

Example of application of the rules (1)

p(L)=0.15  p(not L)=1-0.15=0.

p(L | S)=0.4 L and S are dependent events

p(not L | S)=1-0.4=0.

p(S & L) = p(S)∙p(L|S)=0.3 ∙ 0.4 = 0.12 (prob of the intersection of dependent events)

p(S or L) (prob of the union, compatible events)

p(S or L) = p(S)+p(L)- p(S & L) =0.3 + 0.15 - 0.12 = 0.

In a certain population:

  • 20% of deliveries has complications

•30% of deliveries are done by cesarean cut

  • Half of deliveries with complications require a cesarean cut

What is the probability of having a cesarean delivery or complications?

Example of application of the rules (2)

Events:

Information:

Question:

P(A or B) = p(A) + p(B) – p(A & B)

p(A & B) = p(B|A) ·p(A)=0.5 ·0.2=0.1 (prob. cesarean with /and/ complication)

P(A or B) = 0.2 + 0.3 – 0.1 = 0.

p(A)=0.2 p(B) = 0.3 P(B|A) = 0.

P(A or B)

A = complication; B = cesarean

The Bayes formula

It is important to understand well the setting:

  • It is known what is the general probability of

occurrence of a certain event C

p(C1) prior probability

  • It is known that either C1 or its complement (C2)

are the only possible causes of an event E, and

with which probability, P(E|C1) P(E|C2).

  • It is observed that event E occurred. The aim is

updating the probability of C1, as:

p(C1|E) posterior probability

C

C

E

It is a kind of «diagnostic problem»: you observe the symptom E, what is

probability of disease C1?

This «theorem» (Bayes, 1763) is actually a very simple formula that can be derived

from the basic calculation rules (see next). However the logical implications involve

the need of a subjective definition of probability.

From the Bayes theorem a full statistical inference setting alternative to the

frequentist one arises (Bayesian statistics)

The Bayes formula

C

C

E

p(C1|E) = p(C1&E) / p(E)

  • For the numerator: p(C1&E) =p(E|C1)·p(C1)
  • For the denominator we use the decomposition:

P(E) = p(E|C1)∙p(C1)+ p(E|C2)∙p(C2)

p(E|C1)p(C1) p(E|C2) p(C2)

p(E|C1) p(C1)

p(C1 | E)

  

The ratio of the prior prob. of the

causes C1 and C2 is updated

through the likelihood ratio,

returning the ratio of posterior

probabilities

p(C2)

p(C1)

p(E| C2)

p(E| C1)

p(C2| E)

p(C1 | E)

  

It is also useful to compare and interpret the probabilities of the causes:

A policy team is investigating on whether Zac is responsible of a theft. Zac denies

and claims he never went to the site where it occurred. So far police estimates that

Zac is guilty with probability 60%.

Today police found Zac’s hair in the theft site. The hair could be found there with

probability 100% if Zac is guilty, however if Zac was not there (not guilty) there is

still a 20% probability that the hair was there. Does the finding of the hair change

the assessment of the police about Zac being guilty? Compute also the odds of

guilt before and after the finding (see next)

Events: Guilty, Not Guilty: G, NG. Finding the hair: F

Information: p (R|A) 0.6 1.0 0.2 p(A

Question1: p(G | F)

Notice that the event F is «decomposed» in the two cases, that Zac is Guilty

or that Zac is Not Guilty, and this is the quantity at the denominator of the

Bayes f-la

Application of Bayes formula

p(G)= p(F|G)= p(F|NG)=

p(NG) =0.

Information: p(G)=0.6 p(NG)=0.4 P(F|G)=100% P(F|NG)=0.

Question1: p(G | F)

F = (F&G) U (F&NG) 

p(F) = 1.0 ∙0.6+0.2 ∙0.4=0.6+0.08=0.

p(G | F) = 0.6 / 0.608 = 0.882 notice: 0.6 is P(F/G)∙P(G) [num]

Question2: compare the odds of guilt a priori and a posteriori

Application of Bayes formula

  

Pr( ) 1

Pr( )

A

A

Def of ODDS of an event A:

p(C2)

p(C1)

p(E| C2)

p(E| C1)

p(C2| E)

p(C1 | E)

  

Before the Finding the prob. of Guilty was

«only» 50% higher that the prob of Not-Guilty.

After the Finding it is 7.5 times higher that Zac

is Guilty than that Zac is Not-Guilty

posterior Odds prior Odds

The probabilities in the diagnostic test

Test + Test –

Disease ok False negative

No Disease False positive ok

(Unknown)

Situation of

the subject

Result of the diagnostic test

Predictive values:

  • Of the positive test: p(Disease | Test +)
  • Of the negative test p(No Disease | Test –)

P(Disease)

«Prevalence»

They are computed using the Bayes f.la

We need to know the prior probability of the

disease

  • For that particular subject
  • In general in the population («prevalence»)

𝑝𝑟 𝐷 𝑇 + =

௣௥ ்ା |஽ ȉ௣௥ ஽

௣௥ ்ା |஽ ȉ௣௥ ஽ ା௣௥ ்ା |஽ഥ^ ȉ௣௥ ஽ഥ^

=

௦௘௡௦ȉ௣௥௘

௦௘௡௦ȉ௣௥௘௩ ଵି௦௣௘ ଵି௣௥௘௩

𝑝𝑟 𝐷

ഥ 𝑇 − =

௣௥ ்ି |஽ഥ^ ȉ௣௥ ஽ഥ

௣௥ ்ି |஽ഥ^ ȉ௣௥ ஽ഥ^ ା௣௥ ் ି |஽ ȉ௣௥ ஽

=

௦௣௘௖ȉ ଵି௣௥

௦௣௘௖ȉ ଵି ௣௥௘௩ ା ଵି ௦௘௡௦ ȉ௣௥௘௩

Application: diagnostic test

It is estimated that a disease affects 1 person out of 50. Detecting this

disease is invasive. A test based on a blood sample can detect diseased

people with sensitivity = 70% and specificity = 90%. We want to compute the

probability that a person with positive Test is diseased.

Events: PT= positive test ; D = disease

Information: p(PT|D)=0.7 p(not PT|not D) = 0.9 P(D) = 1/50=0.

Clinical question: P(D | PT)

We apply the Bayes formula:

1 − 𝑝𝑟 𝑛𝑜𝑡 𝑃𝑇 𝑛𝑜𝑡 𝐷 1 − 𝑝𝑟(𝐷)

Estimation of Sensitivity and Specificity

To estimate sensitivity and specificity of a new diagnostic technique we

consider a sample of subjects, that we could classify into “diseased” and “not

diseased” using the exact diagnostic technique. The subjects are then given

the new test, results are:

Test + Test –

Diseased tp fn d

Not Diseased fp tn n-d

tp+fp fn+tn n

n subjects among whom d

diseased, the other (n-d) not

diseased.

Among diseased, tp who got a

positive test are the “true

positive” and fn who got a

negative test are “false negative”.

etc

tp fn

tp

d

tp

sensitivity pT D

est

   

.

( | )

tn fp

tn

n d

tn

specificit y pT nD

est

  

.

( | )

Estimation of the Predictive Value

Apparently the positive predictive value P(Diseased | Test +) can be estimated

from the table in a straightforward way:

Test + Test –

Diseased tp fn d

Not Diseased fp tn n-d

tp+fp fn+tn n

tp fp

tp

pD T

est

 

???

.

( | )

This is in general NOT CORRECT! In fact to estimate the predictive value we need to

know (an estimate of) the prevalence of the disease. This is normally NOT the one

that we get from the sample, because the number of Diseased and Not Diseased is

fixed by the investigators, so it does not necessarily reproduce the prevalence in the

population (e.g. often we choose 2-3 Not-Diseased (“controls”) for every Diseased)

The formula above is correct only IF the prevalence in the experiment (=d/n) is equal

to the true prevalence in the population. (In this case, using the formula above or the

Bayes formula will return the same result, but this one is faster)

The game of tosses of a coin is an example of study of a random

variable

  • X = a non-certain number, varying due to chance, as a result of an

experiment

  • X is a random variable
  • Its probability distribution describes:
    • All possible values
    • The probability of the possible values

Random variables and probability distributions

How to make this

«description» depends on the

type of variable: is X discrete

or continuous?

The tools are similar to those seen in

Descriptive Statistics, i.e. respectively

percentages and density; synthetic

indexes: mean, variance

Random variables and probability distributions

  • A random variable X can be dichotomous, discrete with k values,

discrete with infinite values, continuous.

Prob πj

π

π

…

πk

Values

x

x

…

xk

Discrete r.v. with k modalities x1, x2, … xk

The distribution is

identified by k-

parameters = the

probabilities

πj = Pr(X = xj)

Continuous r.v.

13

12

14

10

The distribution is described by

a density curve f(x) and it is

identified by some parameters

Special case: dichotomous

variable (k=2)

X=0,1 e,g,

event A: False/True

The distribution is

identified by one

parameter only π (= p(A) )

 

b

a

f x dx

PX a b

a b

X

௝

The expected value and the variance

Given a random variable X, we define expected value the mean of all possible

values (weighted according to their probabilities)

 

 

EX x f x dx

EX x

j

j j

( ) 

Discrete random variable

Continuous random variable

E(X) is basically a representative value of all possible values of X, and thus the

value of X that we expect «on average» to get

Notice the similarity with the

f.la of the arithmetic mean of

observed data:

k

j

j j

x xf

1

Further we define the variance of the r.v., which measures the spread of the

possible values around the expected value:

ଶ

ଶ − 𝐸(𝑋)

ଶ

Concept and f.la similar to those

seen in Descriptive Statistics.

Example of calculation of the expected value

in the coin game (v. 2)

N=3 tosses of an unbalanced coin: Pr(Head)=0.3 Pr(Tail)=0.

X = number of Heads

X = 0 X = 1 X = 2 X = 3

p(X=0)

p(X=1)

p(X=2)

p(X=3)

 

i

j j

E( X) x   0  0. 343  1  0. 441  2  0. 189  3  0. 027  0. 9

Binomial in the coin game

X = 0 X = 1 X = 2 X = 3

p(X=0) =

p(X=1) =

p(X=2) =

p(X=3) =

i

j j Expected value: EX x p

Binomial with parameters

N=3 and π=0.

   

0 30 0 3 3

  1. 3 0. 7 110. 7

 P X

E( X)N  3  0. 3

Applying the

f-la of

Bi(3,0.3):

   

2 32 2 1

  1. 3 1 0. 3 30. 3 0. 7

 PX 

N=3 tosses of an unbalanced coin: Pr(Head)=0.3 Pr(Tail)=0.

X = number of Heads

Possible values

of X:

Probability of

the possible

values:

Binomial in the coin game

30 tosses of the coin with

Pr(Head)=0.3 Pr(Tail)=0.

X = number of Heads

X = 0, 1, 2, …, 29, 30

e.g. p(X = 12)

Binomial with

parameters N=

and p=0.

E( X)N  30  0. 3  9

Applying the

f.la of

Bi(30,0.3):

  0. 3  1 0. 3  0. 075

12 3012   

 P X

With large N it is difficult to compute how

many sequences of 30 elements H/T do

have exactly 12 elements=H and 18 (N-x)

elements=T

This number will then be multiplied by

12

18

Combinations

Binomial

Coefficient

(R: 86,493,225)

Possible values

of X:

Probability of

the possible

values:

The Poisson distribution

Number of events «success» in situations like «infinite trials».

Observing the occurrence of rare events along an interval of time (or a

surface, or in a territory). The event has a Rate of Success =λ, which also

represents the expected number of success. We could also say that the

probability of observing 1 success along a small interval of time dt is equal

to λ∙dt

It can be used in the typical Binomial case, with a finite but very large

number of trials N, and very small probability of success π. Fix the

parameter λ=Nπ. This approximation is valid if:

ଶ

E( X) 

!

( )

x

e

p X x

x



 

0

k

k k k k

e

e

«Law of rare events».

Renown

discrete

r.v.

var(X) 

A certain disease occurs only in 1 child out of 1000. Which is the probability

that in a sample of 50 children we observe 1 child with the disease? And that

we observe at least 1 child with the disease?

Random Variable: X = number of children with the disease

Information: p(disease)=π=0.001 number of trials: N=

Questions: Pr(X=1)

We use the Poisson with:

Pr(X>0) = 1- 0.95 = 0.05 = 5%

Application of the Poisson distribution

Pr( 0 )

  1. 05

  2. 05 0

e

e

X

=Pr(not X=0) = 1-Pr(X=0)

λ=N∙π= 50·0.001 = 0.

Pr(X≥1) =Pr(X=1 or X=2 or …)

Pr( 1 )

  1. 05

  2. 05 1

e

e

X

Pr( 2 )

  1. 05

  2. 05 2

e

e

X

Notice the

simplfication of

calculations

using previous

results