Assign, extract or compute various quantities of interest from objects of
class bn.fit, bn.fit.dnode, bn.fit.gnode,
bn.fit.cgnode or bn.fit.onode.
## methods available for "bn.fit"
# S3 method for bn.fit
fitted(object, ...)
# S3 method for bn.fit
coef(object, ...)
# S3 method for bn.fit
residuals(object, ...)
# S3 method for bn.fit
sigma(object, ...)
# S3 method for bn.fit
logLik(object, data, nodes, by.sample = FALSE, na.rm = FALSE, debug = FALSE, ...)
# S3 method for bn.fit
AIC(object, data, ..., k = 1)
# S3 method for bn.fit
BIC(object, data, ...)## non-method functions for "bn.fit"
identifiable(x, by.node = FALSE)
singular(x, by.node = FALSE)
## methods available for "bn.fit.dnode"
# S3 method for bn.fit.dnode
coef(object, for.parents, ...)
## methods available for "bn.fit.onode"
# S3 method for bn.fit.onode
coef(object, for.parents, ...)
## methods available for "bn.fit.gnode"
# S3 method for bn.fit.gnode
fitted(object, ...)
# S3 method for bn.fit.gnode
coef(object, ...)
# S3 method for bn.fit.gnode
residuals(object, ...)
# S3 method for bn.fit.gnode
sigma(object, ...)
## methods available for "bn.fit.cgnode"
# S3 method for bn.fit.cgnode
fitted(object, ...)
# S3 method for bn.fit.cgnode
coef(object, for.parents, ...)
# S3 method for bn.fit.cgnode
residuals(object, ...)
# S3 method for bn.fit.cgnode
sigma(object, for.parents, ...)
logLik() returns a numeric vector or a single numeric value, depending
on the value of by.sample. AIC and BIC always return a
single numeric value.
All the other functions return a list with an element for each node in the
network (if object has class bn.fit) or a numeric vector or
matrix (if object has class bn.fit.dnode, bn.fit.gnode,
bn.fit.cgnode, bn.fit.onode, bn.fit.zihpnode,
bn.fit.zinbnode.).
coef() (and its alias coefficients()) extracts model
coefficients (that is, conditional probabilities for discrete nodes; linear
regression coefficients for Gaussian and conditional Gaussian nodes;
regression coefficients of the count and zero-inflation components for
zero-inflated nodes).
residuals() (and its alias resid()) extracts model residuals,
and fitted() (and its alias
fitted.values()) extracts fitted
values from nodes other than discrete ones. If the bn.fit object does
not include the residuals or the fitted values for the node of interest, both
functions return NULL.
sigma() extracts the standard deviations of the residuals from Gaussian
and conditional Gaussian networks and nodes.
logLik() returns the log-likelihood for the observations in
data. If na.rm is set to TRUE, the log-likelihood will be
NA if the data contain missing values. If na.rm is set to
FALSE, missing values will be dropped, and the log-likelihood will be
computed using only locally-complete observations (effectively returning the
node-average log-likelihood times the sample size). Note that the
log-likelihood may be NA even if na.rm = TRUE if the network
contains NA parameters or is singular.
The for.parents argument in the methods for coef() and
sigma() can be used to have both functions return the parameters
associated with a specific configuration of the discrete parents of a node.
If for.parents is not specified, all relevant parameters are returned.
bn.fit, bn.fit-class.
data(gaussian.test)
dag = hc(gaussian.test)
fitted = bn.fit(dag, gaussian.test)
coefficients(fitted)
coefficients(fitted$C)
str(residuals(fitted))
data(learning.test)
dag2 = hc(learning.test)
fitted2 = bn.fit(dag2, learning.test)
coefficients(fitted2$E)
coefficients(fitted2$E, for.parents = list(F = "a", B = "b"))
Run the code above in your browser using DataLab