Learn R Programming

bnlearn (version 3.1)

score: Score of the Bayesian network

Description

Compute the score of the Bayesian network.

Usage

score(x, data, type = NULL, ..., debug = FALSE)

## S3 method for class 'bn': logLik(object, data, ...) ## S3 method for class 'bn': AIC(object, data, ..., k = 1) ## S3 method for class 'bn': BIC(object, data, ...)

Arguments

x, object
an object of class bn.
data
a data frame containing the data the Bayesian network was learned from.
type
a character string, the label of a network score. If none is specified, the default score is the Bayesian Information Criterion for both discrete and continuous data sets. See bnlear
debug
a boolean value. If TRUE a lot of debugging output is printed; otherwise the function is completely silent.
...
extra arguments from the generic method (for the AIC and logLik functions, currently ignored) or additional tuning parameters (for the score function).
k
a numeric value, the penalty per parameter to be used; the default k = 1 gives the expression used to compute the AIC in the context of scoring Bayesian networks.

Value

  • A numeric value, the score of the Bayesian network.

Details

Additional parameters of the score function:

  • iss: the imaginary sample size, used by the Bayesian Dirichlet equivalent score (both thebdeandmbde) and the Bayesian Gaussian posterior density. It is also known asequivalent sample size. The default value is equal to10for both thebde/mbdescores andbge.
  • exp: a list of indexes of experimental observations (those that have been artificially manipulated). Each element of the list must be named after one of the nodes, and must contain a numeric vector with indexes of the observations whose value has been manipulated for that node.
  • k: the penalty per parameter to be used by the AIC and BIC scores. The default value is1for AIC andlog(nrow(data))/2for BIC.
  • phi: the prior phi matrix formula to use in the Bayesian Gaussian equivalent (bge) score. Possible values areheckerman(default) andbottcher(the one used by default in thedealpackage.)

References

Chickering DM (1995). "A Transformational Characterization of Equivalent Bayesian Network Structures". In "UAI '95: Proceedings of the Eleventh Annual Conference on Uncertainty in Artificial Intelligence", pp. 87-98. Morgan Kaufmann.

Geiger D, Heckerman D (1994). "Learning Gaussian Networks". Technical report, Microsoft Research. Available as Technical Report MSR-TR-94-10.

Heckerman D, Geiger D, Chickering DM (1995). "Learning Bayesian Networks: The Combination of Knowledge and Statistical Data". Machine Learning, 20(3), 197-243. Available as Technical Report MSR-TR-94-09.

Cooper GF, Yoo C (1999). "Causal Discovery from a Mixture of Experimental and Observational Data". In "UAI '99: Proceedings of the Fifteenth Annual Conference on Uncertainty in Artificial Intelligence", pp. 116-125. Morgann Kaufmann.

See Also

choose.direction, arc.strength.

Examples

Run this code
data(learning.test)
res = set.arc(gs(learning.test), "A", "B")
score(res, learning.test, type = "bde")
# [1] -23967.65
## let's see score equivalence in action!
res2 = set.arc(gs(learning.test), "B", "A")
score(res2, learning.test, type = "bde")
# [1] -23967.65

## k2 score on the other hand is not score equivalent.
score(res, learning.test, type = "k2")
# [1] -23958.70
score(res2, learning.test, type = "k2")
# [1] -23957.68

## equivalent to logLik(res, learning.test)
score(res, learning.test, type = "loglik")
# [1] -23832.13

## equivalent to AIC(res, learning.test)
score(res, learning.test, type = "aic")
# [1] -23873.13

Run the code above in your browser using DataLab