tests/testthat/test_input_checks_node.r

test_that("name root node", {
  expect_error(node(c(1, 2), type="rbernoulli"))
})

test_that("name root node", {
  expect_error(node("A", type="something"))
})

test_that("name child node", {
  expect_error(node(c(1, 2), type="binomial", parents="C",
                    betas=1, intercept=2.1))
})

test_that("type child node", {
  expect_error(node("A", type="rbernoulli", parents="C",
                    betas=1))
})

test_that("parents child node", {
  expect_error(node("A", type="binomial", parents=list("A", "B"), betas=1))
})

test_that("error when using internal variable names", {
  expect_error({
    custom_fun <- function(data, parents, type_str) {
      return(1)
    }

    dag <- empty_dag() +
      node("A", type="rnorm") +
      node("Y", type=custom_fun, parents="A", type_str=20)
  })
})

Try the simDAG package in your browser

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

simDAG documentation built on Aug. 28, 2025, 1:08 a.m.