tests/testthat/test_sl.R

library(bnstruct)
context("Testing CPTs")

dataset <- child()
dataset <- impute(dataset)
net <- learn.network(dataset)

dag <- dag(net)
s <- sapply(1:num.nodes(net), function(x) {
  parents <- which(dag[,x] > 0)
  prod(node.sizes(net)[parents])
})

test_that("sum of cpts", {
  expect_equal(sum(unlist(cpts(net))), sum(s))
})

Try the bnstruct package in your browser

Any scripts or data that you put into this service are public.

bnstruct documentation built on Dec. 1, 2022, 1:22 a.m.