Outline Determining the graphical structure Milk test Mastitis - - PDF document

outline
SMART_READER_LITE
LIVE PREVIEW

Outline Determining the graphical structure Milk test Mastitis - - PDF document

Bayesian networks II. Model building Advanced Herd Management Anders Ringgaard Kristensen Outline Determining the graphical structure Milk test Mastitis diagnosis Pregnancy Determining the conditional probabilities


slide-1
SLIDE 1

1

Bayesian networks

  • II. Model building

Advanced Herd Management Anders Ringgaard Kristensen

Outline

Determining the graphical structure

Milk test Mastitis diagnosis Pregnancy

Determining the conditional probabilities Modeling methods and tricks

slide-2
SLIDE 2

2

Outline

Determining the graphical structure

Milk test Mastitis diagnosis Pregnancy

Determining the conditional probabilities Modeling methods and tricks

Milk test

Sensitivity/Specificity determines the conditional probabilities Direction of edge!

“Causal direction Against the “reasoning” direction

Infected? Infected?

{“Yes”, “No”} {“Positive”, “Negative”}

slide-3
SLIDE 3

3

Daily measurements

Are the infection states of different days independent? Probably not! Markov property Duration of disease

Inf1 Inf2 Inf3 Inf7 Inf6 Inf5 Inf4 Test1 Test2 Test3 Test7 Test6 Test5 Test4

Dependence between test results

Correctness of test depends on whether it was correct yesterday. To determine whether it was correct yesterday:

The true infection state yesterday

Not observed – we need the conditional probabilities.

The test result yesterday

Inf1 Inf2 Inf3 Inf7 Inf6 Inf5 Inf4 Test1 Test2 Test3 Test7 Test6 Test5 Test4

slide-4
SLIDE 4

4

Dependence between test results

A simplifying intermediate variable Cori ∈ {“yes”, “no”} indicating whether the test was correct.

Inf1 Inf2 Inf3 Inf7 Inf6 Inf5 Inf4 Test1 Test2 Test3 Test7 Test6 Test5 Test4 Cor1 Cor2 Cor3 Cor4 Cor5 Cor6

Mastitis diagnosis, AMS

Separate variables (don’t pool mastitis & heat) Check conditional independence

Are “Conductivity” and “Temperature” independent, given “Mastitis”?

Mastitis Heat Conductivity Temperature

No Subclinical Clinical No Yes

slide-5
SLIDE 5

5

Mastitis diagnosis, AMS

Separate variables (don’t pool mastitis & heat) Check conditional independence

Are “Conductivity” and “Temperature” independent, given “Mastitis”?

Mastitis Heat Conductivity Temperature

No Subclinical Clinical No Yes

If not conditional independent

If conductivity influences temperature.

Mastitis Heat Conductivity Temperature

No Subclinical Clinical No Yes

slide-6
SLIDE 6

6

If not conditional independent

If temperature influences conductivity.

The causal direction may be difficult to determine

Mastitis Heat Conductivity Temperature

No Subclinical Clinical No Yes

If not conditional independent

If the direction of an edge cannot be determined, a variable is often missing!

Mastitis Heat Conductivity Temperature

No Subclinical Clinical No Yes

Other disease

slide-7
SLIDE 7

7

Pregnancy (again, again …)

A goat is mated, and six weeks later we want to test it for pregnancy. We have three tests available:

Blood test Urine test Scanning

The variables of our problem are:

Pregnant {“yes”, “no”} Blood {“positive”, “negative”} Urine {“positive”, “negative”} Scan {“positive”, “negative”}

Pregnancy test BN

Check for conditional independence

Pregnant Urine Scan Blood

slide-8
SLIDE 8

8

Pregnancy test BN, revised

The blood test and the urine test both measure a hormone level. The scanning does something completely different.

Pregnant Urine Scan Blood Hormone

Outline

Determining the graphical structure

Milk test Mastitis diagnosis Pregnancy

Determining the conditional probabilities Modeling methods and tricks

slide-9
SLIDE 9

9

Determining the probabilities

Statistical model with parameters estimated from data. Law of nature. Experts of the domain.

Milk test example

The P(Testi | Infi) conditional probability is supplied by the test retailer.

Inf1 Inf2 Inf3 Inf7 Inf6 Inf5 Inf4 Test1 Test2 Test3 Test7 Test6 Test5 Test4 Cor1 Cor2 Cor3 Cor4 Cor5 Cor6

slide-10
SLIDE 10

10

P(Testi | Infi)

0.99 0.01 Infi = “no” 0.01 0.99 Infi = “yes” P(Testi=“yes”|Infi ) P(Testi=“yes”|Infi ) Defined by the sensitivity and specificity of the test.

Milk test example

The P(Cori | Infi, Testi) conditional probability is trivial.

Inf1 Inf2 Inf3 Inf7 Inf6 Inf5 Inf4 Test1 Test2 Test3 Test7 Test6 Test5 Test4 Cor1 Cor2 Cor3 Cor4 Cor5 Cor6

slide-11
SLIDE 11

11

P(Cori | Infi, Testi)

If Infi and Testi agree, the test is correct! 1 “yes” “yes” 1 “no” “no” 1 “yes” “no” 1 “no” “yes” P(Cori=n|Infi,Testi) P(Cori=y|Infi,Testi) Testi Infi

Milk test example

The P(Testi | Infi, Cori-1) conditional probabilities needs some assumptions.

Inf1 Inf2 Inf3 Inf7 Inf6 Inf5 Inf4 Test1 Test2 Test3 Test7 Test6 Test5 Test4 Cor1 Cor2 Cor3 Cor4 Cor5 Cor6

slide-12
SLIDE 12

12

P(Testi | Infi, Cori-1)

Assumptions:

A correct test has 99.9% chance of being correct next time. An incorrect test has 30% chance of being incorrect next time:

Thus, it is still most likely to be correct. In agreement with the example file provided from the homepage. In disagreement with the textbook.

P(Testi | Infi, Cori-1)

0.001 0.999 “yes” “yes” 0.3 0.7 “no” “no” 0.999 0.001 “yes” “no” 0.3 0.7 “no” “yes” P(Testi=n|Infi,Cori-1) P(Testi=y|Infi,Cori-1) Cori-1 Infi

slide-13
SLIDE 13

13

Milk test example

The P(Inf1) probabilities must be modeled.

Inf1 Inf2 Inf3 Inf7 Inf6 Inf5 Inf4 Test1 Test2 Test3 Test7 Test6 Test5 Test4 Cor1 Cor2 Cor3 Cor4 Cor5 Cor6

P(Inf1)

Assume that the milk test is made on single cow level at the farm. We need the probability λ that the milk from a particular cow is infected on an arbitrary day (i.e. P(Infi = “yes”) = λ). The farmer has no knowledge about λ, but The dairy performs a very precise bulk tank test:

If the milk from just one cow is infected, the bulk tank test will be positive. On average, the bulk tank test is positive once a month

slide-14
SLIDE 14

14

P(Inf1)

Further assumptions:

λ is the same for all cows Cows are infected independently.

Under those assumptions: (1 - λ)50 = 29/30 ⇔ λ = 1 – (29/30)0.02 ≈ 0.0007

Milk test example

The P(Infi | Infi-1) conditional probabilities must be modeled.

Inf1 Inf2 Inf3 Inf7 Inf6 Inf5 Inf4 Test1 Test2 Test3 Test7 Test6 Test5 Test4 Cor1 Cor2 Cor3 Cor4 Cor5 Cor6

slide-15
SLIDE 15

15

P(Infi | Infi-1, Infi-2)

Assume the following properties of the infection:

A not-infected cow has probability q of becoming infected. An infection always lasts for at least 2 days After 2 days, the probability of recovery is π Define a state space model: si ∈ {nn, ny, yn, yy} where e.g. “ny” means: not-infected day i-1 but infected day i

P(Infi | Infi-1, Infi-2)

Transition propabilities: (1-q) (1-q) nn Day i+1 Day i P(yes) yy yn ny (1-π) (1-π) π yy q q yn 1 1 ny q q nn Only assumptions on min. duration, q and π

slide-16
SLIDE 16

16

A procedure

There are basically 3 parameters:

Duration minimum 2 days Probability of becoming infected q Daily probability of recovery π (after 2 days)

The 3 parameters should be estimated from data. If data is not available, we may have to rely on experts. Experts’ guesses may be calibrated to the overall probability of infection at a given day.

Limiting state distribution

slide-17
SLIDE 17

17

Milk test example

The P(Infi | Infi-1) conditional probabilities must be modeled.

Inf1 Inf2 Inf3 Inf7 Inf6 Inf5 Inf4 Test1 Test2 Test3 Test7 Test6 Test5 Test4 Cor1 Cor2 Cor3 Cor4 Cor5 Cor6

P(Infi | Infi-1)

Some assumption compensating for the fact that we don’t know the infection state two days ago…

slide-18
SLIDE 18

18

A stud farm: Genealogical tree

John is suffering from a serious hereditary disease caused by a recessive gene. State space for a horse: aa, aA or AA The genotype aa is diseased. The genotype aA is carrier. We want to cull all carriers!

Ann Brian Cecily Fred Dorothy Eric Gwenn Henry Irene John

Contitional probabilities from genetics

Father Mother (0, 0, 1) (0, 0.5, 0.5) (0, 1, 0) AA (0, 0.5, 0.5) (0.25, 0.5, 0.25) (0.5, 0.5, 0) aA (0, 1, 0) (0.5, 0.5, 0) (1, 0, 0) aa AA aA aa

slide-19
SLIDE 19

19

Unknown parents

Two unknown parents:

Assume that the distribution reflects the population probabilities of being healthy or carrier (if they had beem diseased they would not have survived until “breeding age”).

One unknown parent:

Introduce a “dummy” parent reflecting the population distribution.

The diseased state “aa”

Impossible for all other horses than John Two options:

Delete the state and adjust all probabilities accordingly. Keep the state and enter the evidence that the horses are either healthy or carriers

slide-20
SLIDE 20

20

Obtaining the probabilities

Sources:

Pure data estimation (frequency counts) Model and parameter estimation from data Provided “by nature” Subjective expert assessments

Outline

Determining the graphical structure

Milk test Mastitis diagnosis Pregnancy

Determining the conditional probabilities Modeling methods and tricks

slide-21
SLIDE 21

21

Logical constraints: SIR model

We observe the spread of a contagious disease in a population of, say 50 animals. Each animal is either

Susceptible Infective Removed (recovered/dead)

Let Si, Ii and Ri be the number of susceptible, infective and removed, respectively, at time i

The SIR model

Basic problem: Si, Ii and Ri are not independent

Cannot be solved by directed (causal) edges.

Even though the conditional probabilities of the model may be correct, it may happen that Si + Ii + Ri ≠ 50

S1 R1 I1 S2 R2 I2 S3 R3 I3

slide-22
SLIDE 22

22

The SIR model

P(Ci = Valid | Si, Ii, Ri) = 1 if Si + Ii + Ri = 50 P(Ci = Valid | Si, Ii, Ri) = 0 if Si + Ii + Ri ≠ 50 Enter the evidence P(Ci = Valid) and propagate

S1 R1 I1 S2 R2 I2 S3 R3 I3

C1 C1 C1

{“Valid”, “Invalid”}

Logical constraints

Refer also to the sock-sorting problem in the textbook.