tests/testthat/test_lrtest.R

library(corncob)
context("Test lrtest")

set.seed(1)
seq_depth <- rpois(20, lambda = 10000)
my_counts <- rbinom(20, size = seq_depth, prob = 0.001) * 10
my_covariate <- cbind(rep(c(0,1), each = 10), rep(c(0,1), 10))
colnames(my_covariate) <- c("X1", "X2")

test_data <- data.frame("W" = my_counts, "M" = seq_depth, my_covariate)

out1 <- bbdml(formula = cbind(W, M - W) ~ 1,
              phi.formula = ~ 1,
              data = test_data,
              link = "logit",
              phi.link = "logit",
              nstart = 1)

out2 <- bbdml(formula = cbind(W, M - W) ~ X1,
             phi.formula = ~ X1,
             data = test_data,
             link = "logit",
             phi.link = "logit",
             nstart = 1)


test_that("lrtest works", {
  expect_is(lrtest(mod = out2, mod_null = out1), "numeric")
})

Try the corncob package in your browser

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

corncob documentation built on Aug. 31, 2023, 9:06 a.m.