tests/testthat/test-random.test.data.R

test_that("random.test.data returns the expected structure", {
  set.seed(7)
  d <- random.test.data(nrows = 4, ncols = 5, vars.no = 3)
  expect_s3_class(d, "data.frame")
  expect_equal(nrow(d), 20)
  expect_equal(ncol(d), 1 + 2 + 2) # dep + (vars.no - 1) covariates + X,Y
  expect_false(anyNA(d))
})

test_that("random.test.data supports poisson and zip dependent variables", {
  set.seed(8)
  d.pois <- random.test.data(4, 4, 3, dep.var.dis = "poisson")
  expect_true(all(d.pois$dep >= 0))
  d.zip <- random.test.data(10, 10, 3, dep.var.dis = "zip")
  expect_true(any(d.zip$dep == 0))
})

Try the lctools package in your browser

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

lctools documentation built on July 9, 2026, 9:07 a.m.