tests/testthat/test_matrix2dag.r

test_that("general test case", {
  mat <- matrix(c(0, 0, 1, 0, 0, 1, 0, 0, 0), ncol=3, byrow=TRUE)
  colnames(mat) <- c("age", "sex", "death")
  rownames(mat) <- c("age", "sex", "death")

  type <- list(age="rnorm", sex="rbernoulli", death="binomial")

  out <- matrix2dag(mat=mat, type=type)

  expected <- empty_dag() +
    node("age", type="rnorm") +
    node("sex", type="rbernoulli") +
    node("death", type="binomial", parents=c("age", "sex"))

  expect_equal(out, expected)
})

Try the simDAG package in your browser

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

simDAG documentation built on April 3, 2025, 10:35 p.m.