bn.fit {bnlearn} | R Documentation |
Fit the parameters of a Bayesian network conditional on its structure.
bn.fit(x, data, debug = FALSE)
x |
an object of class bn . |
data |
a data frame, containing the variables in the model. |
debug |
a boolean value. If TRUE a lot of debugging output
is printed; otherwise the function is completely silent. |
An object of class bn.fit
. See bn.fit class
for
details.
Due to the way Bayesian networks are defined it's possible to
estimate their parameters only if the network structure is
completely directed (i.e. there are no undirected arcs). See
set.arc
and pdag2dag
for two ways
of manually setting the direction of one or more arcs.
Marco Scutari
data(learning.test) # learn the network structure. res = gs(learning.test) # set the direction of the only undirected arc, A - B. res = set.arc(res, "A", "B") # estimate the parameters of the Bayesian network. fitted = bn.fit(res, learning.test)