tests/testthat/test_grouped_glm.R

test_that('correct results for glm_grouped()', {
  ucb_weighted <- as.data.frame(UCBAdmissions)
  ucb_weighted$Freq <- as.integer(ucb_weighted$Freq)

  ucb_long <- tidyr::uncount(ucb_weighted, Freq)

  ungrouped <- glm(Admit ~ Gender + Dept, data = ucb_long, family = binomial)

  expect_error(
    grouped <- glm_grouped(Admit ~ Gender + Dept, data = ucb_weighted, weights = ucb_weighted$Freq),
    regexp = NA
  )

  expect_equal(grouped$df.null, 11)
})

Try the parsnip package in your browser

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

parsnip documentation built on June 24, 2024, 5:14 p.m.