Skip to contents

KL.bn.fit returns the Kullback-Leibler (KL) divergence between a Bayesian network and its update after parameter variation.

Usage

# S3 method for bn.fit
KL(
  x,
  node,
  value_node,
  value_parents,
  new_value,
  covariation = "proportional",
  ...
)

Arguments

x

object of class bn.fit.

node

character string. Node of which the conditional probability distribution is being changed.

value_node

character string. Level of node.

value_parents

character string. Levels of node's parents. The levels should be defined according to the order of the parents in bnfit[[node]][["parents"]]. If node has no parents, then it should be set to NULL.

new_value

numeric vector with elements between 0 and 1. Values to which the parameter should be updated. It can take a specific value or more than one. In the case of more than one value, these should be defined through a vector with an increasing order of the elements. new_value can also be set to the character string all: in this case a sequence of possible parameter changes ranging from 0.05 to 0.95 is considered.

covariation

character string. Co-variation scheme to be used for the updated Bayesian network. Can take values uniform, proportional, orderp, all. If equal to all, uniform, proportional and order-preserving co-variation schemes are used. Set by default to proportional.

...

additional parameters to be added to the plot.

Value

A dataframe with the varied parameter and the KL divergence for different co-variation schemes. If plot = TRUE the function returns a plot of the KL divergences.

Details

The Bayesian network on which parameter variation is being conducted should be expressed as a bn.fit object. The name of the node to be varied, its level and its parent's levels should be specified. The parameter variation specified by the function is:

P ( node = value_node | parents = value_parents ) = new_value

References

Kullback, S., & Leibler, R. A. (1951). On information and sufficiency. The annals of mathematical statistics, 22(1), 79-86.

Leonelli, M., Goergen, C., & Smith, J. Q. (2017). Sensitivity analysis in multilinear probabilistic models. Information Sciences, 411, 84-97.

See also

Examples

KL(synthetic_bn, "y2", "1", "2", "all", "all")
#>    New_value     Uniform Proportional Order Preserving
#> 1       0.05 0.099278412  0.097128206     9.712821e-02
#> 2       0.10 0.048249282  0.046099076     4.609908e-02
#> 3       0.15 0.023760689  0.021610483     2.161048e-02
#> 4       0.20 0.010600473  0.008450267     8.450267e-03
#> 5       0.25 0.004070643  0.001920437     1.920437e-03
#> 6       0.30 0.002150206  0.000000000    -1.998401e-17
#> 7       0.30 0.002150206  0.000000000    -1.998401e-17
#> 8       0.35 0.003839319  0.001689113               NA
#> 9       0.40 0.008630462  0.006480256               NA
#> 10      0.45 0.016302378  0.014152172               NA
#> 11      0.50 0.026835069  0.024684864               NA
#> 12      0.55 0.040382862  0.038232656               NA
#> 13      0.60 0.057286275  0.055136069               NA
#> 14      0.65 0.078124024  0.075973818               NA
#> 15      0.70 0.103825949  0.101675743               NA
#> 16      0.75 0.135904118  0.133753912               NA
#> 17      0.80 0.176955797  0.174805591               NA
#> 18      0.85 0.231912816  0.229762610               NA
#> 19      0.90 0.311916231  0.309766025               NA
#> 20      0.95 0.452611089  0.450460883               NA
KL(synthetic_bn, "y1", "2", NULL, 0.3, "all")
#>   New_value    Uniform Proportional Order Preserving
#> 1       0.3 0.06641431            0                0