score {bnlearn} | R Documentation |
Compute the score of the Bayesian network.
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)
x |
an object of class "bn". |
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 score.
Possible values are lik
(multinomial likelihood), loglik (multinomial
loglikelihood), aic (Akaike Information Criterion),
bic (Bayesian Information Criterion), k2
(K2 score), bde or dir (Bayesian
dirichlet posterior density), bge (Bayesian
gaussian posterior density). If none is specified, the default
score is the Akaike Information Criterion for discrete
data sets and the Bayesian gaussian posterior density
for discrete ones. See bnlearn-package
for details. |
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. |
Additional parameters of the score
function:
iss
: the imaginary sample size, used by the Bayesian
Dirichlet equivalent score and the Bayesian gaussian posterior
density. The default value is twice the number of cells of the
joint contingency table (for compatibility with the deal
package) for the bde
score, and twice the number of
independent parameters for the bge
score.
k
: the penalty per parameter to be used by the AIC and
BIC scores. Thr default value is 1
for AIC and
log(nrow(data))/2
for BIC.
phi
: the prior phi matrix formula to use in the
Bayesian Gaussian equivalent (bge
) score. Possible
values are heckerman
(default) and bottcher
(the one used by default in the deal package.)
A numeric value, the score of the Bayesian network.
Only discrete Bayesian networks are supported.
The execution time scales linearly with the sample size.
Marco Scutari
D. M. Chickering. A Transformational Characterization of Equivalent Bayesian Network Structures. In Proceedins of 11th Conference on Uncertainty in Artificial Intelligence, pages 87-98. Morgan Kaufmann Publishers Inc., 1995.
D. Heckerman, D. Geiger and D. Chieckering. Learning Bayesian Networks: The Combination of Knowledge and Statistical Data. Microsoft Research Technical Report MSR-TR-94-09.
data(learning.test) res = set.arc(gs(learning.test), "A", "B") score(res, learning.test, type = "bde") # [1] -25005.24 ## let's see score equivalence in action! res2 = set.arc(gs(learning.test), "B", "A") score(res2, learning.test, type = "bde") # [1] -25005.24 ## 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