| Index | Topics |
| bn.fit utilities {bnlearn} | R Documentation |
Utilities to manipulate fitted Bayesian networks
Description
Assign, extract or compute various quantities of interest from an object of class bn.fit,
bn.fit.dnode or bn.fit.gnode.
Usage
## methods available for "bn.fit" ## S3 method for class 'bn.fit': fitted(object, ...) ## S3 method for class 'bn.fit': coef(object, ...) ## S3 method for class 'bn.fit': residuals(object, ...) ## S3 method for class 'bn.fit': predict(object, node, data, ...) ## S3 method for class 'bn.fit': logLik(object, data, ...) ## S3 method for class 'bn.fit': AIC(object, data, ..., k = 1) ## methods available for "bn.fit.dnode" ## S3 method for class 'bn.fit.dnode': coef(object, ...) ## S3 method for class 'bn.fit.dnode': predict(object, data, ...) ## methods available for "bn.fit.gnode" ## S3 method for class 'bn.fit.gnode': fitted(object, ...) ## S3 method for class 'bn.fit.gnode': coef(object, ...) ## S3 method for class 'bn.fit.gnode': residuals(object, ...) ## S3 method for class 'bn.fit.gnode': predict(object, data, ...)
Arguments
object |
an object of class bn.fit, bn.fit.dnode or bn.fit.gnode. |
node |
a character string, the label of a node. |
data |
a data frame containing the variables in the model. |
... |
additional arguments (currently ignored). |
k |
a numeric value, the penalty per parameter to be used; the default k = 1 gives the
expression used to compute AIC. |
Details
coef (and its alias coefficients) extracts model coefficients (which are
conditional probabilities in discrete networks and linear regression coefficients in Gaussian networks).
residuals (and its alias resid) extracts model residuals and fitted
(and its alias fitted.values) extracts fitted values from fitted Gaussian networks.
predict returns the predicted values for node for the data specified by
data.
Value
predict returns a numeric vector (for Gaussian networks) or a factor (for discrete
networks).
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 (if object has class bn.fit.dnode or
bn.fit.gnode).
Author(s)
Marco Scutari
See Also
Examples
data(gaussian.test) res = hc(gaussian.test) fitted = bn.fit(res, gaussian.test) coefficients(fitted) # $A # (Intercept) # 1.007493 # # $B # (Intercept) # 2.039499 # # $C # (Intercept) A B # 2.001083 1.995901 1.999108 # # $D # (Intercept) B # 5.995036 1.498395 # # $E # (Intercept) # 3.493906 # # $F # (Intercept) A D E G # -0.006047321 1.994853041 1.005636909 1.002577002 1.494373265 # # $G # (Intercept) # 5.028076 # coefficients(fitted$C) # (Intercept) A B # 2.001083 1.995901 1.999108 str(residuals(fitted)) # List of 7 # $ A: num [1:5000] 0.106 -1.255 0.847 -0.174 -0.519 ... # $ B: num [1:5000] -0.107 9.295 0.993 1.818 2.473 ... # $ C: num [1:5000] -1.01 0.183 -0.677 -0.153 -1.997 ... # $ D: num [1:5000] -0.23 0.377 0.518 0.162 -0.22 ... # $ E: num [1:5000] -2.612 3.546 0.341 -2.488 0.591 ... # $ F: num [1:5000] -0.861 1.271 -0.262 -0.479 -0.782 ... # $ G: num [1:5000] 4.1883 -1.3492 -2.6036 1.0574 0.0895 ... data(learning.test) res2 = hc(learning.test) fitted2 = bn.fit(res2, learning.test) coefficients(fitted2$E) # , , F = a # # B # E a b c # a 0.1902 0.0126 0.0244 # b 0.0230 0.0110 0.0234 # c 0.0230 0.0376 0.1566 # # , , F = b # # B # E a b c # a 0.0946 0.0166 0.0498 # b 0.1158 0.0192 0.1062 # c 0.0258 0.0166 0.0536
| Index | Topics |
