tests/testthat/test-w.matrix.R

test_that("w.matrix returns a valid binary adaptive weights matrix", {
  set.seed(42)
  d <- random.test.data(nrows = 6, ncols = 6)
  w <- w.matrix(cbind(d$X + runif(36), d$Y + runif(36)), 4,
                WType = "Binary", family = "adaptive")
  expect_equal(dim(w), c(36, 36))
  expect_true(all(diag(w) == 0))
  expect_true(all(w %in% c(0, 1)))
  expect_true(all(rowSums(w) >= 4))
})

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.