cpquery returns a numeric value, the conditional probability of event
conditional on evidence.
cpudist returns a data frame containing the observations generated from
the conditional distribution of the nodes conditional on evidence.
Logic Sampling
The event and evidence arguments must be two expressions
describing the event of interest and the conditioning evidence in a
format such that, if we denote with data the data set the network
was learned from, data[evidence, ] and data[event, ]
return the correct observations.
If either parameter is equal to TRUE an unconditional probability
query is performed.
Two tuning parameters are available:
n: a positive integer number, the number of random observations
to generate fromfitted. Defaults to5000 * nparams(fitted).
batch: a positive integer number, the size of each batch
of random observations. Defaults to10^4.
References
Koller D, Friedman N (2009). Probabilistic Graphical Models:
Principles and Techniques. MIT Press.
fitted = bn.fit(hc(learning.test), learning.test)
# the result should be around 0.025.cpquery(fitted, (B == "b"), (A == "a"))
table(cpdist(fitted, "A", (C == "c")))