Learn R Programming

bnlearn (version 2.9)

bn.fit: Fit the parameters of a Bayesian network

Description

Fit the parameters of a Bayesian network conditional on its structure.

Usage

bn.fit(x, data, method = "mle", ..., debug = FALSE)
bn.net(x, debug = FALSE)

Arguments

x
an object of class bn (for bn.fit) or an object of class bn.fit (for bn.net).
data
a data frame containing the variables in the model.
method
a character string, either mle for Maximum Likelihood parameter estimation or bayes for Bayesian parameter estimation (currently implemented only for discrete data).
...
additional arguments for the parameter estimation prcoedure, see below.
debug
a boolean value. If TRUE a lot of debugging output is printed; otherwise the function is completely silent.

Value

  • bn.fit returns an object of class bn.fit, bn.net an object of class bn. See bn class and bn.fit class for details.

Details

bn.fit fits the parameters of a Bayesian network given its structure and a data set; bn.net returns the network structure underlying a fitted network.

See Also

bn.fit utilities, bn.fit plots.

Examples

Run this code
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)

Run the code above in your browser using DataLab