26 Bayesian Networks: With Examples in R
> querygrain(jedu, nodes = c("S", "T"), type = "marginal")
$S
S
M F
0.6126 0.3874
$T
T
car train other
0.5594 0.2835 0.1571
As we have seen above, another possible choice is "joint", for the joint dis-
tribution of the nodes. The last valid value is "conditional". In this case
querygrain returns the distribution of the first node in nodes conditional on
the other nodes in nodes (and, of course, on the evidence we specified with
setEvidence).
> querygrain(jedu, nodes = c("S", "T"), type = "conditional")
T
S car train other
M 0.6126 0.6126 0.6126
F 0.3874 0.3874 0.3874
Note how the probabilities in each column sum up to 1, as they are computed
conditional on the value T assumes in that particular column.
Furthermore, we can ...