94 3 Probability, Conditional Probability, and Bayes’ Rule
p.alarm = structure(.Data = c(0.999, 0.001,
0.71,0.29,
0.06,0.94,
0.05,0.95), .Dim = c(2,2,2)),
p.mary = structure(.Data = c(0.99,0.01,0.30,0.70), .Dim = c(2,2)),
burglary = 2,
mary=2
)
and change the initial values to
list(earthquake = 1, alarm = 1, john = 1)
After 10,000 iterations, the mean value of J is obtained as EJ = 2 · p
J
+
(1
p
J) =1.899. Then, P(J|M,B) = p
J
=0.899. Thus, the final result is
P(J, M|B) =P(J|M,B)P(M|B) = p
J
· p
M
=0.899 ·0.661 =0.5942
(which approximates 0.5922, from the exact probability calculation).
Bayesian networks can be useful in medical diagnostics if the conditional
probabilities of the nodes are known. Here is the celebrated “Asia” example.
Example 3.21. Asia. Lauritzen and Spiegelhalter (1988) discuss a fictitious
expert system for diagnosing a patient admitted to a chest clinic, who just re-
turned from a trip to Asia and is experiencing dyspnoea.
2
A graphical model
for the underlying process is shown in Fig. 3.17, where each variable is binary.
The WinBUGS code is shown below with the conditional probabilities given as
in Lauritzen and Spiegelhalter (1988).
model Asia;
asia ~ dcat(p.asia);
smoking ~ dcat(p.smoking[]);
tuberculosis ~ dcat(p.tuberculosis[asia,]);
lung.cancer ~ dcat(p.lung.cancer[smoking,]);
bronchitis ~ dcat(p.bronchitis[smoking,]);
either <- max(tuberculosis,lung.cancer);
xray ~ dcat(p.xray[either,]);
dyspnoea ~ dcat(p.dyspnoea[either,bronchitis,])
DATA
list(asia = 2, dyspnoea = 2,
p.tuberculosis = structure(.Data = c(0.99,0.01,0.95,0.05),
.Dim = c(2,2)),
p.bronchitis = structure(.Data = c(0.70,0.30,0.40,0.60),
.Dim = c(2,2)),
p.smoking = c(0.50,0.50),
2
Difficulty in breathing, often associated with lung or heart disease and resulting in short-
ness of breath. Also called air hunger.