bn.fit.methods: Utilities to manipulate fitted Bayesian networks

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Assign, extract or compute various quantities of interest from an object of class bn.fit, bn.fit.dnode, bn.fit.gnode, bn.fit.cgnode or bn.fit.onode.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
## 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'
sigma(object, ...)
## S3 method for class 'bn.fit'
logLik(object, data, nodes, by.sample = FALSE, ...)
## S3 method for class 'bn.fit'
AIC(object, data, ..., k = 1)
## S3 method for class 'bn.fit'
BIC(object, data, ...)

## methods available for "bn.fit.dnode"
## S3 method for class 'bn.fit.dnode'
coef(object, ...)

## methods available for "bn.fit.onode"
## S3 method for class 'bn.fit.onode'
coef(object, ...)

## 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'
sigma(object, ...)

## methods available for "bn.fit.cgnode"
## S3 method for class 'bn.fit.cgnode'
fitted(object, ...)
## S3 method for class 'bn.fit.cgnode'
coef(object, ...)
## S3 method for class 'bn.fit.cgnode'
residuals(object, ...)
## S3 method for class 'bn.fit.cgnode'
sigma(object, ...)

Arguments

object

an object of class bn.fit, bn.fit.dnode, bn.fit.gnode, bn.fit.cgnode or bn.fit.onode.

nodes

a vector of character strings, the label of a nodes whose log-likelihood components are to be computed.

data

a data frame containing the variables in the model.

...

additional arguments, currently ignored.

k

a numeric value, the penalty coefficient to be used; the default k = 1 gives the expression used to compute AIC.

by.sample

a boolean value. If TRUE, logLik() returns a vector containing the the log-likelihood of each observations in the sample. If FALSE, logLik() returns a single value, the likelihood of the whole sample.

Details

coef() (and its alias coefficients()) extracts model coefficients (which are conditional probabilities for discrete nodes and linear regression coefficients for Gaussian and conditional Gaussian nodes).

residuals() (and its alias resid()) extracts model residuals and fitted() (and its alias fitted.values()) extracts fitted values from Gaussian and conditional Gaussian nodes. 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.

Value

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 or bn.fit.onode).

Author(s)

Marco Scutari

See Also

bn.fit, bn.fit-class.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11

Example output

Attaching package: 'bnlearn'

The following object is masked from 'package:stats':

    sigma

$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 

(Intercept)           A           B 
   2.001083    1.995901    1.999108 
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 ...
, , F = a

   B
E            a          b          c
  a 0.80524979 0.20588235 0.11937378
  b 0.09737511 0.17973856 0.11448141
  c 0.09737511 0.61437908 0.76614481

, , F = b

   B
E            a          b          c
  a 0.40050804 0.31679389 0.23759542
  b 0.49026249 0.36641221 0.50667939
  c 0.10922947 0.31679389 0.25572519

bnlearn documentation built on Jan. 15, 2018, 5:06 p.m.