tests/testthat/test_sl.R

library(bnstruct)

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 May 29, 2024, 3:17 a.m.